Repository navigation
Conversation
…ault Requests that match no route used to get the request path as the url label. Every unknown path (scanners, bots) then created a new set of series - over 40 per path with the default histograms - and request paths can carry IDs or personal data into the metrics. Now these 404s share the same empty url label by default. The new UseRequestPathFor404 option restores the request path. DoNotUseRequestPathFor404 is kept for compatibility, deprecated and without effect, since its behaviour is now the default. Also drops the stale "as of Echo v4.10.1" note: this module targets Echo v5, where the route path is still empty when nothing matched. BREAKING CHANGE: 404s without a matching route get url="" unless UseRequestPathFor404 is set. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Summary
Requests that match no route are now recorded with an empty
urllabel by default, instead of the raw request path.The new
UseRequestPathFor404option restores the old behaviour.DoNotUseRequestPathFor404still compiles, but isdeprecated and has no effect, since its behaviour is now the default. 404s returned by a matched route keep their
route pattern, as before.
This is a breaking change for anyone who reads per-path 404 metrics.
Why
The
urllabel is meant to hold the route pattern (/users/:id), which has a small, fixed set of values. For a 404with no matching route, Echo leaves the route path empty and the middleware falls back to the raw request path: a value
the client fully controls.
urlvalue creates 41 series with the default metrics: 1 forrequests_total,14 for
request_duration_seconds, 13 each forrequest_size_bytesandresponse_size_bytes. A single scannertrying 5,000 paths adds about 205,000 series, more than most applications' useful metrics, and anyone who can reach
the server can push this further. Prometheus middleware generates new metrics for every 404 echo-contrib#86 reported that this "can easily generate millions of
timeseries".
/users/[email protected]/profile,/reset/<token>). Metrics are usually kept longer and visible to more people than application logs.stays visible through
code="404", and those who need the paths can opt in.Why now
The opt-in flag was added in labstack/echo-contrib#111 to address labstack/echo-contrib#86, and the default was kept
for compatibility. This module starts fresh at
v0.0.1, which makes it the least disruptive point to make the safebehaviour the default.
Migration
DoNotUseRequestPathFor404: trueUseRequestPathFor404: trueAlso
when no route matched.
Tests
url="";TestInvalidUTF8PathIsFixedopts into raw paths, which it tests.TestUseRequestPathFor404.go vet,go test -raceandstaticcheckpass on Go 1.26.If you'd rather not change the default in v0.x, I'm happy to turn this into a documentation change for
DoNotUseRequestPathFor404instead.Co-Authored-By: Claude Opus 5.5 [email protected]