-
Notifications
You must be signed in to change notification settings - Fork 624
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
feat(o11y): Attach tracing context to messages received by PeerManagerActor #7866
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).
span.set_parent(context); | ||
(span, msg) | ||
}}; | ||
} |
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.
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
actor
andhandler
expressions 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_fields
tt
matcher should not be separated by commas, I think. It prevents passing through valid token forests such asfoo = expression()
etc.
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.
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.
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.
Looks great!
…rActor (#7866) This PR complete tracing of async work across all actix Actors. https://pagodaplatform.atlassian.net/browse/ND-171
This PR complete tracing of async work across all actix Actors.
https://pagodaplatform.atlassian.net/browse/ND-171