Skip to content

Commit 927b34e

Browse files
committed
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]>
1 parent 030c1ac commit 927b34e

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
@@ -33,6 +33,7 @@ import (
3333
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
3434
"go.opentelemetry.io/otel/propagation"
3535
"go.opentelemetry.io/otel/sdk/resource"
36+
"go.opentelemetry.io/otel/sdk/trace"
3637
sdktrace "go.opentelemetry.io/otel/sdk/trace"
3738
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
3839
)
@@ -49,7 +50,11 @@ func init() {
4950
if cfg.Endpoint == "" {
5051
return nil, fmt.Errorf("no OpenTelemetry endpoint: %w", plugin.ErrSkipPlugin)
5152
}
52-
return newExporter(ic.Context, cfg)
53+
exp, err := newExporter(ic.Context, cfg)
54+
if err != nil {
55+
return nil, err
56+
}
57+
return trace.NewBatchSpanProcessor(exp), nil
5358
},
5459
})
5560
plugin.Register(&plugin.Registration{

0 commit comments

Comments
 (0)