diff --git a/tracer/propagation_ot.go b/tracer/propagation_ot.go index 79cef10c..f314c129 100644 --- a/tracer/propagation_ot.go +++ b/tracer/propagation_ot.go @@ -30,7 +30,6 @@ const ( fieldNameSampled = prefixTracerState + "sampled" traceParentKey = "traceparent" - traceStateKey = "tracestate" ) func (p *textMapPropagator) Inject( @@ -64,16 +63,10 @@ func (p *textMapPropagator) Inject( ) carrier.Set(traceParentKey, traceParentValue) - var traceStatePairs []string - for k, v := range sc.Baggage { carrier.Set(prefixBaggage+k, v) - traceStatePairs = append(traceStatePairs, k+"="+v) } - traceStateValue := strings.Join(traceStatePairs, ",") - carrier.Set(traceStateKey, traceStateValue) - return nil } @@ -113,16 +106,7 @@ func (p *textMapPropagator) Extract( if traceParentArray[3] == "01" { sampled = true } - requiredFieldCount = requiredFieldCount + 2 - case traceStateKey: - traceStateArray := strings.Split(v, ",") - for _, stItem := range traceStateArray { - stItem = strings.TrimSpace(stItem) - if strings.IndexRune(stItem, '=') > -1 { - stItemArray := strings.Split(stItem, "=") - decodedBaggage[stItemArray[0]] = stItemArray[1] - } - } + requiredFieldCount = requiredFieldCount + 3 default: // Balance off the requiredFieldCount++ just below... requiredFieldCount-- @@ -130,38 +114,36 @@ func (p *textMapPropagator) Extract( requiredFieldCount++ return nil }) - if traceID == uuid.Nil && spanID == 0 { - err = carrier.ForeachKey(func(k, v string) error { - switch strings.ToLower(k) { - case fieldNameTraceID: - traceID, err = uuid.Parse(v) - if err != nil { - return opentracing.ErrSpanContextCorrupted - } - case fieldNameSpanID: - spanID, err = strconv.ParseUint(v, 16, 64) - if err != nil { - return opentracing.ErrSpanContextCorrupted - } - case fieldNameSampled: - sampled, err = strconv.ParseBool(v) - if err != nil { - return opentracing.ErrSpanContextCorrupted - } - default: - lowercaseK := strings.ToLower(k) - if strings.HasPrefix(lowercaseK, prefixBaggage) { - decodedBaggage[strings.TrimPrefix(lowercaseK, prefixBaggage)] = v - } - // Balance off the requiredFieldCount++ just below... - requiredFieldCount-- + err = carrier.ForeachKey(func(k, v string) error { + switch strings.ToLower(k) { + case fieldNameTraceID: + traceID, err = uuid.Parse(v) + if err != nil { + return opentracing.ErrSpanContextCorrupted } - requiredFieldCount++ - return nil - }) - if err != nil { - return nil, err + case fieldNameSpanID: + spanID, err = strconv.ParseUint(v, 16, 64) + if err != nil { + return opentracing.ErrSpanContextCorrupted + } + case fieldNameSampled: + sampled, err = strconv.ParseBool(v) + if err != nil { + return opentracing.ErrSpanContextCorrupted + } + default: + lowercaseK := strings.ToLower(k) + if strings.HasPrefix(lowercaseK, prefixBaggage) { + decodedBaggage[strings.TrimPrefix(lowercaseK, prefixBaggage)] = v + } + // Balance off the requiredFieldCount++ just below... + requiredFieldCount-- } + requiredFieldCount++ + return nil + }) + if err != nil { + return nil, err } if requiredFieldCount < tracerStateFieldCount {