Skip to content

OTLP trace exporter does not include W3C trace flags (bits 0–7) in Span.Flags; only sets parent isRemote bits (8–9) #7436

@nikhilmantri0902

Description

@nikhilmantri0902

Problem Statement

OTLP trace exporter does not include W3C trace flags (bits 0–7) in Span.Flags; only sets parent isRemote bits (8–9).
The OTLP trace exporter in @opentelemetry-go/ sets only the “parent is remote” flags (bits 8–9) on Span.Flags and omits the W3C trace flags (bits 0–7).
By contrast, the Java OTLP exporter sets both: lower 8 bits to the span’s TraceFlags and bits 8–9 for “parent is remote” information.
This leads to downstream consumers not receiving the sampled flag (and other trace flags) via Span.Flags for traces exported by the Go SDK.

Span.Flags should include:
Bits 0–7: span’s W3C TraceFlags (e.g., sampled)
Bits 8–9: “has parent isRemote” and “parent isRemote” per OTLP spec

Proposed Solution

Update the trace exporter to include the span’s W3C trace flags in the lower 8 bits and keep the existing 8–9 isRemote logic.
Conceptually:
For spans: flags := uint32(sd.SpanContext().TraceFlags() & 0xff)
Always set SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK
If sd.Parent().IsRemote(), also set SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK
Assign s.Flags = flags
Apply the same for links using the link’s SpanContext.TraceFlags() for bits 0–7 and the link’s SpanContext.IsRemote() for bits 8–9.

Alternatives

None

Prior Art

Java SDK Implementation:

open-telemetry/opentelemetry-java#6167
open-telemetry/opentelemetry-java#6388

Additional Context

Add any other context or screenshots about the feature request here.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions