groups:
  - id: aspnetcore.common.rate_limiting.metrics.attributes
    type: attribute_group
    brief: Common ASP.NET Core rate-limiting metrics attributes
    attributes:
      - ref: aspnetcore.rate_limiting.policy
        requirement_level:
          conditionally_required: if the matched endpoint for the request had a rate-limiting policy.

  # routing
  - id: metric.aspnetcore.routing.match_attempts
    type: metric
    metric_name: aspnetcore.routing.match_attempts
    stability: stable
    brief: Number of requests that were attempted to be matched to an endpoint.
    instrument: counter
    unit: "{match_attempt}"
    note: |
      Meter name: `Microsoft.AspNetCore.Routing`; Added in: ASP.NET Core 8.0
    attributes:
      - ref: http.route
        requirement_level:
          conditionally_required: if and only if a route was successfully matched.
      - ref: aspnetcore.routing.is_fallback
        requirement_level:
          conditionally_required: if and only if a route was successfully matched.
      - ref: aspnetcore.routing.match_status
        requirement_level: required

  # diagnostics
  - id: metric.aspnetcore.diagnostics.exceptions
    type: metric
    metric_name: aspnetcore.diagnostics.exceptions
    stability: stable
    brief: Number of exceptions caught by exception handling middleware.
    instrument: counter
    unit: "{exception}"
    note: |
      Meter name: `Microsoft.AspNetCore.Diagnostics`; Added in: ASP.NET Core 8.0
    attributes:
      - ref: error.type
        brief: The full name of exception type.
        examples: ['System.OperationCanceledException', 'Contoso.MyException']
        requirement_level: required
      - ref: aspnetcore.diagnostics.handler.type
        requirement_level:
          conditionally_required: if and only if the exception was handled by this handler.
      - ref: aspnetcore.diagnostics.exception.result
        requirement_level: required

  # rate_limiting
  - id: metric.aspnetcore.rate_limiting.active_request_leases
    type: metric
    metric_name: aspnetcore.rate_limiting.active_request_leases
    stability: stable
    brief: Number of requests that are currently active on the server that hold a rate limiting lease.
    instrument: updowncounter
    unit: "{request}"
    note: |
      Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0
    extends: aspnetcore.common.rate_limiting.metrics.attributes

  - id: metric.aspnetcore.rate_limiting.request_lease.duration
    type: metric
    metric_name: aspnetcore.rate_limiting.request_lease.duration
    stability: stable
    brief: The duration of rate limiting lease held by requests on the server.
    instrument: histogram
    unit: "s"
    note: |
      Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0
    extends: aspnetcore.common.rate_limiting.metrics.attributes

  - id: metric.aspnetcore.rate_limiting.request.time_in_queue
    type: metric
    metric_name: aspnetcore.rate_limiting.request.time_in_queue
    stability: stable
    brief: The time the request spent in a queue waiting to acquire a rate limiting lease.
    instrument: histogram
    unit: "s"
    note: |
      Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0
    extends: aspnetcore.common.rate_limiting.metrics.attributes
    attributes:
      - ref: aspnetcore.rate_limiting.result
        requirement_level: required

  - id: metric.aspnetcore.rate_limiting.queued_requests
    type: metric
    metric_name: aspnetcore.rate_limiting.queued_requests
    stability: stable
    brief: Number of requests that are currently queued, waiting to acquire a rate limiting lease.
    instrument: updowncounter
    unit: "{request}"
    note: |
      Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0
    extends: aspnetcore.common.rate_limiting.metrics.attributes

  - id: metric.aspnetcore.rate_limiting.requests
    type: metric
    metric_name: aspnetcore.rate_limiting.requests
    stability: stable
    brief: Number of requests that tried to acquire a rate limiting lease.
    instrument: counter
    unit: "{request}"
    note: |
      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
    extends: aspnetcore.common.rate_limiting.metrics.attributes
    attributes:
      - ref: aspnetcore.rate_limiting.result
        requirement_level: required
