From 107023deaffdd93817f05c637cc2a2f2f963787c Mon Sep 17 00:00:00 2001 From: rahulpa Date: Fri, 23 Aug 2019 13:49:24 -0700 Subject: [PATCH] fix tag.Map. --- propagation/http_textformat_propagator.go | 28 +++++++++---------- .../http_textformat_propagator_test.go | 4 ++- sdk/trace/tracer.go | 2 -- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/propagation/http_textformat_propagator.go b/propagation/http_textformat_propagator.go index 9a92bc6306db..a102473d1f17 100644 --- a/propagation/http_textformat_propagator.go +++ b/propagation/http_textformat_propagator.go @@ -68,66 +68,66 @@ var _ apipropagation.Extractor = textFormatExtractor{} func (tfe textFormatExtractor) Extract() (sc core.SpanContext, tm tag.Map) { h, ok := getRequestHeader(tfe.req, traceparentHeader, false) if !ok { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } sections := strings.Split(h, "-") if len(sections) < 4 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } if len(sections[0]) != 2 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } ver, err := hex.DecodeString(sections[0]) if err != nil { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } version := int(ver[0]) if version > maxVersion { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } if version == 0 && len(sections) != 4 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } if len(sections[1]) != 32 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } result, err := strconv.ParseUint(sections[1][0:16], 16, 64) if err != nil { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } sc.TraceID.High = result result, err = strconv.ParseUint(sections[1][16:32], 16, 64) if err != nil { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } sc.TraceID.Low = result if len(sections[2]) != 16 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } result, err = strconv.ParseUint(sections[2][0:], 16, 64) if err != nil { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } sc.SpanID = result opts, err := hex.DecodeString(sections[3]) if err != nil || len(opts) < 1 { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } sc.TraceOptions = opts[0] if !sc.IsValid() { - return core.EmptySpanContext(), nil + return core.EmptySpanContext(), tag.NewEmptyMap() } // TODO: [rghetia] add tag.Map (distributed context) extraction - return sc, nil + return sc, tag.NewEmptyMap() } type textFormatInjector struct { diff --git a/propagation/http_textformat_propagator_test.go b/propagation/http_textformat_propagator_test.go index d35f1696d896..cba63806cb1e 100644 --- a/propagation/http_textformat_propagator_test.go +++ b/propagation/http_textformat_propagator_test.go @@ -18,6 +18,8 @@ import ( "net/http" "testing" + "go.opentelemetry.io/api/tag" + "github.com/google/go-cmp/cmp" "go.opentelemetry.io/api/core" "go.opentelemetry.io/propagation" @@ -118,7 +120,7 @@ func TestInjectTraceContextToHTTPReq(t *testing.T) { t.Run(tt.name, func(t *testing.T) { req, _ := http.NewRequest("GET", "http://example.com", nil) i := propagator.Injector(req) - i.Inject(tt.sc, nil) + i.Inject(tt.sc, tag.NewEmptyMap()) gotHeader := req.Header.Get("traceparent") if diff := cmp.Diff(gotHeader, tt.wantHeader); diff != "" { diff --git a/sdk/trace/tracer.go b/sdk/trace/tracer.go index f94a227164ec..5c302abc5fc4 100644 --- a/sdk/trace/tracer.go +++ b/sdk/trace/tracer.go @@ -18,7 +18,6 @@ import ( "context" "go.opentelemetry.io/api/core" - "go.opentelemetry.io/api/tag" apitrace "go.opentelemetry.io/api/trace" ) @@ -93,4 +92,3 @@ func (tr *tracer) WithComponent(component string) apitrace.Tracer { tr.component = component return tr } -