formatter: add SPAN_ID access log formatter#43997
Open
bittoby wants to merge 1 commit intoenvoyproxy:mainfrom
Open
formatter: add SPAN_ID access log formatter#43997bittoby wants to merge 1 commit intoenvoyproxy:mainfrom
bittoby wants to merge 1 commit intoenvoyproxy:mainfrom
Conversation
|
Hi @bittoby, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
Signed-off-by: bittoby <218712309+bittoby@users.noreply.github.com>
a916459 to
c3466dc
Compare
Author
|
@agrawroh @basvanbeek Could you please review this PR? Welcome to any feedbacks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message: formatter: add SPAN_ID access log formatter
Additional Description:
Adds a
%SPAN_ID%access log command operator that returns the span ID of the active(downstream) span for a request. This complements the existing
%TRACE_ID%formatterand enables users to correlate access log entries with specific spans in their distributed
tracing backend.
The implementation mirrors
TraceIDFormatterexactly - it callsgetSpanId()on theactive span from the formatter context. The
getSpanId()method already exists on theTracing::Spaninterface and is implemented by several tracing providers (OpenTelemetry,Fluentd). Providers that have not yet implemented it (Zipkin, Datadog, SkyWalking, X-Ray)
return an empty string, which the formatter handles gracefully by outputting
"-".The original issue also suggested separate
%CLIENT_SPAN_ID%/%SERVER_SPAN_ID%formatters. However, only the downstream (server) span is accessible in the access log
formatter context - the upstream (client) span lives inside the router and is not plumbed
to the log context. A single
%SPAN_ID%is the correct approach given the currentarchitecture. Exposing the upstream span would require deeper changes and can be tracked
separately if needed.
Risk Level: Low
Testing: Added unit tests covering all three code paths: valid span ID present, no active
span set, and span present but returning empty ID (providers that don't implement it yet).
Docs Changes: Added
%SPAN_ID%documentation todocs/root/configuration/advanced/substitution_formatter.rst, placed directly after theexisting
%TRACE_ID%entry.Release Notes: Added entry to
changelogs/current.yamlunder theformatterarea.Platform Specific Features: N/A
Fixes #43674