Skip to content

Add native tracing fields to LogEvent to eliminate async MDC overhead#4171

Open
ramanathan1504 wants to merge 9 commits into
2.xfrom
fix-trace-metadata-1976
Open

Add native tracing fields to LogEvent to eliminate async MDC overhead#4171
ramanathan1504 wants to merge 9 commits into
2.xfrom
fix-trace-metadata-1976

Conversation

@ramanathan1504

Copy link
Copy Markdown
Contributor

Fixes #1976 by introducing a TraceContextProvider SPI and adding
native W3C tracing fields (traceId, spanId, traceFlags) directly to LogEvent.

This allows frameworks like OpenTelemetry to bypass the ThreadContext map
entirely, eliminating the map-cloning memory overhead previously
required during asynchronous logging.

@rgoers rgoers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason not to do this. The implemenation looks pretty simple and clean. However, I don't see an integration with JsonTemplateLayout. Is one needed? Without that how would the data get injected into ElasticSearch?

@ramanathan1504

Copy link
Copy Markdown
Contributor Author

Hi @rgoers, that is a great point. I hadn't included the JsonTemplateLayout integration yet, but it is definitely needed to support structured logging properly.

Should I push the native JTL resolvers as new commits to this PR, or would you prefer I open a separate PR since this one is already approved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Log events should have trace/span-related metadata

2 participants