-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v2] Fix the special case for jaeger format traceid extraction (#340)
* Fix the special case for jaeger format traceid extraction being overridden regression introduced with #262 * Add unit test for Jaeger trace id parsing fix
- Loading branch information
Showing
2 changed files
with
49 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tracing | ||
|
||
import ( | ||
"fmt" | ||
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/tags" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestTagsCarrier_Set_JaegerTraceFormat(t *testing.T) { | ||
var ( | ||
fakeTraceSampled = 1 | ||
fakeInboundTraceId = "deadbeef" | ||
fakeInboundSpanId = "c0decafe" | ||
traceHeaderName = "uber-trace-id" | ||
) | ||
|
||
traceHeaderValue := fmt.Sprintf("%s:%s:%s:%d", fakeInboundTraceId, fakeInboundSpanId, fakeInboundSpanId, fakeTraceSampled) | ||
|
||
c := &tagsCarrier{ | ||
Tags: tags.NewTags(), | ||
traceHeaderName: traceHeaderName, | ||
} | ||
|
||
c.Set(traceHeaderName, traceHeaderValue) | ||
|
||
assert.EqualValues(t, map[string]string{ | ||
TagTraceId: fakeInboundTraceId, | ||
TagSpanId: fakeInboundSpanId, | ||
TagSampled: "true", | ||
}, c.Tags.Values()) | ||
} |