1
0
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:
Krzesimir Nowak
2020-02-20 19:31:21 +01:00
committed by GitHub
parent bfe569d699
commit 6b97bb047a
7 changed files with 341 additions and 275 deletions

View File

@@ -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)),
}