Skip to content

egress: record url.full on /ws spans so SigNoz URL search finds them - #460

Merged
AGMETEOR merged 1 commit into
mainfrom
allan/ws-span-url-full
Oct 10, 2026
Merged

AGMETEOR merged 1 commit into
mainfrom
allan/ws-span-url-full

Conversation

@AGMETEOR

@AGMETEOR AGMETEOR commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

context

  • part of https://github.com/getlantern/engineering/issues/3702, which reported that the egress is invisible to SigNoz's URL-based trace search: nothing for unbounded.iantem.io system-wide
  • the spans were there all along. In the last 48h, 289 sampled /ws spans returned 101 and 180 returned 426, all with server.address = unbounded.iantem.io. The search just can't see them:
    • SigNoz derives http_url, the field its URL search filters on, only from url.full or http.url (docs)
    • otelhttp follows the HTTP server conventions and records the URL in parts (server.address, url.scheme, url.path), never url.full, so http_url is empty on every /ws span
    • http_host doesn't help either: on these spans SigNoz fills it from client.address, the donor's IP

summary

  • withURLFull wraps the /ws handler inside the otelhttp span and sets url.full (urlfull.go)
  • scheme from X-Forwarded-Proto, since Caddy terminates TLS and proxies to the egress over plain HTTP so r.TLS is always nil. Only http/https are accepted from the header; otherwise http
  • host is the request's Host, the same value otelhttp already records as server.address
  • the query string is dropped so nothing beyond the route reaches telemetry
  • applies to every /ws request, refused ones included, so a search shows both upgrades (101) and refusals

url.full is a client-span attribute in the OTel HTTP conventions, so this is slightly off-convention for a server span. It's additive and harmless, and it's what makes SigNoz's URL search work.

tests

  • TestWithURLFull_RecordsURLOnServerSpan: behind Caddy (https), no proxy header (http), an unexpected proto is ignored, and the query string is dropped
  • go test -race ./egress/... passes

after deploy

  • httpUrl CONTAINS 'unbounded.iantem.io' should return new /ws spans. Older spans stay unsearchable by URL; server.address = 'unbounded.iantem.io' covers them
  • confirm the scheme reads https, i.e. Caddy sets X-Forwarded-Proto as expected

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Request tracing now records the request’s scheme, host, and path in the span’s URL details. The scheme reflects HTTPS connections and recognized X-Forwarded-Proto values; query strings are not included. This applies to requests handled by the /ws route.

otelhttp records a server request's URL in parts (server.address,
url.scheme, url.path), and SigNoz derives its http_url search field only
from url.full or http.url. A search for the egress's URL therefore
matched nothing, even though every /ws span carries the host.

Wrap the /ws handler to set url.full, taking the scheme from
X-Forwarded-Proto (only http or https) because Caddy proxies to the
egress over plain HTTP, and dropping the query string.

Part of getlantern/engineering#3702.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 09:23
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e37a8cdf-681a-421e-8a23-e7b44bb4ae99

📥 Commits

Reviewing files that changed from the base of the PR and between 742e3c9 and 3ccf9e6.


📒 Files selected for processing (3)
  • egress/egresslib.go
  • egress/urlfull.go
  • egress/urlfull_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The /ws route now records a reconstructed request URL in the current OpenTelemetry span. The new middleware derives the scheme from TLS and accepted X-Forwarded-Proto values. Tests check recorded URLs for several request cases.

Changes

URL span attribute

Layer / File(s) Summary
Reconstruct and record request URLs
egress/urlfull.go
Adds middleware that records the request host and path on the current span. The scheme defaults to http, uses https for TLS, and accepts X-Forwarded-Proto only when its value is exactly http or https. The query string is omitted.
Apply middleware to the WebSocket route
egress/egresslib.go, egress/urlfull_test.go
Wraps handleWebsocket with the middleware before applying the existing OpenTelemetry HTTP handler. Tests check the url.full span attribute and verify that one span is exported for each request case.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk | ⚪ Minimal · up to 3ccf9

Merge Risk: ⚪ Minimal · up to 3ccf9

This change adds a url.full attribute to /ws spans so they can be found by URL search. It does not change request handling, and no merge-blocking risk was identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 3ccf9

Only trace URL metadata changes; WebSocket validation and upgrade behavior remain unchanged. Query strings are excluded. Remaining uncertainty concerns production proxy enforcement and downstream use of the new metadata, not an identified authorization bypass.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The introduced exposure is descriptive URL metadata on the existing /ws endpoint’s recorded spans. A peer reaching that route can influence Host and, where forwarded unchanged, the allowed scheme. The inspected change does not expand service authority or introduce a new network destination.

Trust Boundaries and Controls

  • observed — The wrapper preserves existing subprotocol, protocol-version, consumer-session, and WebSocket acceptance checks. Request-derived URL metadata is not substituted for those checks. Production proxy enforcement and downstream reliance on that metadata remain unverified.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: recording url.full on /ws spans to support SigNoz URL search.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation correctly records the required attribute while excluding query data and includes appropriate coverage.

0 open findings

What changed in this PR

Adds searchable full URLs to egress /ws server spans for SigNoz trace discovery.

Changes:

  • Adds middleware that records a sanitized url.full.
  • Wraps the /ws handler inside otelhttp instrumentation.
  • Tests proxy schemes, invalid protocols, and query removal.
File Description
egress/​urlfull.go Builds and records the sanitized URL attribute.
egress/​urlfull_test.go Verifies span attributes and URL sanitization.
egress/​egresslib.go Applies the middleware to /ws.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AGMETEOR AGMETEOR self-assigned this Oct 10, 2026
@AGMETEOR
AGMETEOR merged commit dbf40b0 into main Oct 10, 2026
5 checks passed
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.

2 participants