This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
observability: tracing gum, automatically cross ref traceID #5079
Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
720355a
add some gum
drahnr f7ee9ae
bump expander
drahnr 6657f6e
gum
drahnr 2384b07
fix all remaining issues
drahnr 2363b91
last fixup
drahnr 9bb0441
Update node/gum/proc-macro/src/lib.rs
drahnr df3f753
change
drahnr 9b580ab
netowrk
drahnr a450ca0
fixins
drahnr 3cb1254
chore
drahnr 6ea8178
allow optional fmt str + args, prep for expr as kv field
drahnr ec437c2
tracing -> gum rename fallout
drahnr 0130947
restrict further
drahnr 397a680
allow multiple levels of field accesses
drahnr 81937b3
another round of docs and a slip of the pen
drahnr 68e045f
update ADR
drahnr cdab19e
fixup lock fiel
drahnr 0cb6386
use target: instead of target=
drahnr a6f5bbd
minors
drahnr 8edf4eb
fix
drahnr f626141
chore
drahnr 638d63b
Merge remote-tracking branch 'origin/master' into bernhard-tracing-gum
drahnr 42c7365
Update node/gum/README.md
drahnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
another round of docs and a slip of the pen
- Loading branch information
commit 81937b37bf4195ee0a4e9fb1de171212e9bbbae1
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ | |
| // along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| #![deny(unused_crate_dependencies)] | ||
| #![deny(missing_docs)] | ||
| #![deny(clippy::dbg_macro)] | ||
|
|
||
| //! Generative part of `tracing-gum`. See `tracing-gum` for usage documentation. | ||
|
|
||
| use proc_macro2::{Ident, Span, TokenStream}; | ||
| use quote::{quote, ToTokens}; | ||
|
|
@@ -27,31 +31,37 @@ use self::types::*; | |
| #[cfg(test)] | ||
| mod tests; | ||
|
|
||
| /// Print an error message. | ||
| #[proc_macro] | ||
| pub fn error(item: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| gum(item, Level::Error) | ||
| } | ||
|
|
||
| /// Print a warning level message. | ||
| #[proc_macro] | ||
| pub fn warn(item: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| gum(item, Level::Warn) | ||
| } | ||
|
|
||
| /// Print a info level message. | ||
| #[proc_macro] | ||
| pub fn info(item: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| gum(item, Level::Info) | ||
| } | ||
|
|
||
| /// Print a debug level message. | ||
| #[proc_macro] | ||
| pub fn debug(item: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| gum(item, Level::Debug) | ||
| } | ||
|
|
||
| /// Print a trace level message. | ||
| #[proc_macro] | ||
| pub fn trace(item: proc_macro::TokenStream) -> proc_macro::TokenStream { | ||
| gum(item, Level::Trace) | ||
| } | ||
|
|
||
| /// One-size-fits all internal implementation that produces the actual code. | ||
| pub(crate) fn gum(item: proc_macro::TokenStream, level: Level) -> proc_macro::TokenStream { | ||
| let item: TokenStream = item.into(); | ||
|
|
||
|
|
@@ -66,6 +76,9 @@ pub(crate) fn gum(item: proc_macro::TokenStream, level: Level) -> proc_macro::To | |
| res.unwrap_or_else(|err| err.to_compile_error()).into() | ||
| } | ||
|
|
||
| /// Does the actual parsing and token generation based on `proc_macro2` types. | ||
| /// | ||
| /// Required for unit tests. | ||
| pub(crate) fn impl_gum2(orig: TokenStream, level: Level) -> Result<TokenStream> { | ||
| let args: Args = parse2(orig)?; | ||
|
|
||
|
|
@@ -75,9 +88,7 @@ pub(crate) fn impl_gum2(orig: TokenStream, level: Level) -> Result<TokenStream> | |
| let Args { target, comma, mut values, fmt } = args; | ||
|
|
||
| // find a value or alias called `candidate_hash`. | ||
| let maybe_candidate_hash = values.iter_mut().find(|value| { | ||
| value.as_ident() == "candidate_hash" | ||
| }); | ||
| let maybe_candidate_hash = values.iter_mut().find(|value| value.as_ident() == "candidate_hash"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a followup PR: Is it possible to remove the hardcoding here to derive the trace_id from something specified by the user ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically yes, but that would add additional syntax. Open to discuss something along the lines of |
||
|
|
||
| if let Some(kv) = maybe_candidate_hash { | ||
| let (ident, rhs_expr, replace_with) = match kv { | ||
|
|
@@ -141,6 +152,7 @@ pub(crate) fn impl_gum2(orig: TokenStream, level: Level) -> Result<TokenStream> | |
| } | ||
| } | ||
|
|
||
| /// Extract the support crate path. | ||
| fn support_crate() -> TokenStream { | ||
| let support_crate_name = if cfg!(test) { | ||
| quote! {crate} | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.