-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add IRouteDiagnosticsMetadata #47492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
api-approved
API was approved in API review, it can be implemented
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API Review Note:
API Approved! // Microsoft.AspNetCore.Http.Abstractions.dll
namespace Microsoft.AspNetCore.Http.Metadata;
+ public interface IRouteDiagnosticsMetadata
+ {
+ string Route { get; }
+ } |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
api-approved
API was approved in API review, it can be implemented
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Background and Motivation
The Open Telemetry HTTP server semantic conventions records required and optional data to include with metrics measurements. A recommended tag is the route match by the HTTP request. For example, an HTTP request to
app.MapGet("product/{id}", () => ...)
would have the routeproduct/{id}
.The route is available in ASP.NET Core on the matched endpoint in the RouteEndpoint.RoutePattern. However, HTTP metrics are run in
Microsoft.AspNetCore.Hosting
. That code doesn't have access toRouteEndpoint
, which is inMicrosoft.AspNetCore.Routing
, because of layering.Two possible solutions:
RouteEndpoint
,RoutePattern
, and all its dependencies toMicrosoft.AspNetCore.Http.Abstractions
and type forward. Then hosting can check if the matched endpoint is aRouteEndpoint
and access the route. However, the route pattern is quite a lot of code to move.Microsoft.AspNetCore.Http.Abstractions
. The metadata has a property with a string version of the pattern. Hosting diagnostics can then get the metadata from the endpoint, and use whatever text value is present.Proposed API
Usage Examples
Alternative Designs
See description.
Risks
The text was updated successfully, but these errors were encountered: