248
func (ec *exportConfig) buildOtlpGrpcMetricExporter(
249
cfg *otlpGrpcMetricExporter,
251
>
dopts := cfg.Connection.dialOpts()
252
>
opts := []otlpmetricgrpc.Option{
253
>
otlpmetricgrpc.WithEndpoint(cfg.Connection.Endpoint),
254
>
otlpmetricgrpc.WithHeaders(cfg.Headers),
255
>
otlpmetricgrpc.WithTimeout(cmp.Or(cfg.Timeout, 10*time.Second)),
256
>
otlpmetricgrpc.WithDialOption(dopts...),
257
>
otlpmetricgrpc.WithRetry(otlpmetricgrpc.RetryConfig{
258
>
Enabled: cmp.Or(cfg.Retry.Enabled, retryDefaultEnabled),
259
>
InitialInterval: cmp.Or(cfg.Retry.InitialInterval, retryDefaultInitialInterval),
260
>
MaxInterval: cmp.Or(cfg.Retry.MaxInterval, retryDefaultMaxInterval),
261
>
MaxElapsedTime: cmp.Or(cfg.Retry.MaxElapsedTime, retryDefaultMaxElapsedTime),
262
>
}),
263
>
}
264
>
265
>
// work around https://github.com/open-telemetry/opentelemetry-go/issues/2940
266
>
if cfg.Connection.Insecure {
267
opts = append(opts, otlpmetricgrpc.WithInsecure())
268
}
269
270
>
if cfg.ConnectionName == "" {
config.go
271
return otlpmetricgrpc.New(context.Background(), opts...)
272
}
273
274
>
conncfg, ok := ec.findNamedGrpcConnCfg(cfg.ConnectionName)
config.go
275
>
if !ok {
276
return nil, fmt.Errorf("OTEL exporter connection %q not found", cfg.ConnectionName)
277
}
278
>
return &sharedConnMetricExporter{
config.go
279
>
baseOpts: opts,
280
>
dialer: conncfg,
281
>
}, nil
282
}
283
284
func (ec *exportConfig) buildOtlpGrpcSpanExporter(
285
cfg *otlpGrpcSpanExporter,
286
>
) (otelsdktrace.SpanExporter, error) {
config.go
287
>
opts := []otlptracegrpc.Option{
288
>
otlptracegrpc.WithEndpoint(cfg.Connection.Endpoint),
289
>
otlptracegrpc.WithHeaders(cfg.Headers),
290
>
otlptracegrpc.WithTimeout(cmp.Or(cfg.Timeout, 10*time.Second)),
291
>
otlptracegrpc.WithDialOption(cfg.Connection.dialOpts()...),
292
>
otlptracegrpc.WithRetry(otlptracegrpc.RetryConfig{
293
>
Enabled: cmp.Or(cfg.Retry.Enabled, retryDefaultEnabled),
294
>
InitialInterval: cmp.Or(cfg.Retry.InitialInterval, retryDefaultInitialInterval),
295
>
MaxInterval: cmp.Or(cfg.Retry.MaxInterval, retryDefaultMaxInterval),
296
>
MaxElapsedTime: cmp.Or(cfg.Retry.MaxElapsedTime, retryDefaultMaxElapsedTime),
297
>
}),
298
>
}
299
>
300
>
// work around https://github.com/open-telemetry/opentelemetry-go/issues/2940
301
>
if cfg.Connection.Insecure {
302
opts = append(opts, otlptracegrpc.WithInsecure())
303
}
304
305
>
if cfg.ConnectionName == "" {
config.go
306
return otlptracegrpc.NewUnstarted(opts...), nil
307
}
308
309
>
conncfg, ok := ec.findNamedGrpcConnCfg(cfg.ConnectionName)
config.go
310
>
if !ok {
311
return nil, fmt.Errorf("OTEL exporter connection %q not found", cfg.ConnectionName)
312
}
313
>
return &sharedConnSpanExporter{
config.go
314
>
baseOpts: opts,
315
>
dialer: conncfg,
316
>
}, nil
317
}
318