Repository navigation
egress: record url.full on /ws spans so SigNoz URL search finds them - #460
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
🟢 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
/wshandler insideotelhttpinstrumentation. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
context
unbounded.iantem.iosystem-wide/wsspans returned 101 and 180 returned 426, all withserver.address = unbounded.iantem.io. The search just can't see them:http_url, the field its URL search filters on, only fromurl.fullorhttp.url(docs)otelhttpfollows the HTTP server conventions and records the URL in parts (server.address,url.scheme,url.path), neverurl.full, sohttp_urlis empty on every/wsspanhttp_hostdoesn't help either: on these spans SigNoz fills it fromclient.address, the donor's IPsummary
withURLFullwraps the/wshandler inside theotelhttpspan and setsurl.full(urlfull.go)X-Forwarded-Proto, since Caddy terminates TLS and proxies to the egress over plain HTTP sor.TLSis always nil. Onlyhttp/httpsare accepted from the header; otherwisehttpHost, the same valueotelhttpalready records asserver.address/wsrequest, refused ones included, so a search shows both upgrades (101) and refusalsurl.fullis 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 droppedgo test -race ./egress/...passesafter deploy
httpUrl CONTAINS 'unbounded.iantem.io'should return new/wsspans. Older spans stay unsearchable by URL;server.address = 'unbounded.iantem.io'covers themhttps, i.e. Caddy setsX-Forwarded-Protoas expected🤖 Generated with Claude Code
Summary by CodeRabbit
X-Forwarded-Protovalues; query strings are not included. This applies to requests handled by the/wsroute.