Skip to content
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

Prevent duplicate "message" fields #3195

Open
cloneable opened this issue Jan 15, 2025 · 1 comment
Open

Prevent duplicate "message" fields #3195

cloneable opened this issue Jan 15, 2025 · 1 comment

Comments

@cloneable
Copy link

Bug Report

Description

The opentelemetry-rust people have started using tracing to log their internal errors, but decided to wrap tracing macro calls inside custom macros.

https://github.com/open-telemetry/opentelemetry-rust/blob/f46bccceab3a019fe4c2a46473dbef2c0d217702/opentelemetry/src/global/internal_logging.rs#L71-L78

Unfortunately, they also decided to set the "message" fields explicitly while their macros add an empty implicit "message" field.

https://github.com/open-telemetry/opentelemetry-rust/blob/f46bccceab3a019fe4c2a46473dbef2c0d217702/opentelemetry-sdk/src/trace/span_processor.rs#L381-L382

This tripped our custom subscriber. While we're fixing it and making it more robust, is there anything that can be done on tracing side to prevent duplicate "message" fields? Are FieldSets even meant to have only unique fields?

@cloneable
Copy link
Author

cloneable commented Jan 16, 2025

Then again, if duplicate fields are allowed this would break the JSON logger.

tracing::info!(a = 1, a = 2, message = "bb", "aa");

Output of tracing_subscriber::fmt's JSON:

{"timestamp":"2025-01-16T10:05:22.290921Z","level":"INFO","fields":{"message":"aa","a":1,"a":2,"message":"bb"},"target":"tests"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant