diff --git a/CHANGELOG.md b/CHANGELOG.md index bba1b734..fb62a2d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ## v0.6.1 -- Add macro attribute `#[trace(full_path = true)]` to use the full path of the function instead of only the function name. +- Add macro attribute `#[trace(path_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 5018b870..67c1bbef 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 full_path = false; + let mut path_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_path") => { - full_path = b.value; - args.insert("full_path"); + })) if path.is_ident("path_name") => { + path_name = b.value; + args.insert("path_name"); } NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, @@ -69,9 +69,9 @@ impl Args { } } - let name = if full_path { + let name = if path_name { if args.contains("name") { - abort_call_site!("`name` and `full_path` can not be used together"); + abort_call_site!("`name` and `path_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. -/// * `full_path` - Whether to use the full path of the function as the span name. Defaults to `false`. +/// * `path_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-full-path.rs b/minitrace-macro/tests/ui/err/has-name-and-path-name.rs similarity index 52% rename from minitrace-macro/tests/ui/err/has-name-and-full-path.rs rename to minitrace-macro/tests/ui/err/has-name-and-path-name.rs index f41c931f..50edfe36 100644 --- a/minitrace-macro/tests/ui/err/has-name-and-full-path.rs +++ b/minitrace-macro/tests/ui/err/has-name-and-path-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", full_path = true)] +#[trace(name = "Name", path_name = true)] fn f() {} fn main() {} diff --git a/minitrace-macro/tests/ui/err/has-name-and-full-path.stderr b/minitrace-macro/tests/ui/err/has-name-and-path-name.stderr similarity index 69% rename from minitrace-macro/tests/ui/err/has-name-and-full-path.stderr rename to minitrace-macro/tests/ui/err/has-name-and-path-name.stderr index 24babe1e..8af796b1 100644 --- a/minitrace-macro/tests/ui/err/has-name-and-full-path.stderr +++ b/minitrace-macro/tests/ui/err/has-name-and-path-name.stderr @@ -1,7 +1,7 @@ -error: `name` and `full_path` can not be used together +error: `name` and `path_name` can not be used together --> tests/ui/err/has-name-and-full-path.rs:3:1 | -3 | #[trace(name = "Name", full_path = true)] +3 | #[trace(name = "Name", path_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-path.rs b/minitrace-macro/tests/ui/ok/has-name-and-path-name.rs similarity index 72% rename from minitrace-macro/tests/ui/ok/has-name-and-full-path.rs rename to minitrace-macro/tests/ui/ok/has-name-and-path-name.rs index 38bbd8db..7c17d5ac 100644 --- a/minitrace-macro/tests/ui/ok/has-name-and-full-path.rs +++ b/minitrace-macro/tests/ui/ok/has-name-and-path-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(name = "Name", full_path = false)] +#[trace(name = "Name", path_name = false)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace-macro/tests/ui/ok/has-full-path.rs b/minitrace-macro/tests/ui/ok/has-path-name.rs similarity index 80% rename from minitrace-macro/tests/ui/ok/has-full-path.rs rename to minitrace-macro/tests/ui/ok/has-path-name.rs index 90fb1337..61bf908e 100644 --- a/minitrace-macro/tests/ui/ok/has-full-path.rs +++ b/minitrace-macro/tests/ui/ok/has-path-name.rs @@ -1,6 +1,6 @@ use minitrace::trace; -#[trace(full_path = true)] +#[trace(path_name = true)] async fn f(a: u32) -> u32 { a } diff --git a/minitrace/tests/lib.rs b/minitrace/tests/lib.rs index 3636059c..77844bf7 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(full_path = true)] - fn do_something_full_path(i: u64) { + #[trace(path_name = true)] + fn do_something_path_name(i: u64) { std::thread::sleep(std::time::Duration::from_millis(i)); } - #[trace(full_path = true)] - async fn do_something_async_full_path(i: u64) { + #[trace(path_name = true)] + async fn do_something_async_path_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_full_path(100); - block_on(do_something_async_full_path(100)); + do_something_path_name(100); + block_on(do_something_async_path_name(100)); } minitrace::flush(); @@ -514,8 +514,8 @@ fn macro_example() { root [] do_something [] do_something_async [] - lib::macro_example::{{closure}}::do_something_async_full_path [] - lib::macro_example::{{closure}}::do_something_full_path [] + lib::macro_example::{{closure}}::do_something_async_path_name [] + lib::macro_example::{{closure}}::do_something_path_name [] "#; assert_eq!( tree_str_from_span_records(collected_spans.lock().clone()),