Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make trace.TraceContext as default context propagator #456

Merged
merged 6 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/trace/trace_context_propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type TraceContext struct{}
var _ propagation.TextFormat = TraceContext{}
var traceCtxRegExp = regexp.MustCompile("^[0-9a-f]{2}-[a-f0-9]{32}-[a-f0-9]{16}-[a-f0-9]{2}-?")

// DefaultPropagator is the default trace propagator.
var DefaultPropagator propagation.TextFormat = TraceContext{}
clsung marked this conversation as resolved.
Show resolved Hide resolved

func (hp TraceContext) Inject(ctx context.Context, supplier propagation.Supplier) {
sc := SpanFromContext(ctx).SpanContext()
if sc.IsValid() {
Expand Down
2 changes: 1 addition & 1 deletion plugin/grpctrace/grpctrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
propagator = trace.TraceContext{}
propagator = trace.DefaultPropagator
)

type metadataSupplier struct {
Expand Down
2 changes: 1 addition & 1 deletion plugin/httptrace/httptrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
HostKey = key.New("http.host")
URLKey = key.New("http.url")

propagator = trace.TraceContext{}
propagator = trace.DefaultPropagator
)

// Returns the Attributes, Context Entries, and SpanContext that were encoded by Inject.
Expand Down
4 changes: 2 additions & 2 deletions plugin/othttp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func WithPublicEndpoint() Option {

// WithPropagator configures the Handler with a specific propagator. If this
// option isn't specificed then
// go.opentelemetry.io/otel/api/trace.TraceContext is used.
// go.opentelemetry.io/otel/api/trace.DefaultPropagator is used.
func WithPropagator(p propagation.TextFormat) Option {
return func(h *Handler) {
h.prop = p
Expand Down Expand Up @@ -130,7 +130,7 @@ func NewHandler(handler http.Handler, operation string, opts ...Option) http.Han
h := Handler{handler: handler, operation: operation}
defaultOpts := []Option{
WithTracer(global.TraceProvider().Tracer("go.opentelemetry.io/plugin/othttp")),
WithPropagator(trace.TraceContext{}),
WithPropagator(trace.DefaultPropagator),
clsung marked this conversation as resolved.
Show resolved Hide resolved
WithSpanOptions(trace.WithSpanKind(trace.SpanKindServer)),
}

Expand Down