-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opentelemetry: enforce event_location for span tags (#2124)
The `with_event_location(false)` method will now properly omit `code.*` tags from spans. ## Motivation Recently, I attempted to remove the `code.*` tags from opentelemetry tracing spans utilizing the [`with_event_location`] of OpenTelemetrySubscriber. This did not work as expected because the [`on_new_span`] doesn't account for the `event_location` boolean similar to how [`on_event`] does. ## Solution The change presented will expand the use of the `location` field to check before adding the `code.*` KeyValue attributes in `on_new_span`. In addition, `with_event_location` was renamed to `with_location`, as it now controls both span *and* event locations, and the `with_event_location` method has been deprecated. ## Testing Additional unit tests are included in [tracing-opentelemetry/src/subscriber.rs] to cover both boolean cases of `with_location`. [`with_event_location`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L343 [`on_new_span`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L448-L460 [`on_event`]: https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/subscriber.rs#L582 [tracing-opentelemetry/src/subscriber.rs]: https://github.com/tokio-rs/tracing/pull/2124/files#diff-69011e8b23dffcbe19b9b72e5ac54330a7871f424a90700ed7f5c5686daf431bR911-R975)
- Loading branch information
Showing
1 changed file
with
88 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters