Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Lok <[email protected]>
  • Loading branch information
andylokandy committed Jan 24, 2024
1 parent a0fa176 commit 6462d93
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions minitrace-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,12 @@ fn gen_properties(span: proc_macro2::Span, args: &Args) -> proc_macro2::TokenStr
fn unescape_format_string(s: &str) -> (String, bool) {
let unescaped_delete = s.replace("{{", "").replace("}}", "");
let contains_valid_format_string =
unescaped_delete.contains("{") || unescaped_delete.contains("}");
unescaped_delete.contains('{') || unescaped_delete.contains('}');
if contains_valid_format_string {
return (s.to_string(), true);
(s.to_string(), true)
} else {
let unescaped_replace = s.replace("{{", "{").replace("}}", "}");
return (unescaped_replace, false);
(unescaped_replace, false)
}
}

Expand Down
2 changes: 1 addition & 1 deletion minitrace/src/local/span_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl SpanQueue {

let span = &mut self.span_queue[span_handle.index];
span.properties
.extend(properties.into_iter().map(|(k, v)| (k.into(), v.into())));
.extend(properties.into_iter().map(|(k, v)| (k, v)));
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion minitrace/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl SpanInner {
{
self.raw_span
.properties
.extend(properties().into_iter().map(|(k, v)| (k.into(), v.into())));
.extend(properties().into_iter().map(|(k, v)| (k, v)));
}

#[inline]
Expand Down
2 changes: 2 additions & 0 deletions minitrace/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,13 @@ fn test_elapsed() {
#[test]
#[serial]
fn test_macro_properties() {
#[allow(clippy::drop_non_drop)]
#[trace(short_name = true, properties = { "k1": "v1", "a": "argument a is {a:?}", "b": "{b:?}", "escaped1": "{c:?}{{}}", "escaped2": "{{ \"a\": \"b\"}}" })]
fn foo(a: i64, b: &Bar, c: Bar) {
drop(c);
}

#[allow(clippy::drop_non_drop)]
#[trace(short_name = true, properties = { "k1": "v1", "a": "argument a is {a:?}", "b": "{b:?}", "escaped1": "{c:?}{{}}", "escaped2": "{{ \"a\": \"b\"}}" })]
async fn foo_async(a: i64, b: &Bar, c: Bar) {
drop(c);
Expand Down

0 comments on commit 6462d93

Please sign in to comment.