Skip to content

Commit e8da82a

Browse files
corhereKazuyoshi Kato
authored andcommitted
tracing: fix panic on startup when configured
When support for http/protobuf was added, the OTLP tracing processor plugin was mistakenly changed to return a raw OTLP exporter instance. Consequently, the type-assertion to a trace.SpanProcessor inside the tracing pluigin would panic if the processor plugin was configured. Modify the OTLP plugin to return a BatchSpanProcessor derived from the exporter once more. Signed-off-by: Cory Snider <[email protected]> (cherry picked from commit 927b34e) Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent ec44f6b commit e8da82a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tracing/plugin/otlp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
3232
"go.opentelemetry.io/otel/propagation"
3333
"go.opentelemetry.io/otel/sdk/resource"
34+
"go.opentelemetry.io/otel/sdk/trace"
3435
sdktrace "go.opentelemetry.io/otel/sdk/trace"
3536
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
3637
)
@@ -47,7 +48,11 @@ func init() {
4748
if cfg.Endpoint == "" {
4849
return nil, fmt.Errorf("no OpenTelemetry endpoint: %w", plugin.ErrSkipPlugin)
4950
}
50-
return newExporter(ic.Context, cfg)
51+
exp, err := newExporter(ic.Context, cfg)
52+
if err != nil {
53+
return nil, err
54+
}
55+
return trace.NewBatchSpanProcessor(exp), nil
5156
},
5257
})
5358
plugin.Register(&plugin.Registration{

0 commit comments

Comments
 (0)