forked from romanz/electrs
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a579e79
commit b9c80ca
Showing
17 changed files
with
161 additions
and
159 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn trace(_attr: TokenStream, item: TokenStream) -> TokenStream { | ||
#[cfg(feature = "otlp-tracing")] | ||
{ | ||
use quote::quote; | ||
use syn::{parse_macro_input, ItemFn}; | ||
|
||
let additional_fields = if !_attr.is_empty() { | ||
let attr_tokens: proc_macro2::TokenStream = _attr.into(); | ||
quote! {, #attr_tokens } | ||
} else { | ||
quote! {} | ||
}; | ||
|
||
let function = parse_macro_input!(item as ItemFn); | ||
|
||
let fields_tokens = quote! { | ||
fields(module = module_path!(), file = file!(), line = line!() #additional_fields) | ||
}; | ||
|
||
let expanded = quote! { | ||
#[tracing::instrument(skip_all, #fields_tokens)] | ||
#function | ||
}; | ||
|
||
return expanded.into(); | ||
} | ||
|
||
#[cfg(not(feature = "otlp-tracing"))] | ||
{ | ||
item | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.