Skip to content

fix(observability): OTel semantic attrs on access log + status on root span#240

Open
igoramf wants to merge 3 commits into
mainfrom
fix/root-span-status-and-otel-access-log
Open

fix(observability): OTel semantic attrs on access log + status on root span#240
igoramf wants to merge 3 commits into
mainfrom
fix/root-span-status-and-otel-access-log

Conversation

@igoramf

@igoramf igoramf commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • logRequest() was emitting legacy attribute names (method, path, status, duration_ms). Now uses OTel semantic convention names (http.request.method, url.path, http.response.status_code) so tail-worker and direct-POST logs share the same attribute keys — no aliasing needed in dashboards
  • deco.http.request root span never received http.status_code, leaving it permanently Unset even for 5xx responses. Now stamps the status after the handler returns, triggering the setAttribute promotion in otelHttpTracer so 5xx spans surface as StatusCode=Error in ClickHouse

Test plan

  • After deploy, query ClickHouse otel_logsrequest handled logs should have http.request.method, url.path, http.response.status_code instead of method, path, status
  • Query otel_traces for deco.http.request spans with SpanAttributes['http.status_code'] = '500' — should now return results with StatusCode=Error

🤖 Generated with Claude Code


Summary by cubic

Standardized access logs to OpenTelemetry semantic keys and removed duration_ms, and the root deco.http.request span now records http.status_code. Uses @opentelemetry/semantic-conventions constants.

  • Bug Fixes
    • Access logs now emit http.request.method, url.path, http.response.status_code (replaces method, path, status). Dropped duration_ms.
    • Root span sets http.status_code after the handler returns, so 5xx spans surface as StatusCode=Error.

Written for commit 9473ccf. Summary will update on new commits.

Review in cubic

…t span

Two instrumentation gaps closed:

1. logRequest() was emitting legacy attribute names (method, path, status,
   duration_ms). Switch to OTel semantic convention names so tail-worker
   and direct-POST logs share the same attribute keys and dashboards can
   query either source without aliasing.

2. deco.http.request root span never received http.status_code, leaving it
   permanently Unset even for 5xx responses. Stamp it after the handler
   returns so the setAttribute promotion in otelHttpTracer triggers and
   5xx spans surface as StatusCode=Error in ClickHouse.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@igoramf igoramf requested a review from a team June 16, 2026 21:03
igoramf and others added 2 commits June 18, 2026 21:12
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Duration belongs on the span (startTime/endTime), not the log.
The tail worker already exposes cloudflare.worker.wall_time_ms for
the same purpose — having duration_ms in the direct-POST log creates
a second inconsistent attribute measuring a slightly different thing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant