From c43b2d482bd1b1289a66248edb0ec23b5083d906 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 9 Oct 2024 20:32:39 -0400 Subject: [PATCH] http.vars.trace_id placeholder --- src/docs/markdown/caddyfile/directives/tracing.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/docs/markdown/caddyfile/directives/tracing.md b/src/docs/markdown/caddyfile/directives/tracing.md index 881f279..95cfb7e 100644 --- a/src/docs/markdown/caddyfile/directives/tracing.md +++ b/src/docs/markdown/caddyfile/directives/tracing.md @@ -10,7 +10,9 @@ When enabled, it will propagate an existing trace context or initialize a new on It uses [gRPC](https://github.com/grpc/) as an exporter protocol and W3C [tracecontext](https://www.w3.org/TR/trace-context/) and [baggage](https://www.w3.org/TR/baggage/) as propagators. -The trace ID is added to [access logs](/docs/caddyfile/directives/log) as the standard `traceID` field. +The trace ID is added to [access logs](/docs/caddyfile/directives/log) as the standard `traceID` field. Additionally, the `{http.vars.trace_id}` placeholder is made available, for example to add the ID to a (`request_header`)[request_header] to pass it to your app. + + ## Syntax @@ -24,6 +26,8 @@ tracing { [Placeholders](/docs/caddyfile/concepts#placeholders) may be used in span names; keep in mind that tracing happens as early as possible, so only request placeholders may be used, and not response placeholders. + + ## Configuration ### Environment variables @@ -41,6 +45,8 @@ export OTEL_EXPORTER_OTLP_HEADERS="myAuthHeader=myToken,anotherHeader=value" export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://my-otlp-endpoint:55680 ``` + + ## Examples Here is a **Caddyfile** example: @@ -51,6 +57,7 @@ example.com { tracing { span api } + request_header X-Trace-Id {http.vars.trace_id} reverse_proxy localhost:8081 }