Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions go/trace/opentracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ func (jf openTracingService) New(parent Span, label string) Span {

func extractMapFromString(in string) (opentracing.TextMapCarrier, error) {
m := make(opentracing.TextMapCarrier)
items := strings.Split(in, ":")
if len(items) < 2 {
return nil, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT, "expected transmitted context to contain at least span id and trace id")
}
items := strings.Split(in, ",")
for _, v := range items {
idx := strings.Index(v, "=")
if idx < 1 {
Expand Down
5 changes: 3 additions & 2 deletions go/trace/opentracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestExtractMapFromString(t *testing.T) {
expected := make(opentracing.TextMapCarrier)
expected["apa"] = "12"
expected["banan"] = "x-tracing-backend-12"
result, err := extractMapFromString("apa=12:banan=x-tracing-backend-12")
expected["uber-trace-id"] = "123:456:789:1"
result, err := extractMapFromString("apa=12,banan=x-tracing-backend-12,uber-trace-id=123:456:789:1")
assert.NoError(t, err)
assert.Equal(t, expected, result)
}
Expand All @@ -36,6 +37,6 @@ func TestErrorConditions(t *testing.T) {
_, err := extractMapFromString("")
assert.Error(t, err)

_, err = extractMapFromString("key=value:keywithnovalue")
_, err = extractMapFromString("key=value,keywithnovalue")
assert.Error(t, err)
}