From 86a6839694b9e5d2a0e8c1f7a3f1fcb9dc0e8039 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 17 Jul 2025 15:25:14 +0800 Subject: [PATCH] Add ASP.NET Core memory pool metrics --- .chloggen/2532.yaml | 4 + docs/dotnet/dotnet-aspnetcore-metrics.md | 113 +++++++++++++++++++++++ docs/registry/attributes/aspnetcore.md | 1 + model/aspnetcore/metrics.yaml | 64 +++++++++++++ model/aspnetcore/registry.yaml | 5 + 5 files changed, 187 insertions(+) create mode 100644 .chloggen/2532.yaml diff --git a/.chloggen/2532.yaml b/.chloggen/2532.yaml new file mode 100644 index 0000000000..6bb32ed347 --- /dev/null +++ b/.chloggen/2532.yaml @@ -0,0 +1,4 @@ +change_type: enhancement +component: aspnetcore +note: Add ASP.NET Core memory pool metrics and update the registry. +issues: [2532] diff --git a/docs/dotnet/dotnet-aspnetcore-metrics.md b/docs/dotnet/dotnet-aspnetcore-metrics.md index a801bcc776..0c61cfc68e 100644 --- a/docs/dotnet/dotnet-aspnetcore-metrics.md +++ b/docs/dotnet/dotnet-aspnetcore-metrics.md @@ -21,6 +21,11 @@ This article defines semantic conventions for ASP.NET Core metrics. - [Metric: `aspnetcore.rate_limiting.queued_requests`](#metric-aspnetcorerate_limitingqueued_requests) - [Metric: `aspnetcore.rate_limiting.request.time_in_queue`](#metric-aspnetcorerate_limitingrequesttime_in_queue) - [Metric: `aspnetcore.rate_limiting.requests`](#metric-aspnetcorerate_limitingrequests) +- [Memory pool](#memory-pool) + - [Metric: `aspnetcore.memory_pool.pooled`](#metric-aspnetcorememory_poolpooled) + - [Metric: `aspnetcore.memory_pool.evicted`](#metric-aspnetcorememory_poolevicted) + - [Metric: `aspnetcore.memory_pool.allocated`](#metric-aspnetcorememory_poolallocated) + - [Metric: `aspnetcore.memory_pool.rented`](#metric-aspnetcorememory_poolrented) - [Identity](#identity) - [Metric: `aspnetcore.identity.user.create.duration`](#metric-aspnetcoreidentityusercreateduration) - [Metric: `aspnetcore.identity.user.update.duration`](#metric-aspnetcoreidentityuserupdateduration) @@ -303,6 +308,114 @@ Meter name: `Microsoft.AspNetCore.RateLimiting`; Added in: ASP.NET Core 8.0 +## Memory pool + +All memory pool metrics are reported by the `Microsoft.AspNetCore.MemoryPool` meter. + +### Metric: `aspnetcore.memory_pool.pooled` + + + + + + + + +| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations | +| -------- | --------------- | ----------- | -------------- | --------- | ------ | +| `aspnetcore.memory_pool.pooled` | UpDownCounter | `By` | Number of bytes currently pooled and available for reuse. [1] | ![Development](https://img.shields.io/badge/-development-blue) | | + +**[1]:** Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + +| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---|---|---|---|---|---| +| [`aspnetcore.memory_pool.owner`](/docs/registry/attributes/aspnetcore.md) | string | The name of the library or subsystem using the memory pool instance. | `kestrel`; `iis` | `Conditionally Required` [1] | ![Development](https://img.shields.io/badge/-development-blue) | + +**[1] `aspnetcore.memory_pool.owner`:** if owner is specified when the memory pool is created. + + + + + + +### Metric: `aspnetcore.memory_pool.evicted` + + + + + + + + +| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations | +| -------- | --------------- | ----------- | -------------- | --------- | ------ | +| `aspnetcore.memory_pool.evicted` | Counter | `By` | Total number of bytes evicted from the memory pool. Eviction occurs when idle pooled memory is reclaimed. [1] | ![Development](https://img.shields.io/badge/-development-blue) | | + +**[1]:** Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + +| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---|---|---|---|---|---| +| [`aspnetcore.memory_pool.owner`](/docs/registry/attributes/aspnetcore.md) | string | The name of the library or subsystem using the memory pool instance. | `kestrel`; `iis` | `Conditionally Required` [1] | ![Development](https://img.shields.io/badge/-development-blue) | + +**[1] `aspnetcore.memory_pool.owner`:** if owner is specified when the memory pool is created. + + + + + + +### Metric: `aspnetcore.memory_pool.allocated` + + + + + + + + +| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations | +| -------- | --------------- | ----------- | -------------- | --------- | ------ | +| `aspnetcore.memory_pool.allocated` | Counter | `By` | Total number of bytes allocated by the memory pool. Allocation occurs when a memory rental request exceeds the available pooled memory. [1] | ![Development](https://img.shields.io/badge/-development-blue) | | + +**[1]:** Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + +| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---|---|---|---|---|---| +| [`aspnetcore.memory_pool.owner`](/docs/registry/attributes/aspnetcore.md) | string | The name of the library or subsystem using the memory pool instance. | `kestrel`; `iis` | `Conditionally Required` [1] | ![Development](https://img.shields.io/badge/-development-blue) | + +**[1] `aspnetcore.memory_pool.owner`:** if owner is specified when the memory pool is created. + + + + + + +### Metric: `aspnetcore.memory_pool.rented` + + + + + + + + +| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations | +| -------- | --------------- | ----------- | -------------- | --------- | ------ | +| `aspnetcore.memory_pool.rented` | Counter | `By` | Total number of bytes rented from the memory pool. [1] | ![Development](https://img.shields.io/badge/-development-blue) | | + +**[1]:** Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + +| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---|---|---|---|---|---| +| [`aspnetcore.memory_pool.owner`](/docs/registry/attributes/aspnetcore.md) | string | The name of the library or subsystem using the memory pool instance. | `kestrel`; `iis` | `Conditionally Required` [1] | ![Development](https://img.shields.io/badge/-development-blue) | + +**[1] `aspnetcore.memory_pool.owner`:** if owner is specified when the memory pool is created. + + + + + + ## Identity All ASP.NET Core Identity metrics are reported by the `Microsoft.AspNetCore.Identity` meter. diff --git a/docs/registry/attributes/aspnetcore.md b/docs/registry/attributes/aspnetcore.md index 8a5f519414..6c48093481 100644 --- a/docs/registry/attributes/aspnetcore.md +++ b/docs/registry/attributes/aspnetcore.md @@ -21,6 +21,7 @@ ASP.NET Core attributes | `aspnetcore.identity.token_verified` | string | The result of token verification. | `success`; `failure` | ![Development](https://img.shields.io/badge/-development-blue) | | `aspnetcore.identity.user.update_type` | string | The user update type. | `update`; `user_name`; `reset_password` | ![Development](https://img.shields.io/badge/-development-blue) | | `aspnetcore.identity.user_type` | string | The full name of the identity user type. | `Contoso.ContosoUser` | ![Development](https://img.shields.io/badge/-development-blue) | +| `aspnetcore.memory_pool.owner` | string | The name of the library or subsystem using the memory pool instance. | `kestrel`; `iis` | ![Development](https://img.shields.io/badge/-development-blue) | | `aspnetcore.rate_limiting.policy` | string | Rate limiting policy name. | `fixed`; `sliding`; `token` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | `aspnetcore.rate_limiting.result` | string | Rate-limiting result, shows whether the lease was acquired or contains a rejection reason | `acquired`; `request_canceled` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | `aspnetcore.request.is_unhandled` | boolean | Flag indicating if request was handled by the application pipeline. | `true` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | diff --git a/model/aspnetcore/metrics.yaml b/model/aspnetcore/metrics.yaml index 03b00e2e02..fc1e961b91 100644 --- a/model/aspnetcore/metrics.yaml +++ b/model/aspnetcore/metrics.yaml @@ -12,6 +12,13 @@ groups: attributes: - ref: aspnetcore.identity.user_type requirement_level: required + - id: aspnetcore.common.memory_pool.metrics.attributes + type: attribute_group + brief: Common ASP.NET Core memory pool metrics attributes + attributes: + - ref: aspnetcore.memory_pool.owner + requirement_level: + conditionally_required: if owner is specified when the memory pool is created. # routing - id: metric.aspnetcore.routing.match_attempts @@ -143,6 +150,63 @@ groups: - ref: aspnetcore.rate_limiting.result requirement_level: required + # memory_pool + - id: metric.aspnetcore.memory_pool.pooled + type: metric + metric_name: aspnetcore.memory_pool.pooled + annotations: + code_generation: + metric_value_type: int + stability: development + brief: Number of bytes currently pooled and available for reuse. + instrument: updowncounter + unit: "By" + note: | + Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + extends: aspnetcore.common.memory_pool.metrics.attributes + + - id: metric.aspnetcore.memory_pool.allocated + type: metric + metric_name: aspnetcore.memory_pool.allocated + annotations: + code_generation: + metric_value_type: int + stability: development + brief: Total number of bytes allocated by the memory pool. Allocation occurs when a memory rental request exceeds the available pooled memory. + instrument: counter + unit: "By" + note: | + Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + extends: aspnetcore.common.memory_pool.metrics.attributes + + - id: metric.aspnetcore.memory_pool.evicted + type: metric + metric_name: aspnetcore.memory_pool.evicted + annotations: + code_generation: + metric_value_type: int + stability: development + brief: Total number of bytes evicted from the memory pool. Eviction occurs when idle pooled memory is reclaimed. + instrument: counter + unit: "By" + note: | + Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + extends: aspnetcore.common.memory_pool.metrics.attributes + + - id: metric.aspnetcore.memory_pool.rented + type: metric + metric_name: aspnetcore.memory_pool.rented + annotations: + code_generation: + metric_value_type: int + stability: development + brief: Total number of bytes rented from the memory pool. + instrument: counter + unit: "By" + note: | + Meter name: `Microsoft.AspNetCore.MemoryPool`; Added in: ASP.NET Core 10.0 + extends: aspnetcore.common.memory_pool.metrics.attributes + # identity - id: metric.aspnetcore.identity.user.create.duration type: metric diff --git a/model/aspnetcore/registry.yaml b/model/aspnetcore/registry.yaml index aa97bed6ff..3ae15195e7 100644 --- a/model/aspnetcore/registry.yaml +++ b/model/aspnetcore/registry.yaml @@ -83,6 +83,11 @@ groups: stability: stable brief: ASP.NET Core exception middleware handling result. examples: ["handled", "unhandled"] + - id: aspnetcore.memory_pool.owner + type: string + stability: development + brief: The name of the library or subsystem using the memory pool instance. + examples: ["kestrel", "iis"] - id: aspnetcore.identity.user_type type: string brief: The full name of the identity user type.