mirror of
https://github.com/caddyserver/caddy.git
synced 2025-04-19 18:58:50 +08:00
tracing: add http.vars.span_id
placeholder when tracing is enabled
Signed-off-by: YifanYang6 <yifanyang6@link.cuhk.edu.cn>
This commit is contained in:
parent
926e36959e
commit
9ff96824d3
@ -91,6 +91,8 @@ func (ot *openTelemetryWrapper) serveHTTP(w http.ResponseWriter, r *http.Request
|
||||
spanID := spanCtx.SpanID().String()
|
||||
// Add a trace_id placeholder, accessible via `{http.vars.trace_id}`.
|
||||
caddyhttp.SetVar(ctx, "trace_id", traceID)
|
||||
// Add a span_id placeholder, accessible via `{http.vars.span_id}`.
|
||||
caddyhttp.SetVar(ctx, "span_id", spanID)
|
||||
// Add the traceID and spanID to the log fields for the request.
|
||||
if extra, ok := ctx.Value(caddyhttp.ExtraLogFieldsCtxKey).(*caddyhttp.ExtraLogFields); ok {
|
||||
extra.Add(zap.String("traceID", traceID))
|
||||
|
Loading…
x
Reference in New Issue
Block a user