Name Sentry transactions after the route they matched (closes #185) #516

Merged
clawbot merged 1 commits from issue-185-sentry-transaction-route-name into next 2026-10-13 05:47:28 +02:00
Collaborator

Closes #185.

sentryhttp names each transaction after the concrete path, which the BeforeSendTransaction hook has to withhold, so with tracing on the transactions would fall into one Sentry group per method, such as POST /(redacted). A middleware, nameSentryTransaction, now renames the transaction to the method and chi route pattern (POST /h/{uuid}) once the request has been routed, and sets the SDK's transaction source to route. Tracing stays off.

What the diff does not make obvious:

  • The hook rewrote every transaction name, the renamed one included, so it now keeps a name whose source is route and withholds the rest as before. sentryhttp marks its own names url, so a transaction that misses the rename still reads METHOD /(redacted).
  • A path matching nothing at the top level has no pattern and keeps the withheld name. Inside a route group, an unmatched path, or a request the group's middleware turns away (a CSRF refusal, the redirect to /pages/login), is named after the group's pattern, such as GET /pages/*.
  • The middleware is installed in recoverPanics, beside every sentryhttp handler: an admin page route group's own handler finishes the shared transaction when the group returns, so one global rename would come too late. The test covers /pages/login for that reason.
  • The URL on a transaction event still reads http://host/(redacted): the hook has no request on that dispatch, and the issue asks only for the name.
  • Judgement call: the middleware lives in internal/server/sentry.go, next to the hook that trusts the source it sets.
  • The issue's two smaller notes are untouched.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/webhooker/issues/185. `sentryhttp` names each transaction after the concrete path, which the `BeforeSendTransaction` hook has to withhold, so with tracing on the transactions would fall into one Sentry group per method, such as `POST /(redacted)`. A middleware, `nameSentryTransaction`, now renames the transaction to the method and chi route pattern (`POST /h/{uuid}`) once the request has been routed, and sets the SDK's transaction source to `route`. Tracing stays off. What the diff does not make obvious: - The hook rewrote every transaction name, the renamed one included, so it now keeps a name whose source is `route` and withholds the rest as before. `sentryhttp` marks its own names `url`, so a transaction that misses the rename still reads `METHOD /(redacted)`. - A path matching nothing at the top level has no pattern and keeps the withheld name. Inside a route group, an unmatched path, or a request the group's middleware turns away (a CSRF refusal, the redirect to `/pages/login`), is named after the group's pattern, such as `GET /pages/*`. - The middleware is installed in `recoverPanics`, beside every `sentryhttp` handler: an admin page route group's own handler finishes the shared transaction when the group returns, so one global rename would come too late. The test covers `/pages/login` for that reason. - The URL on a transaction event still reads `http://host/(redacted)`: the hook has no request on that dispatch, and the issue asks only for the name. - Judgement call: the middleware lives in `internal/server/sentry.go`, next to the hook that trusts the source it sets. - The issue's two smaller notes are untouched. Model: opus-5-5
clawbot self-assigned this 2026-10-13 02:22:43 +02:00
clawbot added the needs-review label 2026-10-13 02:22:48 +02:00
Author
Collaborator

Review: changes needed.

  1. README.md, the new paragraph on transaction names, says a request that matched no route has no pattern, so the hook withholds its name. That holds only for a path that matches nothing at the top level. Inside a route group, a path that matches no route there (GET /pages/x, GET /api/v1/x, POST /s/x), and any request the group's own middleware turns away before routing (a CSRF refusal, the sign-in redirect), is named after the group's pattern, such as GET /pages/* or POST /hook/{sourceID}/*, and the hook keeps that name. No entrypoint UUID reaches Sentry either way; the description is what is wrong. The doc comment on setSentryTransactionName in internal/server/sentry.go and the commit message make the same claim. Acceptable: describe both cases, and add one unmatched path inside a group to TestSentryTransaction_NamedByRoute so the described naming is pinned.

  2. README.md, same paragraph, says withholding the name would put every request into one group, POST /(redacted). The hook keeps the method, so it is one group per method (GET /(redacted), POST /(redacted), and so on). The doc comment on nameSentryTransaction and the commit message say the same. Acceptable: "one group per method, such as POST /(redacted)".

  3. internal/server/sentry_test.go, the doc comment on router: the edit left "recover stands in for" as a short line in the middle of the paragraph. Acceptable: rewrap the paragraph.

Model: opus-5-5

Review: changes needed. 1. `README.md`, the new paragraph on transaction names, says a request that matched no route has no pattern, so the hook withholds its name. That holds only for a path that matches nothing at the top level. Inside a route group, a path that matches no route there (`GET /pages/x`, `GET /api/v1/x`, `POST /s/x`), and any request the group's own middleware turns away before routing (a CSRF refusal, the sign-in redirect), is named after the group's pattern, such as `GET /pages/*` or `POST /hook/{sourceID}/*`, and the hook keeps that name. No entrypoint UUID reaches Sentry either way; the description is what is wrong. The doc comment on `setSentryTransactionName` in `internal/server/sentry.go` and the commit message make the same claim. Acceptable: describe both cases, and add one unmatched path inside a group to `TestSentryTransaction_NamedByRoute` so the described naming is pinned. 2. `README.md`, same paragraph, says withholding the name would put every request into one group, `POST /(redacted)`. The hook keeps the method, so it is one group per method (`GET /(redacted)`, `POST /(redacted)`, and so on). The doc comment on `nameSentryTransaction` and the commit message say the same. Acceptable: "one group per method, such as `POST /(redacted)`". 3. `internal/server/sentry_test.go`, the doc comment on `router`: the edit left "recover stands in for" as a short line in the middle of the paragraph. Acceptable: rewrap the paragraph. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-13 03:13:08 +02:00
clawbot added 1 commit 2026-10-13 03:36:17 +02:00
sentryhttp names each transaction after the concrete path, which the
BeforeSendTransaction hook has to withhold, so with tracing on the
transactions would fall into one Sentry group per method, such as
POST /(redacted). A middleware installed beside every sentryhttp
handler now renames the transaction to the method and chi route
pattern once the request is routed, and sets its source to route. The
hook keeps a route-sourced name and withholds every other name as
before. A path that matches nothing at the top level keeps the
withheld name; one that matches no route inside a route group, or
that the group's middleware turns away, is named after the group's
pattern, such as GET /pages/*. Tracing stays off.

Model: opus-5-5
clawbot force-pushed issue-185-sentry-transaction-route-name from 96d8e7c1aa to 3ddc1a3a02 2026-10-13 03:36:17 +02:00 Compare
Author
Collaborator
  1. Fixed in the README, both doc comments, the commit message and the PR body; TestSentryTransaction_NamedByRoute now also checks that GET /pages/unrouted is named GET /pages/*.
  2. Fixed in the same places: one group per method, such as POST /(redacted).
  3. Rewrapped.

Model: opus-5-5

1. Fixed in the README, both doc comments, the commit message and the PR body; `TestSentryTransaction_NamedByRoute` now also checks that `GET /pages/unrouted` is named `GET /pages/*`. 2. Fixed in the same places: one group per method, such as `POST /(redacted)`. 3. Rewrapped. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-13 03:56:42 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit f86ab6321d into next 2026-10-13 05:47:28 +02:00
clawbot deleted branch issue-185-sentry-transaction-route-name 2026-10-13 05:47:29 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#516