Semantic Conventions for ASP.NET Core metrics

Status: Stable

This article defines semantic conventions for ASP.NET Core metrics.

Server

Routing

All routing metrics are reported by the Microsoft.AspNetCore.Routing meter.

Metric: aspnetcore.routing.match_attempts

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.routing.match_attemptsCounter{match_attempt}Number of requests that were attempted to be matched to an endpoint. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.Routing; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.routing.match_statusstringMatch result - success or failuresuccess; failureRequiredStable
aspnetcore.routing.is_fallbackbooleanA value that indicates whether the matched route is a fallback route.trueConditionally Required if and only if a route was successfully matched.Stable
http.routestringThe matched route, that is, the path template in the format used by the respective server framework. [1]/users/:userID?; {controller}/{action}/{id?}Conditionally Required if and only if a route was successfully matched.Stable

[1] http.route: MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it. SHOULD include the application root if there is one.


aspnetcore.routing.match_status has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
failureMatch failedStable
successMatch succeededStable

Exceptions

Exceptions Metric is reported by the Microsoft.AspNetCore.Diagnostics meter.

Metric: aspnetcore.diagnostics.exceptions

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.diagnostics.exceptionsCounter{exception}Number of exceptions caught by exception handling middleware. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.Diagnostics; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.diagnostics.exception.resultstringASP.NET Core exception middleware handling resulthandled; unhandledRequiredStable
error.typestringThe full name of exception type. [1]System.OperationCanceledException; Contoso.MyExceptionRequiredStable
aspnetcore.diagnostics.handler.typestringFull type name of the IExceptionHandler implementation that handled the exception.Contoso.MyHandlerConditionally Required [2]Stable

[1] error.type: The error.type SHOULD be predictable, and SHOULD have low cardinality.

When error.type is set to a type (e.g., an exception type), its canonical class name identifying the type within the artifact SHOULD be used.

Instrumentations SHOULD document the list of errors they report.

The cardinality of error.type within one instrumentation library SHOULD be low. Telemetry consumers that aggregate data from multiple instrumentation libraries and applications should be prepared for error.type to have high cardinality at query time when no additional filters are applied.

If the operation has completed successfully, instrumentations SHOULD NOT set error.type.

If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), it’s RECOMMENDED to:

  • Use a domain-specific attribute
  • Set error.type to capture all errors, regardless of whether they are defined within the domain-specific set or not.

[2] aspnetcore.diagnostics.handler.type: if and only if the exception was handled by this handler.


aspnetcore.diagnostics.exception.result has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
abortedException handling didn’t run because the request was aborted.Stable
handledException was handled by the exception handling middleware.Stable
skippedException handling was skipped because the response had started.Stable
unhandledException was not handled by the exception handling middleware.Stable

error.type has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
_OTHERA fallback error value to be used when the instrumentation doesn’t define a custom value.Stable

Rate-limiting

All rate-limiting metrics are reported by the Microsoft.AspNetCore.RateLimiting meter.

Metric: aspnetcore.rate_limiting.active_request_leases

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.rate_limiting.active_request_leasesUpDownCounter{request}Number of requests that are currently active on the server that hold a rate limiting lease. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.RateLimiting; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.rate_limiting.policystringRate limiting policy name.fixed; sliding; tokenConditionally Required [1]Stable

[1] aspnetcore.rate_limiting.policy: if the matched endpoint for the request had a rate-limiting policy.

Metric: aspnetcore.rate_limiting.request_lease.duration

this metric SHOULD be specified with ExplicitBucketBoundaries of [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ].

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.rate_limiting.request_lease.durationHistogramsThe duration of rate limiting lease held by requests on the server. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.RateLimiting; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.rate_limiting.policystringRate limiting policy name.fixed; sliding; tokenConditionally Required [1]Stable

[1] aspnetcore.rate_limiting.policy: if the matched endpoint for the request had a rate-limiting policy.

Metric: aspnetcore.rate_limiting.queued_requests

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.rate_limiting.queued_requestsUpDownCounter{request}Number of requests that are currently queued, waiting to acquire a rate limiting lease. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.RateLimiting; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.rate_limiting.policystringRate limiting policy name.fixed; sliding; tokenConditionally Required [1]Stable

[1] aspnetcore.rate_limiting.policy: if the matched endpoint for the request had a rate-limiting policy.

Metric: aspnetcore.rate_limiting.request.time_in_queue

this metric SHOULD be specified with ExplicitBucketBoundaries of [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ].

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.rate_limiting.request.time_in_queueHistogramsThe time the request spent in a queue waiting to acquire a rate limiting lease. [1]Stable

[1]: Meter name: Microsoft.AspNetCore.RateLimiting; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.rate_limiting.resultstringRate-limiting result, shows whether the lease was acquired or contains a rejection reasonacquired; request_canceledRequiredStable
aspnetcore.rate_limiting.policystringRate limiting policy name.fixed; sliding; tokenConditionally Required [1]Stable

[1] aspnetcore.rate_limiting.policy: if the matched endpoint for the request had a rate-limiting policy.


aspnetcore.rate_limiting.result has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
acquiredLease was acquiredStable
endpoint_limiterLease request was rejected by the endpoint limiterStable
global_limiterLease request was rejected by the global limiterStable
request_canceledLease request was canceledStable

Metric: aspnetcore.rate_limiting.requests

NameInstrument TypeUnit (UCUM)DescriptionStability
aspnetcore.rate_limiting.requestsCounter{request}Number of requests that tried to acquire a rate limiting lease. [1]Stable

[1]: Requests could be:

  • Rejected by global or endpoint rate limiting policies
  • Canceled while waiting for the lease.

Meter name: Microsoft.AspNetCore.RateLimiting; Added in: ASP.NET Core 8.0

AttributeTypeDescriptionExamplesRequirement LevelStability
aspnetcore.rate_limiting.resultstringRate-limiting result, shows whether the lease was acquired or contains a rejection reasonacquired; request_canceledRequiredStable
aspnetcore.rate_limiting.policystringRate limiting policy name.fixed; sliding; tokenConditionally Required [1]Stable

[1] aspnetcore.rate_limiting.policy: if the matched endpoint for the request had a rate-limiting policy.


aspnetcore.rate_limiting.result has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

ValueDescriptionStability
acquiredLease was acquiredStable
endpoint_limiterLease request was rejected by the endpoint limiterStable
global_limiterLease request was rejected by the global limiterStable
request_canceledLease request was canceledStable