-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Add IHttpMetricsTagsFeature and IConnectionMetricsTagsFeature #47493
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
JamesNK
added
area-runtime
api-ready-for-review
API is ready for formal API review - https://github.com/dotnet/apireviews
labels
Mar 30, 2023
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; }
+ } |
JamesNK
added
api-approved
API was approved in API review, it can be implemented
and removed
api-ready-for-review
API is ready for formal API review - https://github.com/dotnet/apireviews
labels
Apr 11, 2023
Added in #46834 |
ghost
locked as resolved and limited conversation to collaborators
May 13, 2023
amcasey
added
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
and removed
area-runtime
labels
Aug 25, 2023
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: