Repository navigation
feat(telemetry): expose a check for collisions with built-in server routes - #285
Open
LubabaKhalid wants to merge 1 commit into
Open
LubabaKhalid wants to merge 1 commit into
LubabaKhalid wants to merge 1 commit into
Conversation
…outes Built-in telemetry server routes are inserted before custom routes, so a custom route on the same path and method is silently ignored. Add `TelemetryServerRoute::collides_with_built_in_route` so services can detect this at startup. The check inserts the route into a copy of each built-in router, using the same path handling as the server, so it follows the same conflict rules with and without `telemetry-server-pattern-routing`.
Author
|
@TheJokr this adds the built-in route collision check you suggested. Could you take a look when you have a moment? Thanks! |
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.
Built-in telemetry server routes are inserted before custom routes, so a custom route on the same path and method as a built-in one is silently ignored. This is easy to hit by accident, and a built-in route added in a later release can start shadowing an existing custom route without any warning.
This adds
TelemetryServerRoute::collides_with_built_in_route, which returnstrueif the route collides with a built-in route for any of its methods. Services can call it at startup and fail or warn as they see fit:The check builds the built-in routes for the enabled features and tries to insert the route into a copy of each method's router, so it follows the same conflict rules as the server itself, with and without
telemetry-server-pattern-routing. The parameter escaping thatRoutes::setdid inline moved into a small helper so both use the same path handling.Testing
GET /health,GET /metrics), the same path on a method the built-in route does not handle (POST /health), and a path with no built-in route.cargo test -p foundations --test telemetry_serverwith and withouttelemetry-server-pattern-routing.cargo clippy -p foundations --all-targetswith the CI lint flags, for both feature sets.rustfmt --check --edition 2024.Closes #200