-
Notifications
You must be signed in to change notification settings - Fork 846
Description
Feature Request
Crates
tracing
Motivation
Currently all macros (e.g. tracing::info!) require upfront declaration of the fields you want to capture. They are populated either when the span is created or using .record afterwards.
This makes composition quite challenging - e.g. in tracing-actix-web we'd like to allow the library user to add custom fields to the request root span on top of the default ones (see LukeMathWalker/tracing-actix-web#13 for example) but it's unclear if this is even possible without exposing a macro to users.
The other scenario where I longed for this feature is using the Baggage API from OpenTelemetry: it would be ideal to get the baggage out of an incoming request and then add the retrieved field to the request root span. (cc @jtescher @tl-alex-chilcott)
Proposal
Add a way to specify dynamic fields, documenting explicitly the performance tradeoff compared to the current optimized solution.
Previous art
I tried to scan the issue tracker for previous discussions on the topic but I haven't found much - I suspect I wasn't looking for the right terms. Happy to read old issues to understand if we can move blockers you previously identified.