Skip to content

Commit

Permalink
let client set the propagator and trace provider
Browse files Browse the repository at this point in the history
  • Loading branch information
aranjans committed Dec 24, 2024
1 parent d4ae3ab commit 95a523f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
9 changes: 0 additions & 9 deletions stats/opentelemetry/client_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ import (
otelinternaltracing "google.golang.org/grpc/stats/opentelemetry/internal/tracing"
)

func (h *clientStatsHandler) initializeTracing() {
if !h.options.isTracingEnabled() {
return
}

otel.SetTextMapPropagator(h.options.TraceOptions.TextMapPropagator)
otel.SetTracerProvider(h.options.TraceOptions.TracerProvider)
}

// traceTagRPC populates provided context with a new span using the
// TextMapPropagator supplied in trace options and internal itracing.carrier.
// It creates a new outgoing carrier which serializes information about this
Expand Down
3 changes: 3 additions & 0 deletions stats/opentelemetry/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

"go.opentelemetry.io/otel"
otelcodes "go.opentelemetry.io/otel/codes"
oteltrace "go.opentelemetry.io/otel/trace"

Expand Down Expand Up @@ -100,6 +101,8 @@ func defaultTraceOptions(_ *testing.T) (*experimental.TraceOptions, *tracetest.I
spanProcessor := trace.NewSimpleSpanProcessor(spanExporter)
tracerProvider := trace.NewTracerProvider(trace.WithSpanProcessor(spanProcessor))
textMapPropagator := propagation.NewCompositeTextMapPropagator(expstats.GRPCTraceBinPropagator{})
otel.SetTextMapPropagator(textMapPropagator)
otel.SetTracerProvider(tracerProvider)
traceOptions := &experimental.TraceOptions{
TracerProvider: tracerProvider,
TextMapPropagator: textMapPropagator,
Expand Down
9 changes: 0 additions & 9 deletions stats/opentelemetry/server_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ import (
otelinternaltracing "google.golang.org/grpc/stats/opentelemetry/internal/tracing"
)

func (h *serverStatsHandler) initializeTracing() {
if !h.options.isTracingEnabled() {
return
}

otel.SetTextMapPropagator(h.options.TraceOptions.TextMapPropagator)
otel.SetTracerProvider(h.options.TraceOptions.TracerProvider)
}

// traceTagRPC populates context with new span data using the TextMapPropagator
// supplied in trace options and internal itracing.Carrier. It creates a new
// incoming carrier which extracts an existing span context (if present) by
Expand Down

0 comments on commit 95a523f

Please sign in to comment.