-
Notifications
You must be signed in to change notification settings - Fork 43
Add span! macro #21
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
Add span! macro #21
Conversation
This would be awesome to have!
Sounds like a good plan to me. |
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 seems reasonable to me!
Sorry for taking a while to get to this.
fn f() {} | ||
fn type_name_of<T>(_: T) -> &'static str { | ||
std::any::type_name::<T>() | ||
} |
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.
From what I can tell this can be simplified to a
struct S;
let func_name = std::any::type_name::<S>();
let function = &func_name[..func_name.len() - 3];
Would be great if you could add a test that just calls the macro as well as bump the version of rustc in CI files to something like 1.52 or 1.53. |
Merged in f06d0fd Thanks! |
Awesome! Any chance of a patch release with this in it soon? |
Yeah I have been meaning to make some other changes too but I guess i can
just split them up.
…On Sat, 18 Sep 2021, 20:57 Benjamin Saunders, ***@***.***> wrote:
Awesome! Any chance of a patch release with this in it soon?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#21 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFFZUWNAFVWNJOSCEZ6IJDUCTHHZANCNFSM5DPR3HTQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Looks like we're seeing some SIGSEGVs on Windows in a doctest I added for the macro, which I'll need to investigate before I cut a release. |
Could not reproduce the issue locally and I bet its not a new failure mode anyway, so went ahead and published 0.12.5. |
The macro uses
file!()
andline!()
to determine the file name and line number to pass toSpan::new(...)
. It also uses a hack to determine the function name, which is the same hack used instdext::function_name!
, since the RFC to add a macro for this to the Rust stdlib is unresolved.Alternatively,
stdext
could be added as a dependency, but that's probably overkill.Also, it might be convenient to support omitting the
callstack_depth
with a default value of 62, which is the max according to Tracy documentation ("The maximum call stack depth that can be retrieved is 62 frames. This is a restriction at the level of operating system.").