mirror of
https://github.com/caddyserver/caddy.git
synced 2025-07-02 17:31:33 +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:
@ -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))
|
||||
|
Reference in New Issue
Block a user