-
Notifications
You must be signed in to change notification settings - Fork 846
tracing: fix record_all panic #3432
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
base: main
Are you sure you want to change the base?
Conversation
2676a31 to
cf67fdb
Compare
cf67fdb to
fe8b887
Compare
| // create a dummy callsite to get a bogus field. | ||
| static __CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! { | ||
| name: "__fake_tracing_callsite", | ||
| kind: $crate::metadata::Kind::SPAN, | ||
| target: module_path!(), | ||
| level: $crate::Level::TRACE, | ||
| fields: $crate::fieldset!("__fake_tracing_field" = "fake_tracing_value"), | ||
| }; |
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.
Please suggest a better way to create a fake Field. I hate this
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.
An alternative could be some construction based on ArrayVec, we only push the fields that are found.
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.
Rather than using another dep on arrayvec, we could use MaybeUninit and the relevant unsafe. Neither Field nor Option<&dyn Value> need to be dropped, which simplifies the setup.
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.
Why does this need to be different from the original implementation before #3398?
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.
The original implementation iterates over fields in the span metadata. It doesn't construct the field name based on the actual current field given. recordall! simply never worked beyond the case of the exact same spans in the exact order.
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.
You can see that it calls $next and discards $k. So whatever is in the field name provided in recordall! is simply discarded.
Line 3003 in c47c777
| $crate::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"), |
Lines 2982 to 2987 in c47c777
| (@ { $(,)* $($out:expr),* }, $next:expr, { $k:expr } = $val:expr) => { | |
| $crate::valueset!( | |
| @ { $($out),*, (&$next, Some(&$val as &dyn $crate::field::Value)) }, | |
| $next, | |
| ) | |
| }; |
hds
left a comment
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.
Thanks for this PR!
I think it would be good to have a little more test coverage. Especially because these macros are frequent sources of unintentional breaking changes.
Motivation
Fixes #3431
Solution
This is horrible. We rename
valueset!tovalueset_all!, then we re-introduce the originalvalueset!with some notable changes.The new
valueset!doesn't use fields from the fieldset iterator, it instead usesFieldSet::field(...)to find the correct field. If the field isn't found, we set a fallback field that will be ignored (callsites are not equal).