Open dankhan-helmet opened 2 weeks ago
To clarify the bug here, I switched back to 0.18.3, before the new contextManager code was deployed, and in which the previous recommendation was to use Context.current.span
instead of contextManager.active
in the new version - in doing this, the root span is setup correctly as a valid span and with the correct parent id, so looks to be a bug introduced with the new context manager functions where the root span isn't being set up correctly with the new contextManager setup.
Old code, working under 0.18.3, with valid root span:
Context.current.span.setAttributes([
Attribute.fromString('platform.os', 'web'),
]);
Latest code, no longer working under 0.18.6 because the root span is missing:
spanFromContext(contextManager.active).setAttributes([
Attribute.fromString('platform.os', 'web'),
]);
Screenshot of the active span parentId in 0.18.3 for comparison to my previous screenshot:
Describe the bug When I use the
traceContextSync
ortraceContext
helper functions, the first call toglobalContextManager.active
presumably to get the root span if no others have been created, returns a NonRecordingSpan with an invalid parent spanId (0000000) instead of the root span with spanId ([]).I assume the root span would be setup automatically so that there's always a starting context available? Maybe this assumption is wrong, but it's not clear from the docs/README.
The span exports to Jaegar okay (but it could just ignore a missing parent span so maybe the problem isn't being shown there, but exporting the same data to honeycomb, the problem is more obvious as they render the root span as a missing span).
If this isn't an error and just a user-error, I'd be grateful for some additional examples in the readme that discuss how to set up the root span (if required) and how to use these helper functions correctly. Thanks.
Steps to reproduce
Note: even if you don't use the helper functions, it returns the same result with parent spanid as 0000000 instead of an empty spanid to indicate the root span, making me think there is no root span setup:
What did you expect to see? Expected that the first call to globalContextManager.active would get the root context and a valid recording span, that doesn't have an invalid parent SpanId
What did you see instead? It returns a non-recording invalid span id span with parentId = 00000000 instead of [].
What version and what artifacts are you using? Artifacts: (
opentelemetry-api
,opentelemetry-sdk
, which BatchSpanProcessor, ) Version: opentelemetry: ^0.18.6 How did you reference these artifacts? (excerpt from yourpubspec.lock
,pubspec.yaml
, etc)Environment Dart Version: Dart SDK version: 3.3.0 (stable) (Tue Feb 13 10:25:19 2024 +0000) on "macos_arm64" OS: Flutter (Channel stable, 3.19.2, on macOS 13.6.4 22G513 darwin-arm64, locale en-NZ)
Additional context Add any other context about the problem here.