-
Notifications
You must be signed in to change notification settings - Fork 83
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
Copy parent trace_id from parent span #80
base: v0.1.x
Are you sure you want to change the base?
Conversation
Hm could you elaborate more on the case where parent span ids are not currently copied? Currently the trace id is intentionally only tracked for cases where there is no active parent so it can be used for pre-sampling. |
TIL, I didn't know that's how sampling was handled internally. I haven't looked to much in depth how it's implemented, but I suppose the trace_id is generated when the span is closed instead of when it's created? If that's the case, I'm not really sure how I could solve my problem. The use-case I currently have is to copy the I had to close the original PR due to a circular dependency issue, but I'm using my own version of the |
So the main issue is ordering around calls to |
Could a more reliable approach be to buffer the LogRecords, this way we could retrieve a stable trace_id and export them without having to consider calls to |
@maximebedard maybe, you could explore that path and see what tradeoffs you would have to make. Potentially unbounded buffering as logs within a given span aren't capped, also delaying log export until the parent is closed be undesirable. Alternatively we could consider a special field type solution where if a trace id has been set there it can't be re assigned, and there may be other possible alternative solutions to explore as well. |
@jtescher the related opentelemetry rust change open-telemetry/opentelemetry-rust#1394 |
Motivation
I ran into an issue where the trace_id of the parent span is not copied into the
SpanContext
of the current span. This can be especially problematic when downstream APIs rely on theOtelData
structure to extract the trace_id and span_id.I believe the test was incorrect as it was only checking that the value was left unchanged in the parent span, not that the trace_id of the current span was set.
I believe this is related to #77.
Solution
I'm copying the trace_id from the
parent_cx.span
when the span has a parent context. Otherwise we generate a new trace_id. I've updated the test_tracer to generate sequential{TraceId,SpanId}
to potentially avoid comparing against{TraceId,SpanId}::INVALID
.Thanks!