Skip to content
Merged
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
26 changes: 26 additions & 0 deletions data_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment on lines +1246 to +1249
Copy link

Copilot AI Feb 9, 2026

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 not 0000000000000000).

Suggested change
// #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",
// #23: --tp-ignore-env should result in an empty/omitted parent span id (not 0000000000000000)
{
{
Name: "#23 --tp-ignore-env should omit parent span id (empty/omitted, not 0000000000000000)",

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 9, 2026

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 not 0000000000000000).

Copilot uses AI. Check for mistakes.
SpanCount: 1,
},
},
},
// full-system test --otlp-headers makes it to grpc/http servers
{
{
Expand Down
6 changes: 5 additions & 1 deletion otelcli/config_span.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package otelcli

import (
"bytes"
"encoding/hex"
"fmt"
"io"
Expand Down Expand Up @@ -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
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor readability improvement: consider storing otlpclient.GetEmptySpanId() in a local variable (e.g., emptySpanID := ...) before the if, so the comparison reads more clearly and avoids repeating a function call in the condition.

Suggested change
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) {

Copilot uses AI. Check for mistakes.
span.ParentSpanId = tp.SpanId
}
}
} else {
span.TraceId = otlpclient.GetEmptyTraceId()
Expand Down