-
Notifications
You must be signed in to change notification settings - Fork 0
fix(span): skip zero parent span id from empty traceparent (#23) #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1243,6 +1243,32 @@ var suites = []FixtureSuite{ | |
| }, | ||
| }, | ||
| }, | ||
| // #23: --tp-ignore-env should not produce a zero-valued parent span id | ||
| { | ||
| { | ||
| Name: "#23 --tp-ignore-env should not send zero parent span id", | ||
| Config: FixtureConfig{ | ||
| CliArgs: []string{ | ||
| "span", | ||
| "--endpoint", "{{endpoint}}", | ||
| "--tp-ignore-env", | ||
| "--name", "test-tp-ignore", | ||
| }, | ||
| Env: map[string]string{ | ||
| "TRACEPARENT": "00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01", | ||
| }, | ||
| }, | ||
| Expect: Results{ | ||
| Config: otelcli.DefaultConfig(), | ||
| SpanData: map[string]string{ | ||
| "trace_id": "*", | ||
| "span_id": "*", | ||
| "parent_span_id": "", | ||
| }, | ||
|
Comment on lines
+1263
to
+1267
|
||
| SpanCount: 1, | ||
| }, | ||
| }, | ||
| }, | ||
| // full-system test --otlp-headers makes it to grpc/http servers | ||
| { | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||
| package otelcli | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import ( | ||||||||||||||||||||||
| "bytes" | ||||||||||||||||||||||
| "encoding/hex" | ||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||
| "io" | ||||||||||||||||||||||
|
|
@@ -42,7 +43,10 @@ func (c Config) NewProtobufSpan() *tracepb.Span { | |||||||||||||||||||||
| tp := c.LoadTraceparent() | ||||||||||||||||||||||
| if tp.Initialized { | ||||||||||||||||||||||
| span.TraceId = tp.TraceId | ||||||||||||||||||||||
| span.ParentSpanId = tp.SpanId | ||||||||||||||||||||||
| // only set parent span id when the traceparent has a real (non-zero) span id (#23) | ||||||||||||||||||||||
| if !bytes.Equal(tp.SpanId, otlpclient.GetEmptySpanId()) { | ||||||||||||||||||||||
|
Comment on lines
44
to
+47
|
||||||||||||||||||||||
| if tp.Initialized { | |
| span.TraceId = tp.TraceId | |
| span.ParentSpanId = tp.SpanId | |
| // only set parent span id when the traceparent has a real (non-zero) span id (#23) | |
| if !bytes.Equal(tp.SpanId, otlpclient.GetEmptySpanId()) { | |
| emptySpanID := otlpclient.GetEmptySpanId() | |
| if tp.Initialized { | |
| span.TraceId = tp.TraceId | |
| // only set parent span id when the traceparent has a real (non-zero) span id (#23) | |
| if !bytes.Equal(tp.SpanId, emptySpanID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says “zero-valued parent span id”, but the assertion checks for an empty string (i.e., omitted/empty
parent_span_id), not the all-zeros hex representation. Consider rewording the comment and/or test name to explicitly say the parent span id should be empty/omitted (and not0000000000000000).