-
Notifications
You must be signed in to change notification settings - Fork 746
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
subscriber: fix span data for new, exit, and close events #1334
Merged
hawkw
merged 8 commits into
tokio-rs:master
from
akinnane:span_events_use_subject_span_data
Apr 7, 2021
Merged
subscriber: fix span data for new, exit, and close events #1334
hawkw
merged 8 commits into
tokio-rs:master
from
akinnane:span_events_use_subject_span_data
Apr 7, 2021
Conversation
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
New, exit and close span events are generated while the current context is set to either `None` or the parent span of the span the event relates to. This causes spans data to be absent from the JSON output in the case of the `None`, or causes the span data to reference the parent's span data. Changing the way the current span is determined allows the correct span to be identified for these events. Trying to access the events `.parent()` allows access of the correct span for the `on_event` actions, while using `.current_span()` works for normal events. Ref: tokio-rs#1032
Based on feedback by @hawkw, I've improved the test for tokio-rs#1333 to parse the json output. This is more specifc for the bug and allows easier testing of the different span `on_events`. Ref: tokio-rs#1333 (review)
Use the `on_records` test method check all events have the correct context as described in the PR.
hawkw
approved these changes
Apr 6, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me --- I had a couple of non-blocking style suggestions.
hawkw
added a commit
that referenced
this pull request
Apr 16, 2021
* subscriber: fix span data for new, exit, and close events New, exit and close span events are generated while the current context is set to either `None` or the parent span of the span the event relates to. This causes spans data to be absent from the JSON output in the case of the `None`, or causes the span data to reference the parent's span data. Changing the way the current span is determined allows the correct span to be identified for these events. Trying to access the events `.parent()` allows access of the correct span for the `on_event` actions, while using `.current_span()` works for normal events. Ref: #1032 * Fix style * subscriber: improve test for #1333 Based on feedback by @hawkw, I've improved the test for #1333 to parse the json output. This is more specifc for the bug and allows easier testing of the different span `on_events`. Ref: #1333 (review) * subscriber: improve #1334 tests covering all span states Use the `on_records` test method check all events have the correct context as described in the PR. * Apply suggestions from code review Co-authored-by: Eliza Weisman <eliza@buoyant.io>
Merged
hawkw
added a commit
that referenced
this pull request
Apr 17, 2021
* subscriber: fix span data for new, exit, and close events New, exit and close span events are generated while the current context is set to either `None` or the parent span of the span the event relates to. This causes spans data to be absent from the JSON output in the case of the `None`, or causes the span data to reference the parent's span data. Changing the way the current span is determined allows the correct span to be identified for these events. Trying to access the events `.parent()` allows access of the correct span for the `on_event` actions, while using `.current_span()` works for normal events. Ref: #1032 * Fix style * subscriber: improve test for #1333 Based on feedback by @hawkw, I've improved the test for #1333 to parse the json output. This is more specifc for the bug and allows easier testing of the different span `on_events`. Ref: #1333 (review) * subscriber: improve #1334 tests covering all span states Use the `on_records` test method check all events have the correct context as described in the PR. * Apply suggestions from code review Co-authored-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Apr 30, 2021
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [#1321]: #1321 [#1333]: #1333 [#1334]: #1334 [#1355]: #1355 [#1368]: #1368
hawkw
added a commit
that referenced
this pull request
May 1, 2021
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [#1321]: #1321 [#1333]: #1333 [#1334]: #1334 [#1355]: #1355 [#1368]: #1368
kaffarell
pushed a commit
to kaffarell/tracing
that referenced
this pull request
May 22, 2024
# 0.2.18 (April 30, 2021) ### Deprecated - Deprecated the `CurrentSpan` type, which is inefficient and largely superseded by the `registry` API ([tokio-rs#1321]) ### Fixed - **json**: Invalid JSON emitted for events in spans with no fields ([tokio-rs#1333]) - **json**: Missing span data for synthesized new span, exit, and close events ([tokio-rs#1334]) - **fmt**: Extra space before log lines when timestamps are disabled ([tokio-rs#1355]) ### Added - **env-filter**: Support for filters on spans whose names contain any characters other than `{` and `]` ([tokio-rs#1368]) Thanks to @Folyd, and new contributors @akinnane and @aym-v for contributing to this release! [tokio-rs#1321]: tokio-rs#1321 [tokio-rs#1333]: tokio-rs#1333 [tokio-rs#1334]: tokio-rs#1334 [tokio-rs#1355]: tokio-rs#1355 [tokio-rs#1368]: tokio-rs#1368
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Span
on_events
don't display correct span data when using JSON formatter and theon_event
is triggered from a parent context.Ref: #1032
The
enter
andlogline
events correctly show the span subject's metadata. However, thenew
,exit
, andclose
events show the span's parent span's metadata instead. The finalexit
andclose
events show no metadata as there is no grandparent span to retrieve metadata from.This shows the timeline of events and the span context they display.
This is primarily caused because
FomatEvents::format_event
usesctx.ctx.current_span()
to determine the context for the current event.I think the
new
,close
andexit
events should show the metadata for the span referenced in the event'smessage
, however, theseon_event
actions exist outside the context of the referenced span and show the metadata for that context/span instead.Solution
This change tries to use
event.parent()
to determine the correct span context for the event, falling back toctx.ctx.current_span()
If there is noevent.parent()
in the current event. It produces the following output where each JSON line displays the event subject's metadata.