Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
remove tracestate
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Mar 9, 2020
1 parent 9af785f commit 4b85f97
Showing 1 changed file with 29 additions and 47 deletions.
76 changes: 29 additions & 47 deletions tracer/propagation_ot.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
fieldNameSampled = prefixTracerState + "sampled"

traceParentKey = "traceparent"
traceStateKey = "tracestate"
)

func (p *textMapPropagator) Inject(
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -113,55 +106,44 @@ 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--
}
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 {
Expand Down

0 comments on commit 4b85f97

Please sign in to comment.