Skip to content

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

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
log/tracing-http-debug-logging-82f43ed720691e99
Draft

[log] Add debug logging to tracing/http.go WrapHTTPHandler#3206
github-actions[bot] wants to merge 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 <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 5, 2026
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.

0 participants