How to obtain the Parent Span ID for logging, etc. from the context of the Child Span? #4763
Unanswered
vkruglik-aka
asked this question in
Q&A
Replies: 1 comment
-
In case someone comes across this ticket looking for the same thing, here is what I came up with so far:
If would be nice if |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My app needs to include the parent span id in python log messages. opentelemetry.instrumentation.LoggingInstrumentor unfortunately doesn't add the parent span id to the LogRecord. So, how do I obtain the Parent Span ID from the context of a child span?
I searched far and wide through python opentelemetry code and don't see a way to synchronously obtain the parent span id.
For example, my app uses
FlaskInstrumentor().instrument_app(app). By the time that the get() or post() method gets called, flask instrumentation has already started a new span (probably via
with trace.get_tracer().start_as_current_span(...):`). So, my code doesn't see the span id from the traceparent or b3 headers.I need to be able to obtain the Parent Span ID in my logging.Filter subclass so that I could add the Parent Span ID to the log record.
Beta Was this translation helpful? Give feedback.
All reactions