Skip to content

Add trace_flags.sampled context data entry to Log4j Core provider #13774

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

Closed
ppkarwasz opened this issue Apr 25, 2025 · 5 comments
Closed

Add trace_flags.sampled context data entry to Log4j Core provider #13774

ppkarwasz opened this issue Apr 25, 2025 · 5 comments
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@ppkarwasz
Copy link

Is your feature request related to a problem? Please describe.

Some structured log formats like the format accepted by FluentD stackdriver do not accept the W3C trace-flags field, but expect each flag to be stored separately.

Describe the solution you'd like

It would be useful to add an option to opentelemetry-log4j-context-data-2.17-autoconfigure to export each trace flag separately to the Log4j Core context data.

Since currently there is only one flag defined, the custom context data provider could export an entry with name trace_flags.sampled and boolean value.

Describe alternatives you've considered

Currently it is still rather easy to emulate the behavior of the trace_flags.sampled entry described above by replacing returning true if trace_flags is 01 and false if trace_flags is 00. This workaround, however, will no longer work if the W3C defines additional trace flags.

Additional context

No response

@ppkarwasz ppkarwasz added enhancement New feature or request needs triage New issue that requires triage labels Apr 25, 2025
@ppkarwasz
Copy link
Author

I can of course provide a PR if the proposed solution is accepted.

@trask
Copy link
Member

trask commented Apr 25, 2025

this format is part of the specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/logging_trace_context.md#overview

it might be better to add support for this in fluentd instead of adding this to all opentelemetry logging instrumentation across all languages

@ppkarwasz
Copy link
Author

this format is part of the specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/logging_trace_context.md#overview

Thanks for the explanation. In such a case I believe I can close this feature request.

@trask, to fully profit from the trace flags, it would be useful to have a custom Log4j Core filter to increase the logging verbosity, whenever sampled is set to true. Is this something you would be willing to accept in opentelemetry-log4j-context-data-2.17-autoconfigure?

@trask
Copy link
Member

trask commented Apr 29, 2025

Is this something you would be willing to accept in opentelemetry-log4j-context-data-2.17-autoconfigure?

I'm not sure I fully understand the proposal, could you open a new issue and outline?

@ppkarwasz
Copy link
Author

Done: #13804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

2 participants