Skip to content

Commit

Permalink
tracing: fix panic on startup when configured
Browse files Browse the repository at this point in the history
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 <csnider@mirantis.com>
  • Loading branch information
corhere committed Apr 7, 2022
1 parent 030c1ac commit 927b34e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tracing/plugin/otlp.go
Expand Up @@ -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"
)
Expand All @@ -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{
Expand Down

0 comments on commit 927b34e

Please sign in to comment.