apis: support TRACE_ID and SPAN_ID access log operators - #7635
Conversation
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
|
Could a maintainer please apply the |
|
The Contour project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to the #contour channel in the Kubernetes Slack |
There was a problem hiding this comment.
@AkashKumar7902 Thank you for contributing!
Could you add small mention in the docs as well, e.g. this:
diff --git a/site/content/docs/main/config/access-logging.md b/site/content/docs/main/config/access-logging.md
index d3731a78f..bb1f5de64 100644
--- a/site/content/docs/main/config/access-logging.md
+++ b/site/content/docs/main/config/access-logging.md
@@ -151,6 +151,18 @@ json-fields:
**Note:** The fingerprint values will be empty (`-`) for non-TLS connections or if the corresponding fingerprinting feature is not enabled.
+### Logging Trace and Span IDs
+
+When [tracing](tracing.md) is enabled, trace and span identifiers can be included in access logs.
+
+For text-based access logging, the following command operators can be used:
+- `%TRACE_ID%` - Trace identifier of the request
+- `%SPAN_ID%` - Span identifier of Envoy's span
+
+For JSON access logging, the following built-in fields can be added:
+- `trace_id`
+- `span_id`
+
## Using Access Log Formatter Extensions
Envoy allows implementing custom access log command operators as extensions.
diff --git a/site/content/docs/main/config/tracing.md b/site/content/docs/main/config/tracing.md
index fb8c19762..c3841c9f7 100644
--- a/site/content/docs/main/config/tracing.md
+++ b/site/content/docs/main/config/tracing.md
@@ -120,5 +120,7 @@ kubectl logs deploy/simplest-collector -n projectcontour
Now you should be able to see traces in the logs of the otel collector.
+Trace and span identifiers can also be included in [access logs](access-logging.md#logging-trace-and-span-ids) to correlate log entries with traces.
+
[1]: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing
[2]: https://opentelemetry.io/Signed-off-by: Tero Saarni <tero.saarni@est.tech>
tsaarni
left a comment
There was a problem hiding this comment.
@AkashKumar7902 Thank you for contributing! I pushed the documentation updates directly to your branch.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7635 +/- ##
==========================================
+ Coverage 82.38% 84.06% +1.68%
==========================================
Files 130 131 +1
Lines 15873 14190 -1683
==========================================
- Hits 13077 11929 -1148
+ Misses 2510 2261 -249
+ Partials 286 0 -286 🚀 New features to boost your workflow:
|
Fixes #7550
What this PR does
TRACE_IDandSPAN_IDoperators to Contour's simple access-log operator allowlisttrace_idandspan_idJSON short formsWhy
Contour currently rejects these operators during access-log validation even though the shipped Envoy 1.38 release supports both. The operators were missing from Contour's known simple-operator list.
Impact
Users can opt in to logging active trace and span identifiers and correlate Envoy access-log entries with their distributed tracing backend.
Testing
./apis/projectcontour/v1alpha1and./internal/envoy/v3go vetwith the project's build tagsmake lint-codespellandmake lint-flagsgofumpton the changed Go files andgit diff --checkRelease note
Requested label:
release-note/small. The corresponding numbered changelog is included.