-
Notifications
You must be signed in to change notification settings - Fork 443
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
How to get parent span? #1904
Comments
The link shared talk's about getting SpanId of parent from the Context while creating a (child) span. This is happening here. The C++ implementation doesn't provide ReadableSpan interface to get the SpanId of parent after the Span is created. This is historically by design ( to prioritize optimization over feature), and has been discussed here. Adding ReadableSpan interface would need major design changes, and won't be feasible now. |
@lalitb : What about this api? If child active span is ended, with this automatically give context of the parent span? If there's no way to get parent span from a span, and if you are writing a wrapper library for opentelemetry, that would force a user to keep track of parent spans right? In some sort of Stack/Queue structure.... it's things like this that caused me to hit issues like: #1889 and #1888. |
Yes it will give the context containing parent-span once the child active span is ended. There are no getters on Span object to obtain the parent SpanId, if that is what you are looking for. I don't know how this relates to #1889 and #1888. |
@lalitb - any way to get spanId from the context returned by, |
Something like this should work
|
@lalitb - that api doesn't seem to work... once child span is ended, current span should be the parent right? I can see GetCurrentSpan() still returned that child that's been ended. |
Please share the code you are trying. Just ending Span::End() is not enough for context unwinding. You need to ensure that the Span object (which is of type nostd::shared_ptr) gets destroyed too. |
Your right, this works
|
Opentelemetry spec says it should be possible to get a parent span given a span's context:
https://github.com/open-telemetry/opentelemetry-specification/blob/v1.0.0/specification/trace/api.md#determining-the-parent-span-from-a-context
But looking at the api, there's no apparent way how to do that? There's GetParentSpanId api in SpanData, but you can only get SpanData for InMemoryExporter.
The text was updated successfully, but these errors were encountered: