You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-27 22:49:15 +02:00
Move correlation context propagation to correlation package (#479)
Correlation context propagation shouldn't be a part of the trace package - it is a different aspect of the propagation cross-cutting concern. This commit also adds a DefaultHTTPPropagator function for correlation context propagation and makes the plugins use it. Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"go.opentelemetry.io/otel/api/core"
|
||||
"go.opentelemetry.io/otel/api/correlation"
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
@@ -128,10 +129,15 @@ func WithMessageEvents(events ...event) Option {
|
||||
// named after the operation and with any provided HandlerOptions.
|
||||
func NewHandler(handler http.Handler, operation string, opts ...Option) http.Handler {
|
||||
h := Handler{handler: handler, operation: operation}
|
||||
propagator := trace.DefaultHTTPPropagator()
|
||||
tcPropagator := trace.DefaultHTTPPropagator()
|
||||
ccPropagator := correlation.DefaultHTTPPropagator()
|
||||
props := propagation.New(
|
||||
propagation.WithInjectors(tcPropagator, ccPropagator),
|
||||
propagation.WithExtractors(tcPropagator, ccPropagator),
|
||||
)
|
||||
defaultOpts := []Option{
|
||||
WithTracer(global.TraceProvider().Tracer("go.opentelemetry.io/plugin/othttp")),
|
||||
WithPropagators(propagation.New(propagation.WithInjectors(propagator), propagation.WithExtractors(propagator))),
|
||||
WithPropagators(props),
|
||||
WithSpanOptions(trace.WithSpanKind(trace.SpanKindServer)),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user