fix: export parent span identifiers - #59
Open
incidere wants to merge 1 commit into
Open
Conversation
inge4pres
reviewed
Aug 15, 2026
| /// Span represents a single operation within a trace. | ||
| pub const Span = struct { | ||
| span_context: SpanContext, | ||
| parent_span_id: ?trace.SpanID, |
Member
There was a problem hiding this comment.
Did you omit the default null value assignment on purpose?
Since this is a public API field, adding the optional field would break compilation for all users.
Suggested change
| parent_span_id: ?trace.SpanID, | |
| parent_span_id: ?trace.SpanID = null, |
|
|
||
| // Create the span with instrumentation scope | ||
| var span = trace_api.Span.init(allocator, span_context, span_name, options.kind, self.scope); | ||
| span.parent_span_id = if (parent_span_context) |parent_sc| parent_sc.span_id else null; |
Member
There was a problem hiding this comment.
The spec says an invalid parent SpanContext makes the new span a root span.
Since we don't check the parent when we extract it from context, so we should add a validity check
Suggested change
| span.parent_span_id = if (parent_span_context) |parent_sc| parent_sc.span_id else null; | |
| span.parent_span_id = if (parent_span_context) |parent_sc| | |
| (if (parent_sc.span_id.isValid()) parent_sc.span_id else null) | |
| else | |
| null; |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #55.
What changed
Validation
zig fmt --check opentelemetry-sdk/src/api/trace/span.zig opentelemetry-sdk/src/sdk/trace/provider.zig opentelemetry-sdk/src/sdk/trace/span_processor.zig opentelemetry-sdk/src/sdk/trace/exporters/generic.zig opentelemetry-sdk/src/sdk/trace/exporters/otlp.zigzig build sdk-test -Dtarget=x86_64-linux-musl— 291 tests passedzig build sdk-examples -Dtarget=x86_64-linux-musl