-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
tracing: instrument more resources #4302
Conversation
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
tokio/src/sync/batch_semaphore.rs
Outdated
cfg_trace! { | ||
return Self { | ||
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT), | ||
waiters: Mutex::const_new(Waitlist { | ||
queue: LinkedList::new(), | ||
closed: false, | ||
}), | ||
resource_span: tracing::Span::none(), | ||
}; | ||
} | ||
|
||
cfg_not_trace! { | ||
return Self { | ||
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT), | ||
waiters: Mutex::const_new(Waitlist { | ||
queue: LinkedList::new(), | ||
closed: false, | ||
}), | ||
}; | ||
} |
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.
Surely there must be a better way...
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.
I would like to believe so. Any ideas?
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.
What happens if you do this?
return Self {
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT),
waiters: Mutex::const_new(Waitlist {
queue: LinkedList::new(),
closed: false,
}),
#[cfg(tracing)]
resource_span: tracing::Span::none(),
};
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 a lot, I have changed it to use this approach in other places as well
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
Signed-off-by: Zahari Dichev <[email protected]>
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. Looks good to merge.
As a general comment, there probably are opportunities to clean up the code and avoid all the cfg
attributes in the main source. We can worry about that in a follow up PR. I'm happy to work with you on figuring out strategies to clean it up.
The change here will only apply when the unstable flag is enabled, so lets move forward and cleanup incrementally.
This PR adds instrumentation to more resources from the
sync
package.Related: tokio-rs/console#188