[log] Add debug logging to tracing/http.go WrapHTTPHandler#3206
Conversation
Add meaningful debug log calls to WrapHTTPHandler using the existing logTracing logger (declared in provider.go, same package): - Log at handler registration time: span name and extra attribute count - Log per-request: span name, HTTP method/path, and whether a W3C remote parent trace context was extracted from incoming headers - Log after span creation: span name and trace ID for correlation These logs are only emitted when DEBUG matches 'tracing:provider' or a wildcard pattern, adding zero overhead in production. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds additional debug-level observability to the tracing HTTP wrapper (tracing.WrapHTTPHandler) to help diagnose handler wiring and trace propagation behavior.
Changes:
- Log handler registration with span name and extra attribute count.
- Log per-request entry with method/path and whether an extracted remote parent is present.
- Log trace ID after starting the server span.
Show a summary per file
| File | Description |
|---|---|
internal/tracing/http.go |
Adds debug logs around handler wrapping, request entry, and span start/trace ID for easier trace-correlation debugging. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| // GitHub API proxy. Callers that need session-level attributes (e.g. session.id) | ||
| // should add them as extra attrs or extend the context themselves. | ||
| func WrapHTTPHandler(next http.Handler, spanName string, extraAttrs ...attribute.KeyValue) http.Handler { | ||
| logTracing.Printf("Registering HTTP handler with OTel span: span=%s, extraAttrs=%d", spanName, len(extraAttrs)) |
There was a problem hiding this comment.
These new logs in http.go use logTracing which is namespaced as tracing:provider, so enabling/disabling debug output becomes misleading and you can’t selectively turn on tracing:http without also turning on provider logs. Elsewhere in the repo loggers are per-file/module (e.g. proxy:handler in internal/proxy/handler.go:24, proxy:graphql in internal/proxy/graphql.go:11); consider defining a tracing:http logger in this file and using it for request/handler logs.
Adds 4 meaningful debug log calls to
internal/tracing/http.gousing the existinglogTracinglogger declared inprovider.go(sametracingpackage, no new logger declaration needed).Changes
File:
internal/tracing/http.goThree categories of debug log calls added to
WrapHTTPHandler:Handler registration — logs when a handler is wired up with its OTel span name and the number of extra attributes:
Per-request entry — logs the span name, HTTP method, path, and whether an incoming W3C
traceparentheader was found (i.e., whether this is a continuation of a distributed trace or a fresh root trace):Post-span-start — logs the generated or propagated trace ID for cross-system correlation:
No Side Effects
logTracingis already declared inprovider.goin the same package — no new logger variable addedoteltrace.SpanContextFromContext(ctx).IsRemote()is a pure read with no side effectsspan.SpanContext().TraceID()is a pure read; formats to hex via%sDEBUG=tracing:*orDEBUG=*— zero overhead when disabledQuality Checklist
logTracinglogger (no duplicate declaration)pkg:filenameconvention (tracing:provider)Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
search_code: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".To allow these resources, lower
min-integrityin your GitHub frontmatter: