Label request metrics with standard HTTP methods only (closes #274) #277

Merged
clawbot merged 2 commits from issue-274-metrics-method-label into next 2026-10-15 21:47:11 +02:00
2 Commits
Author SHA1 Message Date
sneak bc6464a3c5 Label request metrics with standard HTTP methods only (closes #274)
check / check (push) Waiting to run
The method label was each request's method as sent, and Go's HTTP
server accepts any method name, so made-up methods added series to the
registry that were never removed. It is now the method only for GET,
HEAD, POST, PUT, PATCH, DELETE, OPTIONS, CONNECT and TRACE, and "other"
for any other. go-http-metrics reads the method from the request it is
handed, so the middleware hands it a copy carrying the label and serves
the next handler the original request.

Model: opus-5-5
2026-10-15 19:01:46 +00:00
sneak afb94a14f0 Test that made-up methods share one metrics method label
The test sends two requests with made-up methods through the metrics
middleware and expects /metrics to count both under the method label
"other", and the handler to see each method as sent. It fails until the
middleware stops using every method name as its own label value.

Model: opus-5-5
2026-10-15 19:01:28 +00:00