-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for recording dynamic fields #1343
Comments
Running into a similar problem of trying to get various fields to always show up at the top of a json log entry (I think pretty similar to OT's baggage concept?). There does not seem to be a good way to do this with either the subscriber or layer apis to do this. Probably going to fork the json formatter. |
This would indeed be nice to have! I'm not sure of a way of adding this in a performant way currently. Perhaps others have put some though into this one already? |
The naive approach in my mind is more or less along these lines:
E.g. in I'd be happy to build a prototype of what this might look like in a PR - if we agree it's something desirable/it goes in the direction the maintainers envision for |
I have the exact same usecase as @LukeMathWalker. I want to add fields to the trace created by my gRPC server tracing and they are not known beforehand. Since this feature request is pretty old, are there any new workarounds for this? |
I've also hit this issue, and came up with something that seems to work for spans and events: https://crates.io/crates/tracing_dynamic |
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.
The text was updated successfully, but these errors were encountered: