Skip to content

Bump tracing and update API usage #2788

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

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions crates/matrix-sdk-common/src/tracing_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl TracingTimer {
#[macro_export]
macro_rules! timer {
($level:expr, $string:expr) => {{
static CALLSITE: tracing::callsite::DefaultCallsite = tracing::callsite2! {
static __CALLSITE: tracing::callsite::DefaultCallsite = tracing::callsite2! {
name: tracing::__macro_support::concat!(
"event ",
file!(),
Expand All @@ -94,7 +94,7 @@ macro_rules! timer {
fields: []
};

$crate::tracing_timer::TracingTimer::new_debug(&CALLSITE, $string.into(), $level)
$crate::tracing_timer::TracingTimer::new_debug(&__CALLSITE, $string.into(), $level)
}};

($string:expr) => {
Expand All @@ -109,7 +109,9 @@ mod tests {
async fn test_timer_name() {
use tracing::{span, Level};

tracing_subscriber::fmt::init();
tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init();

tracing::warn!("Starting test...");

mod time123 {
pub async fn run() {
Expand All @@ -128,6 +130,8 @@ mod tests {

let _timer_guard = timer!("in span");
tokio::time::sleep(instant::Duration::from_millis(256)).await;

tracing::warn!("Test about to finish.");
// Displays: 2023-08-25T15:18:31.427070Z DEBUG le 256ms span:
// matrix_sdk_common::tracing_timer::tests: in span finished in 257ms
}
Expand Down