Skip to content

Commit

Permalink
Set builder parent span to None when manually setting parent (#26)
Browse files Browse the repository at this point in the history
## Motivation

When I tried to find a parent span as someone not familiar with the code
I tried using what's in the builder and if there's None I tried the
parent context (which always has trace ID, it just might be invalid).

This change should simplify this for people unfamiliar with the codebase
by getting rid of the trace ID that's not used.

## Solution

Set trace ID in builder to `None`. It has not been used anywhere if
parent_cx contained a valid trace ID so no other changes are needed.

Signed-off-by: David Mládek <david.mladek.cz@gmail.com>
  • Loading branch information
mladedav authored Jun 1, 2023
1 parent 5ce1b10 commit 040c57a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/span_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl OpenTelemetrySpanExt for tracing::Span {
get_context.with_context(subscriber, id, move |data, _tracer| {
if let Some(cx) = cx.take() {
data.parent_cx = cx;
data.builder.trace_id = None;
}
});
}
Expand Down

0 comments on commit 040c57a

Please sign in to comment.