From 6769330394f78192df01cb59299e9e0f2e5e977b Mon Sep 17 00:00:00 2001 From: Rahul Patel Date: Wed, 4 Mar 2020 14:52:12 -0800 Subject: [PATCH] use NewRoot() standard code. (#513) --- plugin/othttp/handler.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/plugin/othttp/handler.go b/plugin/othttp/handler.go index 65abf904cac..0dd13a26249 100644 --- a/plugin/othttp/handler.go +++ b/plugin/othttp/handler.go @@ -53,7 +53,6 @@ type Handler struct { tracer trace.Tracer props propagation.Propagators spanStartOptions []trace.StartOption - public bool readEvent bool writeEvent bool } @@ -74,7 +73,7 @@ func WithTracer(tracer trace.Tracer) Option { // association instead of a link. func WithPublicEndpoint() Option { return func(h *Handler) { - h.public = true + h.spanStartOptions = append(h.spanStartOptions, trace.WithNewRoot()) } } @@ -91,7 +90,7 @@ func WithPropagators(ps propagation.Propagators) Option { // trace.StartOptions, which are applied to each new span. func WithSpanOptions(opts ...trace.StartOption) Option { return func(h *Handler) { - h.spanStartOptions = opts + h.spanStartOptions = append(h.spanStartOptions, opts...) } } @@ -153,20 +152,6 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // TODO: do something with the correlation context ctx := propagation.ExtractHTTP(r.Context(), h.props, r.Header) - - // not a valid span context, so no link / parent relationship to establish - if sc := trace.RemoteSpanContextFromContext(ctx); sc.IsValid() { - var opt trace.StartOption - if h.public { - // If the endpoint is a public endpoint, it should start a new trace - // and incoming remote sctx should be added as a link. - opt = trace.LinkedTo(sc) - opts = append(opts, opt) - } else { // not a private endpoint, so assume child relationship - ctx = trace.ContextWithRemoteSpanContext(ctx, sc) - } - } - ctx, span := h.tracer.Start(ctx, h.operation, opts...) defer span.End()