Skip to content

[log] Add debug logging to tracing/http.go WrapHTTPHandler#3206

Merged
lpcox merged 1 commit intomainfrom
log/tracing-http-debug-logging-82f43ed720691e99
Apr 5, 2026
Merged

[log] Add debug logging to tracing/http.go WrapHTTPHandler#3206
lpcox merged 1 commit intomainfrom
log/tracing-http-debug-logging-82f43ed720691e99

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 5, 2026

Adds 4 meaningful debug log calls to internal/tracing/http.go using the existing logTracing logger declared in provider.go (same tracing package, no new logger declaration needed).

Changes

File: internal/tracing/http.go

Three categories of debug log calls added to WrapHTTPHandler:

  1. Handler registration — logs when a handler is wired up with its OTel span name and the number of extra attributes:

    Registering HTTP handler with OTel span: span=mcp.tool_call, extraAttrs=2
    ```
    
    
  2. Per-request entry — logs the span name, HTTP method, path, and whether an incoming W3C traceparent header was found (i.e., whether this is a continuation of a distributed trace or a fresh root trace):

    Handling request: span=mcp.tool_call, method=POST, path=/mcp, remoteParent=true
    
  3. Post-span-start — logs the generated or propagated trace ID for cross-system correlation:

    Span started: span=mcp.tool_call, traceID=4bf92f3577b34da6a3ce929d0e0e4736
    

No Side Effects

  • logTracing is already declared in provider.go in the same package — no new logger variable added
  • oteltrace.SpanContextFromContext(ctx).IsRemote() is a pure read with no side effects
  • span.SpanContext().TraceID() is a pure read; formats to hex via %s
  • All logging is gated by DEBUG=tracing:* or DEBUG=* — zero overhead when disabled

Quality Checklist

  • Exactly 1 file modified
  • No test files modified
  • Reuses existing logTracing logger (no duplicate declaration)
  • Logger namespace follows pkg:filename convention (tracing:provider)
  • Log arguments have no side effects
  • Logging messages are meaningful and diagnostic
  • No duplicate logging with existing log calls

Note

🔒 Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

  • search_code:open-telemetry/opentelemetry-go search_code: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Go Logger Enhancement ·

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]>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 5, 2026
@lpcox lpcox marked this pull request as ready for review April 5, 2026 22:06
Copilot AI review requested due to automatic review settings April 5, 2026 22:06
@lpcox lpcox merged commit f18739e into main Apr 5, 2026
4 checks passed
@lpcox lpcox deleted the log/tracing-http-debug-logging-82f43ed720691e99 branch April 5, 2026 22:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants