fix(telemetry): name tenant sub-resource requests after their collection #107

Merged
sharang merged 1 commits from fix/telemetry-sub-route into main 2026-10-30 07:31:48 +00:00
Owner

Side finding from the document-store stage check (29 Oct). GET /v1/tenants/{id}/{sub} dispatches eight collections, but spans and access-log lines all said {sub}: in SigNoz a store read (prepared view, banner, original) looked the same as a team list.

The wildcard route itself stays. ServeMux would reject GET /v1/tenants/{id}/members next to GET /v1/tenants/by-slug/{slug} (see the comment in server.go).

Change: the route function used for spans and the access log names a request GET /v1/tenants/{id}/<collection> when the segment is one of the eight known names (tenantSubresources, kept next to the dispatcher). Anything else keeps GET /v1/tenants/{id}/{sub}. The set is fixed, so there's no cardinality growth and no free path text (slugs, typos) in the name.

Tests:

  • TestSubRoute: known names, an unknown one, deeper paths, an empty segment.
  • TestTenantSubresourcesMatchDispatcher: every listed name reaches a handler, and an unlisted one gets the dispatcher's 404. So the list and the switch can't drift apart.
  • The full suite passes, including postgres.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4

Side finding from the document-store stage check (29 Oct). `GET /v1/tenants/{id}/{sub}` dispatches eight collections, but spans and access-log lines all said `{sub}`: in SigNoz a store read (prepared view, banner, original) looked the same as a team list. The wildcard route itself stays. ServeMux would reject `GET /v1/tenants/{id}/members` next to `GET /v1/tenants/by-slug/{slug}` (see the comment in `server.go`). **Change:** the route function used for spans and the access log names a request `GET /v1/tenants/{id}/<collection>` when the segment is one of the eight known names (`tenantSubresources`, kept next to the dispatcher). Anything else keeps `GET /v1/tenants/{id}/{sub}`. The set is fixed, so there's no cardinality growth and no free path text (slugs, typos) in the name. **Tests:** - `TestSubRoute`: known names, an unknown one, deeper paths, an empty segment. - `TestTenantSubresourcesMatchDispatcher`: every listed name reaches a handler, and an unlisted one gets the dispatcher's 404. So the list and the switch can't drift apart. - The full suite passes, including postgres. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang added 1 commit 2026-10-29 21:28:41 +00:00
fix(telemetry): name tenant sub-resource requests after their collection
ci / shared (pull_request) Successful in 18s
ci / test (pull_request) Successful in 26m56s
ci / image (pull_request) Skipped
d31594cc6c
GET /v1/tenants/{id}/{sub} serves eight collections (members, documents,
projects, contracts, managed-services, company-profile, role-dataset,
store), and spans and access-log lines all said '{sub}': SigNoz could
not tell a document-store read from a team list. The route name now
carries the collection when it is one of the eight, and keeps the
wildcard for anything else, so no free path text reaches the name.

The list lives next to the dispatcher; a test keeps the two in step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4
sharang merged commit 9af8b283a2 into main 2026-10-30 07:31:48 +00:00
Sign in to join this conversation.