From 0c1253a6c347714a54a0e8df4cfd9700af4fdb79 Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 14:44:46 +0800 Subject: [PATCH 1/6] rename path_name to full_name Signed-off-by: Andy Lok --- CHANGELOG.md | 2 +- minitrace-macro/src/lib.rs | 14 +++++++------- ...nd-path-name.rs => has-name-and-full-name.rs} | 2 +- ...name.stderr => has-name-and-full-name.stderr} | 6 +++--- .../ui/ok/{has-path-name.rs => has-full-name.rs} | 2 +- ...nd-path-name.rs => has-name-and-full-name.rs} | 2 +- minitrace/tests/lib.rs | 16 ++++++++-------- 7 files changed, 22 insertions(+), 22 deletions(-) rename minitrace-macro/tests/ui/err/{has-name-and-path-name.rs => has-name-and-full-name.rs} (52%) rename minitrace-macro/tests/ui/err/{has-name-and-path-name.stderr => has-name-and-full-name.stderr} (54%) rename minitrace-macro/tests/ui/ok/{has-path-name.rs => has-full-name.rs} (80%) rename minitrace-macro/tests/ui/ok/{has-name-and-path-name.rs => has-name-and-full-name.rs} (72%) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb62a2d3..dc95ab50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## v0.6.1 -- Add macro attribute `#[trace(path_name = true)]` to use the full path of the function instead of only the function name. +- Add macro attribute `#[trace(full_name = true)]` to use the full path of the function instead of only the function name. ## v0.6.0 diff --git a/minitrace-macro/src/lib.rs b/minitrace-macro/src/lib.rs index 67c1bbef..f521325b 100644 --- a/minitrace-macro/src/lib.rs +++ b/minitrace-macro/src/lib.rs @@ -36,7 +36,7 @@ impl Args { let mut args = HashSet::new(); let mut func_name = func_name; - let mut path_name = false; + let mut full_name = false; let mut enter_on_poll = false; for arg in &input { @@ -53,9 +53,9 @@ impl Args { path, lit: Lit::Bool(b), .. - })) if path.is_ident("path_name") => { - path_name = b.value; - args.insert("path_name"); + })) if path.is_ident("full_name") => { + full_name = b.value; + args.insert("full_name"); } NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, @@ -69,9 +69,9 @@ impl Args { } } - let name = if path_name { + let name = if full_name { if args.contains("name") { - abort_call_site!("`name` and `path_name` can not be used together"); + abort_call_site!("`name` and `full_name` can not be used together"); } Name::FullPath } else { @@ -100,7 +100,7 @@ impl Args { /// ## Arguments /// /// * `name` - The name of the span. Defaults to the function name. -/// * `path_name` - Whether to use the full path of the function as the span name. Defaults to `false`. +/// * `full_name` - Whether to use the full path of the function as the span name. Defaults to `false`. /// * `enter_on_poll` - Whether to enter the span on poll, if set to `false`, `in_span` will be used. /// Only available for `async fn`. Defaults to `false`. /// diff --git a/minitrace-macro/tests/ui/err/has-name-and-path-name.rs b/minitrace-macro/tests/ui/err/has-name-and-full-name.rs similarity index 52% rename from minitrace-macro/tests/ui/err/has-name-and-path-name.rs rename to minitrace-macro/tests/ui/err/has-name-and-full-name.rs index 50edfe36..3290483e 100644 --- a/minitrace-macro/tests/ui/err/has-name-and-path-name.rs +++ b/minitrace-macro/tests/ui/err/has-name-and-full-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", path_name = true)] +#[trace(name = "Name", full_name = true)] fn f() {} fn main() {} diff --git a/minitrace-macro/tests/ui/err/has-name-and-path-name.stderr b/minitrace-macro/tests/ui/err/has-name-and-full-name.stderr similarity index 54% rename from minitrace-macro/tests/ui/err/has-name-and-path-name.stderr rename to minitrace-macro/tests/ui/err/has-name-and-full-name.stderr index 74662dc2..c29ad4c8 100644 --- a/minitrace-macro/tests/ui/err/has-name-and-path-name.stderr +++ b/minitrace-macro/tests/ui/err/has-name-and-full-name.stderr @@ -1,7 +1,7 @@ -error: `name` and `path_name` can not be used together - --> tests/ui/err/has-name-and-path-name.rs:3:1 +error: `name` and `full_name` can not be used together + --> tests/ui/err/has-name-and-full-name.rs:3:1 | -3 | #[trace(name = "Name", path_name = true)] +3 | #[trace(name = "Name", full_name = true)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the attribute macro `trace` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/minitrace-macro/tests/ui/ok/has-path-name.rs b/minitrace-macro/tests/ui/ok/has-full-name.rs similarity index 80% rename from minitrace-macro/tests/ui/ok/has-path-name.rs rename to minitrace-macro/tests/ui/ok/has-full-name.rs index 61bf908e..c30373e4 100644 --- a/minitrace-macro/tests/ui/ok/has-path-name.rs +++ b/minitrace-macro/tests/ui/ok/has-full-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(path_name = true)] +#[trace(full_name = true)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace-macro/tests/ui/ok/has-name-and-path-name.rs b/minitrace-macro/tests/ui/ok/has-name-and-full-name.rs similarity index 72% rename from minitrace-macro/tests/ui/ok/has-name-and-path-name.rs rename to minitrace-macro/tests/ui/ok/has-name-and-full-name.rs index 7c17d5ac..01346397 100644 --- a/minitrace-macro/tests/ui/ok/has-name-and-path-name.rs +++ b/minitrace-macro/tests/ui/ok/has-name-and-full-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", path_name = false)] +#[trace(name = "Name", full_name = false)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace/tests/lib.rs b/minitrace/tests/lib.rs index 77844bf7..49143eff 100644 --- a/minitrace/tests/lib.rs +++ b/minitrace/tests/lib.rs @@ -486,13 +486,13 @@ fn macro_example() { futures_timer::Delay::new(std::time::Duration::from_millis(i)).await; } - #[trace(path_name = true)] - fn do_something_path_name(i: u64) { + #[trace(full_name = true)] + fn do_something_full_name(i: u64) { std::thread::sleep(std::time::Duration::from_millis(i)); } - #[trace(path_name = true)] - async fn do_something_async_path_name(i: u64) { + #[trace(full_name = true)] + async fn do_something_async_full_name(i: u64) { futures_timer::Delay::new(std::time::Duration::from_millis(i)).await; } @@ -504,8 +504,8 @@ fn macro_example() { let _g = root.set_local_parent(); do_something(100); block_on(do_something_async(100)); - do_something_path_name(100); - block_on(do_something_async_path_name(100)); + do_something_full_name(100); + block_on(do_something_async_full_name(100)); } minitrace::flush(); @@ -514,8 +514,8 @@ fn macro_example() { root [] do_something [] do_something_async [] - lib::macro_example::{{closure}}::do_something_async_path_name [] - lib::macro_example::{{closure}}::do_something_path_name [] + lib::macro_example::{{closure}}::do_something_async_full_name [] + lib::macro_example::{{closure}}::do_something_full_name [] "#; assert_eq!( tree_str_from_span_records(collected_spans.lock().clone()), From 7dcd94568a50d153879fe5cfaac2c54c0ad8e344 Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 15:16:37 +0800 Subject: [PATCH 2/6] default to full name Signed-off-by: Andy Lok --- CHANGELOG.md | 2 +- minitrace-macro/src/lib.rs | 34 +++++++++--------- .../ui/err/has-name-and-full-name.stderr | 7 ---- ...ull-name.rs => has-name-and-short-name.rs} | 2 +- .../ui/err/has-name-and-short-name.stderr | 7 ++++ ...ull-name.rs => has-name-and-short-name.rs} | 2 +- .../{has-full-name.rs => has-short-name.rs} | 2 +- minitrace/tests/lib.rs | 36 +++++++++---------- 8 files changed, 47 insertions(+), 45 deletions(-) delete mode 100644 minitrace-macro/tests/ui/err/has-name-and-full-name.stderr rename minitrace-macro/tests/ui/err/{has-name-and-full-name.rs => has-name-and-short-name.rs} (52%) create mode 100644 minitrace-macro/tests/ui/err/has-name-and-short-name.stderr rename minitrace-macro/tests/ui/ok/{has-name-and-full-name.rs => has-name-and-short-name.rs} (71%) rename minitrace-macro/tests/ui/ok/{has-full-name.rs => has-short-name.rs} (79%) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc95ab50..a64cfad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## v0.6.1 -- Add macro attribute `#[trace(full_name = true)]` to use the full path of the function instead of only the function name. +- Macro will use the full path of the function as span name instead of the only function name. You can turn it off by setting `#[trace(short_name = true)]`. ## v0.6.0 diff --git a/minitrace-macro/src/lib.rs b/minitrace-macro/src/lib.rs index f521325b..371e4347 100644 --- a/minitrace-macro/src/lib.rs +++ b/minitrace-macro/src/lib.rs @@ -24,8 +24,8 @@ struct Args { } enum Name { - Function(String), - FullPath, + Plain(String), + FullName, } impl Args { @@ -36,7 +36,7 @@ impl Args { let mut args = HashSet::new(); let mut func_name = func_name; - let mut full_name = false; + let mut short_name = false; let mut enter_on_poll = false; for arg in &input { @@ -53,9 +53,9 @@ impl Args { path, lit: Lit::Bool(b), .. - })) if path.is_ident("full_name") => { - full_name = b.value; - args.insert("full_name"); + })) if path.is_ident("short_name") => { + short_name = b.value; + args.insert("short_name"); } NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, @@ -69,13 +69,15 @@ impl Args { } } - let name = if full_name { - if args.contains("name") { - abort_call_site!("`name` and `full_name` can not be used together"); + let name = if args.contains("name") { + if short_name { + abort_call_site!("`name` and `short_name` can not be used together"); } - Name::FullPath + Name::Plain(func_name) + } else if short_name { + Name::Plain(func_name) } else { - Name::Function(func_name) + Name::FullName }; if args.len() != input.len() { @@ -99,8 +101,8 @@ impl Args { /// /// ## Arguments /// -/// * `name` - The name of the span. Defaults to the function name. -/// * `full_name` - Whether to use the full path of the function as the span name. Defaults to `false`. +/// * `name` - The name of the span. Defaults to the full path of the function. +/// * `short_name` - Whether to use the function name without path as the span name. Defaults to `false`. /// * `enter_on_poll` - Whether to enter the span on poll, if set to `false`, `in_span` will be used. /// Only available for `async fn`. Defaults to `false`. /// @@ -278,10 +280,10 @@ fn gen_block( fn gen_name(span: proc_macro2::Span, name: Name) -> proc_macro2::TokenStream { match name { - Name::Function(func_name) => quote_spanned!(span=> - #func_name + Name::Plain(name) => quote_spanned!(span=> + #name ), - Name::FullPath => quote_spanned!(span=> + Name::FullName => quote_spanned!(span=> { fn f() {} fn type_name_of(_: T) -> &'static str { diff --git a/minitrace-macro/tests/ui/err/has-name-and-full-name.stderr b/minitrace-macro/tests/ui/err/has-name-and-full-name.stderr deleted file mode 100644 index c29ad4c8..00000000 --- a/minitrace-macro/tests/ui/err/has-name-and-full-name.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error: `name` and `full_name` can not be used together - --> tests/ui/err/has-name-and-full-name.rs:3:1 - | -3 | #[trace(name = "Name", full_name = true)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the attribute macro `trace` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/minitrace-macro/tests/ui/err/has-name-and-full-name.rs b/minitrace-macro/tests/ui/err/has-name-and-short-name.rs similarity index 52% rename from minitrace-macro/tests/ui/err/has-name-and-full-name.rs rename to minitrace-macro/tests/ui/err/has-name-and-short-name.rs index 3290483e..b804371b 100644 --- a/minitrace-macro/tests/ui/err/has-name-and-full-name.rs +++ b/minitrace-macro/tests/ui/err/has-name-and-short-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", full_name = true)] +#[trace(name = "Name", short_name = true)] fn f() {} fn main() {} diff --git a/minitrace-macro/tests/ui/err/has-name-and-short-name.stderr b/minitrace-macro/tests/ui/err/has-name-and-short-name.stderr new file mode 100644 index 00000000..5c1dff5c --- /dev/null +++ b/minitrace-macro/tests/ui/err/has-name-and-short-name.stderr @@ -0,0 +1,7 @@ +error: `name` and `short_name` can not be used together + --> tests/ui/err/has-name-and-short-name.rs:3:1 + | +3 | #[trace(name = "Name", short_name = true)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `trace` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/minitrace-macro/tests/ui/ok/has-name-and-full-name.rs b/minitrace-macro/tests/ui/ok/has-name-and-short-name.rs similarity index 71% rename from minitrace-macro/tests/ui/ok/has-name-and-full-name.rs rename to minitrace-macro/tests/ui/ok/has-name-and-short-name.rs index 01346397..03f1d0c5 100644 --- a/minitrace-macro/tests/ui/ok/has-name-and-full-name.rs +++ b/minitrace-macro/tests/ui/ok/has-name-and-short-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", full_name = false)] +#[trace(name = "Name", short_name = false)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace-macro/tests/ui/ok/has-full-name.rs b/minitrace-macro/tests/ui/ok/has-short-name.rs similarity index 79% rename from minitrace-macro/tests/ui/ok/has-full-name.rs rename to minitrace-macro/tests/ui/ok/has-short-name.rs index c30373e4..67b0378f 100644 --- a/minitrace-macro/tests/ui/ok/has-full-name.rs +++ b/minitrace-macro/tests/ui/ok/has-short-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(full_name = true)] +#[trace(short_name = true)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace/tests/lib.rs b/minitrace/tests/lib.rs index 49143eff..eec0d179 100644 --- a/minitrace/tests/lib.rs +++ b/minitrace/tests/lib.rs @@ -390,7 +390,7 @@ fn test_macro() { } } - #[trace(enter_on_poll = true)] + #[trace(short_name = true, enter_on_poll = true)] async fn work(millis: &u64) { let _g = Span::enter_with_local_parent("work-inner"); tokio::time::sleep(std::time::Duration::from_millis(*millis)) @@ -399,7 +399,7 @@ fn test_macro() { } impl Bar { - #[trace] + #[trace(short_name = true)] async fn work2(&self, millis: &u64) { let _g = Span::enter_with_local_parent("work-inner"); tokio::time::sleep(std::time::Duration::from_millis(*millis)) @@ -408,7 +408,7 @@ fn test_macro() { } } - #[trace] + #[trace(short_name = true)] async fn work3<'a>(millis1: &'a u64, millis2: &u64) { let _g = Span::enter_with_local_parent("work-inner"); tokio::time::sleep(std::time::Duration::from_millis(*millis1)) @@ -476,23 +476,23 @@ root [] #[test] #[serial] fn macro_example() { - #[trace] - fn do_something(i: u64) { + #[trace(short_name = true)] + fn do_something_short_name(i: u64) { std::thread::sleep(std::time::Duration::from_millis(i)); } - #[trace] - async fn do_something_async(i: u64) { + #[trace(short_name = true)] + async fn do_something_async_short_name(i: u64) { futures_timer::Delay::new(std::time::Duration::from_millis(i)).await; } - #[trace(full_name = true)] - fn do_something_full_name(i: u64) { + #[trace] + fn do_something(i: u64) { std::thread::sleep(std::time::Duration::from_millis(i)); } - #[trace(full_name = true)] - async fn do_something_async_full_name(i: u64) { + #[trace] + async fn do_something_async(i: u64) { futures_timer::Delay::new(std::time::Duration::from_millis(i)).await; } @@ -504,18 +504,18 @@ fn macro_example() { let _g = root.set_local_parent(); do_something(100); block_on(do_something_async(100)); - do_something_full_name(100); - block_on(do_something_async_full_name(100)); + do_something_short_name(100); + block_on(do_something_async_short_name(100)); } minitrace::flush(); let expected_graph = r#" root [] - do_something [] - do_something_async [] - lib::macro_example::{{closure}}::do_something_async_full_name [] - lib::macro_example::{{closure}}::do_something_full_name [] + do_something_async_short_name [] + do_something_short_name [] + lib::macro_example::{{closure}}::do_something [] + lib::macro_example::{{closure}}::do_something_async [] "#; assert_eq!( tree_str_from_span_records(collected_spans.lock().clone()), @@ -589,7 +589,7 @@ root [] #[test] #[serial] fn max_spans_per_trace() { - #[trace] + #[trace(short_name = true)] fn recursive(n: usize) { if n > 1 { recursive(n - 1); From de7bd3a93f73681b4ff2a9cd82086a0d53d0ff4d Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 15:52:07 +0800 Subject: [PATCH 3/6] add some useful macros Signed-off-by: Andy Lok --- minitrace-macro/src/lib.rs | 14 ++------ minitrace/src/lib.rs | 1 + minitrace/src/macros.rs | 70 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 minitrace/src/macros.rs diff --git a/minitrace-macro/src/lib.rs b/minitrace-macro/src/lib.rs index 371e4347..30846f4c 100644 --- a/minitrace-macro/src/lib.rs +++ b/minitrace-macro/src/lib.rs @@ -133,7 +133,7 @@ impl Args { /// # use minitrace::prelude::*; /// # use minitrace::local::LocalSpan; /// fn foo() { -/// let __guard__ = LocalSpan::enter_with_local_parent("foo"); +/// let __guard__ = LocalSpan::enter_with_local_parent("example::foo"); /// // ... /// } /// @@ -141,7 +141,7 @@ impl Args { /// async { /// // ... /// } -/// .in_span(Span::enter_with_local_parent("bar")) +/// .in_span(Span::enter_with_local_parent("example::bar")) /// .await /// } /// @@ -284,15 +284,7 @@ fn gen_name(span: proc_macro2::Span, name: Name) -> proc_macro2::TokenStream { #name ), Name::FullName => quote_spanned!(span=> - { - fn f() {} - fn type_name_of(_: T) -> &'static str { - std::any::type_name::() - } - let name = type_name_of(f); - let name = &name[..name.len() - 3]; - name.trim_end_matches("::{{closure}}") - } + minitrace::full_name!() ), } } diff --git a/minitrace/src/lib.rs b/minitrace/src/lib.rs index cb9a51b1..4cf5e3ca 100644 --- a/minitrace/src/lib.rs +++ b/minitrace/src/lib.rs @@ -315,6 +315,7 @@ pub mod collector; mod event; pub mod future; pub mod local; +mod macros; mod span; #[doc(hidden)] pub mod util; diff --git a/minitrace/src/macros.rs b/minitrace/src/macros.rs new file mode 100644 index 00000000..7a2b464c --- /dev/null +++ b/minitrace/src/macros.rs @@ -0,0 +1,70 @@ +// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. + +/// Get the name of the function where the macro is invoked. Returns a `&'static str`. +/// +/// # Example +/// +/// ``` +/// use minitrace::func_name; +/// +/// fn foo() { +/// assert_eq!(func_name!(), "foo"); +/// } +/// # foo() +/// ``` +#[macro_export] +macro_rules! func_name { + () => {{ + fn f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + let name = type_name_of(f); + let name = &name[..name.len() - 3]; + name.rsplit("::") + .find(|name| *name != "{{closure}}") + .unwrap() + }}; +} + +/// Get the full path of the function where the macro is invoked. Returns a `&'static str`. +/// +/// # Example +/// +/// ``` +/// use minitrace::full_name; +/// +/// fn foo() { +/// assert_eq!(full_name!(), "rust_out::main::_doctest_main_minitrace_src_macros_rs_34_0::foo"); +/// } +/// # foo() +#[macro_export] +macro_rules! full_name { + () => {{ + fn f() {} + fn type_name_of(_: T) -> &'static str { + std::any::type_name::() + } + let name = type_name_of(f); + let name = &name[..name.len() - 3]; + name.trim_end_matches("::{{closure}}") + }}; +} + +/// Get the source file location where the macro is invoked. Returns a `&'static str`. +/// +/// # Example +/// +/// ``` +/// use minitrace::file_location; +/// +/// fn foo() { +/// assert_eq!(file_location!(), "minitrace/src/macros.rs:8:15"); +/// } +/// # foo() +#[macro_export] +macro_rules! file_location { + () => { + std::concat!(file!(), ":", line!(), ":", column!()) + }; +} From 0abb76ea004ce0f6503916d45c28cd487523b713 Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 15:55:09 +0800 Subject: [PATCH 4/6] fix Signed-off-by: Andy Lok --- CHANGELOG.md | 1 + minitrace/src/macros.rs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a64cfad3..c6f2f633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## v0.6.1 - Macro will use the full path of the function as span name instead of the only function name. You can turn it off by setting `#[trace(short_name = true)]`. +- Add utility macros `func_name!()`, `full_name!()`, and `file_location!()` to generate names for use in span. ## v0.6.0 diff --git a/minitrace/src/macros.rs b/minitrace/src/macros.rs index 7a2b464c..61ee34f0 100644 --- a/minitrace/src/macros.rs +++ b/minitrace/src/macros.rs @@ -1,16 +1,16 @@ // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. /// Get the name of the function where the macro is invoked. Returns a `&'static str`. -/// +/// /// # Example -/// +/// /// ``` /// use minitrace::func_name; -/// +/// /// fn foo() { /// assert_eq!(func_name!(), "foo"); /// } -/// # foo() +/// # foo() /// ``` #[macro_export] macro_rules! func_name { @@ -28,16 +28,16 @@ macro_rules! func_name { } /// Get the full path of the function where the macro is invoked. Returns a `&'static str`. -/// +/// /// # Example -/// +/// /// ``` /// use minitrace::full_name; -/// +/// /// fn foo() { /// assert_eq!(full_name!(), "rust_out::main::_doctest_main_minitrace_src_macros_rs_34_0::foo"); /// } -/// # foo() +/// # foo() #[macro_export] macro_rules! full_name { () => {{ @@ -52,12 +52,12 @@ macro_rules! full_name { } /// Get the source file location where the macro is invoked. Returns a `&'static str`. -/// +/// /// # Example -/// +/// /// ``` /// use minitrace::file_location; -/// +/// /// fn foo() { /// assert_eq!(file_location!(), "minitrace/src/macros.rs:8:15"); /// } From cda04e83b9c089a42abec8d9b40de02438e07834 Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 15:58:16 +0800 Subject: [PATCH 5/6] fix Signed-off-by: Andy Lok --- minitrace-macro/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minitrace-macro/src/lib.rs b/minitrace-macro/src/lib.rs index 30846f4c..0caace2d 100644 --- a/minitrace-macro/src/lib.rs +++ b/minitrace-macro/src/lib.rs @@ -103,7 +103,7 @@ impl Args { /// /// * `name` - The name of the span. Defaults to the full path of the function. /// * `short_name` - Whether to use the function name without path as the span name. Defaults to `false`. -/// * `enter_on_poll` - Whether to enter the span on poll, if set to `false`, `in_span` will be used. +/// * `enter_on_poll` - Whether to enter the span on poll. If set to `false`, `in_span` will be used. /// Only available for `async fn`. Defaults to `false`. /// /// # Examples From 6cfa5fee9b46ad2b0de3e7cec3c3fd2cbc19c13e Mon Sep 17 00:00:00 2001 From: Andy Lok Date: Fri, 27 Oct 2023 16:11:15 +0800 Subject: [PATCH 6/6] fix Signed-off-by: Andy Lok --- minitrace/src/macros.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/minitrace/src/macros.rs b/minitrace/src/macros.rs index 61ee34f0..37a221e2 100644 --- a/minitrace/src/macros.rs +++ b/minitrace/src/macros.rs @@ -61,6 +61,7 @@ macro_rules! full_name { /// fn foo() { /// assert_eq!(file_location!(), "minitrace/src/macros.rs:8:15"); /// } +/// # #[cfg(not(target_os = "windows"))] /// # foo() #[macro_export] macro_rules! file_location {