feat(o11y): Attach tracing context to messages received by PeerManagerActor - #7866
Merged
Conversation
There are two typos to be fixed. 1) `transction` needs to be fixed to `transaction`. 2) `valdiator` needs to be fixed to `validator`.
This does two rather big code motions at the same time (sorry!): * precompilation code is moved from "let's match on VMKind" style to "let's call Runtime's virtual method". To do so, we re-purpose existing `precompile` functions in the trait. Remember, those fns are essentially dead code from "pipelined" compilation * code to deal with our two-layered caching is moved from `cache.rs` into impls of VM
This way the client actors are abstracted out from the network crate. Also moved the multiplexing PeerMessage -> (View)ClientActor API, from PeerActor to NetworkState. Improved tests which started failing (this PR doesn't introduce semantic changes, therefore those tests were apparently too fragile).
nagisa
reviewed
Oct 19, 2022
| span.set_parent(context); | ||
| (span, msg) | ||
| }}; | ||
| } |
Contributor
There was a problem hiding this comment.
Instead of duplicating the macro body, consider making handler_span able to take a parameter that describes level (and invokes tracing::span!) and then add handler_debug_span/handler_trace_span helpers.
The matcher will likely look a lot like this:
macro_rules! handler_span {
(target: $target:expr, $lvl:expr, $msg:expr, $($extra_fields:tt)*) => {{
let WithSpanContext { msg, context, .. } = $msg;
let span = $crate::tracing::span!(
target: $target,
$lvl,
"handle",
handler = $crate::macros::type_name_of(&msg),
actor = $crate::macros::last_component_of_name(std::any::type_name::<Self>()),
$($extra_fields)*)
.entered();
span.set_parent(context);
(span, msg)
}}
}
macro_rules! handler_trace_span {
($target:expr, $msg:expr, $($extra_fields:tt)*) => {
$crate::handler_span!(target: $target, $crate::tracing::Level::TRACE, $msg, $($extra_fields)*
}
}I see a couple issues I didn’t spot last time too:
- it is worth it to keep
actorandhandlerexpressions within thespan!macro, as this way they will end up within theif ... {}condition that decides whether the span is enabled at all, and will be guaranteed to not be processed if the span is disabled; - The
extra_fieldsttmatcher should not be separated by commas, I think. It prevents passing through valid token forests such asfoo = expression()etc.
Contributor
Author
There was a problem hiding this comment.
Followed the approach from https://docs.rs/tracing/latest/src/tracing/macros.rs.html#24 .
Tested that handler_trace_span! can be called with repeated extra fields, including a = 2+3 fields.
nikurt
added a commit
that referenced
this pull request
Nov 9, 2022
…rActor (#7866) This PR complete tracing of async work across all actix Actors. https://pagodaplatform.atlassian.net/browse/ND-171
This file contains hidden or 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
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.
This PR complete tracing of async work across all actix Actors.
https://pagodaplatform.atlassian.net/browse/ND-171