-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add IHttpMetricsTagsFeature and IConnectionMetricsTagsFeature #47493
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! namespace Microsoft.AspNetCore.Http.Features;
+ public interface IHttpMetricsTagsFeature
+ {
+ ICollection<KeyValuePair<string, object?> Tags { get; }
+ }
namespace Microsoft.AspNetCore.Connections.Features;
+ public interface IConnectionMetricsTagsFeature
+ {
+ ICollection<KeyValuePair<string, object?>> Tags { get; }
+ } |
Added in #46834 |
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
ASP.NET Core hosting counters record the number of current requests and duration. There isn't a way for a framework, middleware or app to enrich these counters with tags per-request. For example, ASP.NET Core might want to add a tag to the HTTP server metrics that specifies whether there was an unhandled exception with that request.
This issue outlines an ASP.NET Core feature for adding tags to metrics. It's similar to the existing
IHttpActivityFeature
. For an example of enriching the request activity with tags, see Activity Enrichment in ASP.NET Core 6.0.Proposed API
Implementations are internal. Features are automatically set on the
HttpContext
orTransportConnection
if metrics is enabled (aka someone is listening).Usage Examples
The feature is used by frameworks, middleware or apps when they want to enrich HTTP metrics counters (or connection counters) with extra tags. In the sample below, middleware catches unhandled exceptions, then uses the feature to add the exception type name to metrics.
ASP.NET Core hosting uses the feature when recording counters.
Alternative Designs
One feature could be used for HTTP request and connection.
I believe that approach means it wouldn't be possible to get the connection metrics tags feature from a request, because the request feature of the same type would always be returned.
Risks
The text was updated successfully, but these errors were encountered: