Merge pull request #6789 from corhere/fix/otel-panic

tracing: fix panic on startup when configured
This commit is contained in:
Phil Estes 2022-04-11 14:57:56 +01:00 committed by GitHub
commit eaf286224b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,7 @@ import (
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
"go.opentelemetry.io/otel/sdk/trace"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
)
@ -49,7 +50,11 @@ func init() {
if cfg.Endpoint == "" {
return nil, fmt.Errorf("no OpenTelemetry endpoint: %w", plugin.ErrSkipPlugin)
}
return newExporter(ic.Context, cfg)
exp, err := newExporter(ic.Context, cfg)
if err != nil {
return nil, err
}
return trace.NewBatchSpanProcessor(exp), nil
},
})
plugin.Register(&plugin.Registration{