How to display the span id in a log message? #2483
-
It would be very helpful if the span id can be displayed on a log message that's generated by an event in a span that's created by an instrument macro. But I cannot find how to do it. Without it, I must add an artificial id for the instrument macro instance, for example, #[instrument(skip_all, fields(id = %Uuid::new_v4()), err)]
async fn a_function() {} It would be nice if I can do like this: #[instrument(skip_all, span_id, err)]
async fn a_function() {} Or, it would be nice if Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
What you're writing isn't really an artificial ID—it's an ID that makes sense for your application or library. |
Beta Was this translation helpful? Give feedback.
-
2023-02-23 19:41 غرينتش+02:00, David Barsky ***@***.***>:
…> Without it, I must add an artificial id for the instrument macro
> instance.
What you're writing isn't really an artificial ID—it's an ID that makes
sense for your application or library. `tracing`'s span IDs are generally
meant to be opaque identifiers that are unique within a process for
currently open spans. They are _not_ meant to be globally unique identifiers
like UUIDs. If you'd like to read more, take a look at [this
documentation](https://docs.rs/tracing/latest/tracing/trait.Subscriber.html#tymethod.new_span).
--
Reply to this email directly or view it on GitHub:
#2483 (comment)
You are receiving this because you are subscribed to this thread.
Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
What you're writing isn't really an artificial ID—it's an ID that makes sense for your application or library.
tracing
's span IDs are generally meant to be opaque identifiers that are unique within a process for currently open spans. They are not meant to be globally unique identifiers like UUIDs. If you'd like to read more, take a look at this documentation.