diff --git a/docs/core/diagnostics/built-in-metrics-diagnostics.md b/docs/core/diagnostics/built-in-metrics-diagnostics.md index 83abced071826..e51329efa0566 100644 --- a/docs/core/diagnostics/built-in-metrics-diagnostics.md +++ b/docs/core/diagnostics/built-in-metrics-diagnostics.md @@ -26,42 +26,42 @@ You can enable these metrics by calling the | `{report}` | Number of times a health report reported the health status of an application. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `dotnet.health_check.status` | string | The health status of an application. | `Healthy`; `Unhealthy` | Always | +| Attribute | Type | Description | Examples | Presence | +|------------------------------|----------|--------------------------------------|------------------------|----------| +| `dotnet.health_check.status` | `string` | The health status of an application. | `Healthy`; `Unhealthy` | Always | `dotnet.health_check.status` is one of the following: -| Value | Description | -|---|---| -| `Degraded` | An application was in degraded state. | -| `Healthy` | An application was healthy. | -| `Unhealthy` | An application was unhealthy. | +| Value | Description | +|-------------|---------------------------------------| +| `Degraded` | An application was in degraded state. | +| `Healthy` | An application was healthy. | +| `Unhealthy` | An application was unhealthy. | -Available starting in: .NET 8.0. +Available starting in: .NET 8. ##### Metric: `dotnet.health_check.unhealthy_checks` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.health_check.unhealthy_checks` | Counter | `{unhealthy_check}` | Number of times a health check reported the health status of an application as `Degraded` or `Unhealthy`. | +| `dotnet.health_check.unhealthy_checks` | | `{unhealthy_check}` | Number of times a health check reported the health status of an application as `Degraded` or `Unhealthy`. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `dotnet.health_check.name` | string | The name of the health check. | `ApplicationLifecycle` | Always | -| `dotnet.health_check.status` | string | The health status of an application. | `Healthy`; `Unhealthy` | Always | +| Attribute | Type | Description | Examples | Presence | +|------------------------------|----------|--------------------------------------|------------------------|----------| +| `dotnet.health_check.name` | `string` | The name of the health check. | `ApplicationLifecycle` | Always | +| `dotnet.health_check.status` | `string` | The health status of an application. | `Healthy`; `Unhealthy` | Always | `dotnet.health_check.status` is one of the following: -| Value | Description | -|---|---| -| `Degraded` | An application was in degraded state. | -| `Healthy` | An application was healthy. | -| `Unhealthy` | An application was unhealthy. | +| Value | Description | +|-------------|---------------------------------------| +| `Degraded` | An application was in degraded state. | +| `Healthy` | An application was healthy. | +| `Unhealthy` | An application was unhealthy. | -Available starting in: .NET 8.0. +Available starting in: .NET 8. ## `Microsoft.Extensions.Diagnostics.ResourceMonitoring` @@ -85,7 +85,7 @@ The instrument is only available on a system running on containers both on Windo | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `container.cpu.limit.utilization` | ObservableGauge | `1` | The CPU consumption of the running containerized application relative to resource limit in range `[0, 1]`. | +| `container.cpu.limit.utilization` | | `1` | The CPU consumption of the running containerized application relative to resource limit in range `[0, 1]`. | Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 8.8.0. @@ -95,7 +95,7 @@ The instrument is only available on a system running on containers on Linux. | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `container.cpu.request.utilization` | ObservableGauge | `1` | The CPU consumption of the running containerized application relative to resource request in range `[0, 1]`. | +| `container.cpu.request.utilization` | | `1` | The CPU consumption of the running containerized application relative to resource request in range `[0, 1]`. | Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 8.8.0. @@ -105,7 +105,7 @@ The instrument is only available on a system running on a container either on Wi | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `container.cpu.time` | ObservableCounter | `s` | CPU time used by the container. | +| `container.cpu.time` | | `s` | CPU time used by the container. | Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 9.8.0. @@ -115,7 +115,7 @@ The instrument is only available on a system running on containers both on Windo | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `container.memory.limit.utilization` | ObservableGauge | `1` | The memory consumption of the running containerized application relative to resource limit in range `[0, 1]`. | +| `container.memory.limit.utilization` | | `1` | The memory consumption of the running containerized application relative to resource limit in range `[0, 1]`. | Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 8.8.0. @@ -125,7 +125,7 @@ The instrument is only available on a system running on containers either on Win | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `container.memory.usage` | ObservableUpDownCounter | `By` | Memory usage of all processes in the container measured in bytes. | +| `container.memory.usage` | | `By` | Memory usage of all processes in the container measured in bytes. | Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 9.8.0. @@ -133,27 +133,27 @@ Available starting in `Microsoft.Extensions.Diagnostics.ResourceMonitoring` 9.8. | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `process.cpu.utilization` | ObservableGauge | `1` | The CPU consumption of the running application in range `[0, 1]`. | +| `process.cpu.utilization` | | `1` | The CPU consumption of the running application in range `[0, 1]`. | -Available starting in: .NET 8.0. +Available starting in: .NET 8. ##### Metric: `dotnet.process.memory.virtual.utilization` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.process.memory.virtual.utilization` | ObservableGauge | `1` | The memory consumption of the running application in range `[0, 1]`. | +| `dotnet.process.memory.virtual.utilization` | | `1` | The memory consumption of the running application in range `[0, 1]`. | -Available starting in: .NET 8.0. +Available starting in: .NET 8. ##### Metric: `system.network.connections` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `system.network.connections` | ObservableUpDownCounter | `{connection}` | Number of network connections by state. | +| `system.network.connections` | | `{connection}` | Number of network connections by state. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `network.type` | string | OSI network layer or non-OSI equivalent. | `ipv4`; `ipv6` | Always | -| `system.network.state` | string | The state of a network connection. | `close`; `listen` | Always | +| Attribute | Type | Description | Examples | Presence | +|------------------------|----------|------------------------------------------|-------------------|----------| +| `network.type` | `string` | OSI network layer or non-OSI equivalent. | `ipv4`; `ipv6` | Always | +| `system.network.state` | `string` | The state of a network connection. | `close`; `listen` | Always | -Available starting in: .NET 8.0. +Available starting in: .NET 8. diff --git a/docs/core/diagnostics/built-in-metrics-runtime.md b/docs/core/diagnostics/built-in-metrics-runtime.md index fab4da8c6e4fc..df043f55e5b5e 100644 --- a/docs/core/diagnostics/built-in-metrics-runtime.md +++ b/docs/core/diagnostics/built-in-metrics-runtime.md @@ -11,7 +11,7 @@ This article describes the built-in metrics for .NET runtime libraries that are API. For a listing of metrics based on the older [EventCounters](event-counters.md) API, see [Available counters](available-counters.md). > [!TIP] -> For more information about how to collect and report these metrics, see [Collecting Metrics](metrics-collection.md). +> For more information about how to collect and report these metrics, see [Collecting metrics](metrics-collection.md). ## `System.Runtime` @@ -19,71 +19,71 @@ The `System.Runtime` Meter reports measurements from the GC, JIT, AssemblyLoader ##### Metric: `dotnet.process.cpu.time` -| Name | Instrument Type | Unit (UCUM) | Description | -| ---- | --------------- | ----------- | ----------- | -| `dotnet.process.cpu.time` | Counter | `s` | CPU time used by the process. | +| Name | Instrument Type | Unit (UCUM) | Description | +|---------------------------|---------------------------------------------|-------------|-------------------------------| +| `dotnet.process.cpu.time` | | `s` | CPU time used by the process. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `cpu.mode` | string | The mode of the CPU. | `user`; `system` | Always | +| Attribute | Type | Description | Examples | Presence | +|------------|----------|----------------------|------------------|----------| +| `cpu.mode` | `string` | The mode of the CPU. | `user`; `system` | Always | This metric reports the same values as accessing the processor time properties on for the current process. The `system` mode corresponds to and `user` mode corresponds to -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.process.memory.working_set` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.process.memory.working_set` | UpDownCounter | `By` | The number of bytes of physical memory mapped to the process context. | +| `dotnet.process.memory.working_set` | | `By` | The number of bytes of physical memory mapped to the process context. | This metric reports the same values as calling property. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.collections` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.gc.collections` | Counter | `{collection}` | The number of garbage collections that have occurred since the process has started. | +| `dotnet.gc.collections` | | `{collection}` | The number of garbage collections that have occurred since the process has started. | | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `gc.heap.generation` | string | Name of the maximum managed heap generation being collected. | `gen0`; `gen1`; `gen2` | Always | +| `gc.heap.generation` | `string` | Name of the maximum managed heap generation being collected. | `gen0`; `gen1`; `gen2` | Always | The .NET GC is a generational garbage collector. Each time the garbage collector runs, it uses heuristics to select a maximum generation and then collects objects in all generations up to the selected maximum. For example, a `gen1` collection collects all objects in generations 0 and 1. A `gen2` collection collects all objects in generations 0, 1, and 2. For more information about the .NET GC and generational garbage collection, see the [.NET garbage collection guide](../../standard/garbage-collection/fundamentals.md#generations). -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.heap.total_allocated` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.gc.heap.total_allocated` | Counter | `By` | The *approximate* number of bytes allocated on the managed GC heap since the process started. The returned value does not include any native allocations. | +| `dotnet.gc.heap.total_allocated` | | `By` | The *approximate* number of bytes allocated on the managed GC heap since the process started. The returned value does not include any native allocations. | This metric reports the same values as calling . For more information about the .NET GC, see the [.NET garbage collection guide](../../standard/garbage-collection/fundamentals.md). -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.last_collection.memory.committed_size` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.gc.last_collection.memory.committed_size` | UpDownCounter | `By` | The amount of committed virtual memory in use by the .NET GC, as observed during the latest garbage collection. | +| `dotnet.gc.last_collection.memory.committed_size` | | `By` | The amount of committed virtual memory in use by the .NET GC, as observed during the latest garbage collection. | This metric reports the same values as calling . Committed virtual memory may be larger than the heap size because it includes both memory for storing existing objects (the heap size) and some extra memory that is ready to handle newly allocated objects in the future. For more information about the .NET GC, see the [.NET garbage collection guide](../../standard/garbage-collection/fundamentals.md). -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.last_collection.heap.size` | Name | Instrument Type | Unit (UCUM) | Description | | ---- | --------------- | ----------- | ----------- | -| `dotnet.gc.last_collection.heap.size` | UpDownCounter | `By` | The managed GC heap size (including fragmentation), as observed during the latest garbage collection. | +| `dotnet.gc.last_collection.heap.size` | | `By` | The managed GC heap size (including fragmentation), as observed during the latest garbage collection. | | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---| -| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | +| `gc.heap.generation` | `string` | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | The .NET GC divides the heap into generations. In addition to the standard numbered generations, the GC also puts some objects into two special generations: @@ -92,17 +92,17 @@ The .NET GC divides the heap into generations. In addition to the standard numbe Both of these special generations are collected during `gen2` GC collections. For more information about the .NET GC, see the [.NET Garbage collection guide](../../standard/garbage-collection/fundamentals.md). -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.last_collection.heap.fragmentation.size` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.gc.last_collection.heap.fragmentation.size` | UpDownCounter | `By` | The heap fragmentation, as observed during the latest garbage collection. | +| `dotnet.gc.last_collection.heap.fragmentation.size` | | `By` | The heap fragmentation, as observed during the latest garbage collection. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `gc.heap.generation` | string | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | +| Attribute | Type | Description | Examples | Presence | +|----------------------|----------|-------------|--------------------------------------|----------| +| `gc.heap.generation` | `string` | Name of the garbage collector managed heap generation. | `gen0`; `gen1`; `gen2`; `loh`; `poh` | Always | This metric reports the same values as calling . @@ -110,25 +110,25 @@ When .NET objects are allocated, initially they tend to be laid out contiguously For more information about how the .NET GC works, analyzing GC performance, and what role fragmentation plays, see [.NET memory performance analysis](https://github.com/Maoni0/mem-doc/blob/master/doc/.NETMemoryPerformanceAnalysis.md). -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.gc.pause.time` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.gc.pause.time` | Counter | `s` | The total amount of time paused in GC since the process started. | +| `dotnet.gc.pause.time` | | `s` | The total amount of time paused in GC since the process started. | This metric reports the same values as calling . Each time the .NET GC does a collection it needs to briefly pause all threads running managed code to determine which objects are still referenced. This metric reports the sum of all these pause times since the process began. You can use this metric to determine what fraction of time threads spend paused for GC versus the time they're able to run managed code. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.jit.compiled_il.size` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.jit.compiled_il.size` | Counter | `By` | Count of bytes of intermediate language that have been compiled since the process started. | +| `dotnet.jit.compiled_il.size` | | `By` | Count of bytes of intermediate language that have been compiled since the process started. | This metric reports the same values as calling . @@ -136,13 +136,13 @@ When you build a .NET app, managed code is initially compiled from a high-level Since JIT compilation occurs the first time a method runs, most JIT compilation tends to occur during application startup. Reducing the amount of IL that is JIT compiled can improve application startup time. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.jit.compiled_methods` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.jit.compiled_methods` | Counter | `{method}` | The number of times the JIT compiler (re)compiled methods since the process started. | +| `dotnet.jit.compiled_methods` | | `{method}` | The number of times the JIT compiler (re)compiled methods since the process started. | This metric reports the same values as calling . @@ -150,13 +150,13 @@ When you build a .NET app, managed code is initially compiled from a high-level Since JIT compilation occurs the first time a method runs, most JIT compilation tends to occur during application startup. Reducing the number of methods that need to be JIT compiled can improve application startup time. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.jit.compilation.time` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.jit.compilation.time` | Counter | `s` | The amount of time the JIT compiler has spent compiling methods since the process started. | +| `dotnet.jit.compilation.time` | | `s` | The amount of time the JIT compiler has spent compiling methods since the process started. | This metric reports the same values as calling . @@ -164,86 +164,86 @@ When you build a .NET app, managed code is initially compiled from a high-level Since JIT compilation occurs the first time a method runs, most JIT compilation tends to occur during application startup. Reducing the time spent JIT compiling can improve application startup time. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.thread_pool.thread.count` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.thread_pool.thread.count` | UpDownCounter | `{thread}` | The number of thread pool threads that currently exist. | +| `dotnet.thread_pool.thread.count` | | `{thread}` | The number of thread pool threads that currently exist. | This metric reports the same values as calling . .NET uses a [thread pool](../../standard/threading/the-managed-thread-pool.md) to schedule work items onto other threads. This metric provides the number of worker threads currently managed by that thread pool. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.thread_pool.work_item.count` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.thread_pool.work_item.count` | Counter | `{work_item}` | The number of work items that the thread pool has completed since the process started. | +| `dotnet.thread_pool.work_item.count` | | `{work_item}` | The number of work items that the thread pool has completed since the process started. | This metric reports the same values as calling . .NET uses a [thread pool](../../standard/threading/the-managed-thread-pool.md) to schedule work items onto other threads. This metric provides the number of work items that have been executed by the thread pool threads. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.thread_pool.queue.length` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.thread_pool.queue.length` | UpDownCounter | `{work_item}` | The number of work items that are currently queued to be processed by the thread pool. | +| `dotnet.thread_pool.queue.length` | | `{work_item}` | The number of work items that are currently queued to be processed by the thread pool. | This metric reports the same values as calling . .NET uses a [thread pool](../../standard/threading/the-managed-thread-pool.md) to schedule work items onto other threads. This metric provides the number of work items that are currently queued to be executed by one of the thread pool threads. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.monitor.lock_contentions` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.monitor.lock_contentions` | Counter | `{contention}` | The number of times there was contention when trying to acquire a monitor lock since the process started. | +| `dotnet.monitor.lock_contentions` | | `{contention}` | The number of times there was contention when trying to acquire a monitor lock since the process started. | This metric reports the same values as calling . .NET supports using any managed object as a lock, either with APIs such as or with the [lock statement](../../csharp/language-reference/statements/lock.md). If one thread already holds a lock while a second thread tries to acquire it, this is called _lock contention_. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.timer.count` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.timer.count` | UpDownCounter | `{timer}` | The number of timer instances that are currently active. | +| `dotnet.timer.count` | | `{timer}` | The number of timer instances that are currently active. | This metric reports the same values as calling . -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.assembly.count` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.assembly.count` | UpDownCounter | `{assembly}` | The number of .NET assemblies that are currently loaded. | +| `dotnet.assembly.count` | | `{assembly}` | The number of .NET assemblies that are currently loaded. | This metric reports the same values as calling and then checking the length of the returned array. -Available starting in: .NET 9.0. +Available starting in: .NET 9. ##### Metric: `dotnet.exceptions` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| `dotnet.exceptions` | Counter | `{exception}` | The number of exceptions that have been thrown in managed code. | +| `dotnet.exceptions` | | `{exception}` | The number of exceptions that have been thrown in managed code. | | Attribute | Type | Description | Examples | Presence | |---|---|---|---|---|---| -| `error.type` | string | The exception type that was thrown. | `System.OperationCanceledException`; `Contoso.MyException` | `Required` | +| `error.type` | `string` | The exception type that was thrown. | `System.OperationCanceledException`; `Contoso.MyException` | `Required` | This metric reports the same values as counting calls to the event. -Available starting in: .NET 9.0. +Available starting in: .NET 9. diff --git a/docs/core/diagnostics/built-in-metrics-system-net.md b/docs/core/diagnostics/built-in-metrics-system-net.md index 275386b3ab45b..75b8b387bb994 100644 --- a/docs/core/diagnostics/built-in-metrics-system-net.md +++ b/docs/core/diagnostics/built-in-metrics-system-net.md @@ -25,28 +25,28 @@ The `System.Net.NameResolution` metrics report DNS name resolution from or indirectly within higher level APIs on types such as . Most errors when doing a DNS lookup throw a . To better disambiguate the common error cases, socket exceptions with specific are given explicit error names in `error.type`: -| SocketErrorCode | `error.type` | -| --------------- | ------------ | -| | host_not_found | -| | try_again | -| | address_family_not_supported | -| | no_recovery | +| SocketErrorCode | `error.type` | +|-----------------------------------------------------------------|--------------------------------| +| | `host_not_found` | +| | `try_again` | +| | `address_family_not_supported` | +| | `no_recovery` | Socket exceptions with any other `SocketError` value are reported as `System.Net.Sockets.SocketException`. When using OpenTelemetry, the default buckets for this metric are set to [ 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 ]. -Available starting in: .NET 8 +Available starting in: .NET 8. ## `System.Net.Http` @@ -62,20 +62,20 @@ The `System.Net.Http` metrics report HTTP request and connection information fro | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| [`http.client.open_connections`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientopen_connections) | UpDownCounter | `{connection}` | Number of outbound HTTP connections that are currently active or idle on the client | +| [`http.client.open_connections`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientopen_connections) | | `{connection}` | Number of outbound HTTP connections that are currently active or idle on the client | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `http.connection.state` | string | State of HTTP connection in the HTTP connection pool. | `active`; `idle` | Always | -| `network.protocol.version` | string | Version of the HTTP protocol used. | `1.1`; `2` | Always | -| `server.address` | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | -| `server.port` | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | -| `network.peer.address` | string | Peer IP address of the socket connection. | `10.5.3.2` | Always | -| `url.scheme` | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | +| Attribute | Type | Description | Examples | Presence | +|----------------------------|----------|-------------------------------------------------------|------------------|----------| +| `http.connection.state` | `string` | State of HTTP connection in the HTTP connection pool. | `active`; `idle` | Always | +| `network.protocol.version` | `string` | Version of the HTTP protocol used. | `1.1`; `2` | Always | +| `server.address` | `string` | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | +| `server.port` | `int` | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | +| `network.peer.address` | `string` | Peer IP address of the socket connection. | `10.5.3.2` | Always | +| `url.scheme` | `string` | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | , when configured to use the default , maintains a cached pool of network connections for sending HTTP messages. This metric counts how many connections are currently in the pool. Active connections are handling active requests. Active connects could be transmitting data or awaiting the client or server. Idle connections aren't handling any requests, but are left open so that future requests can be handled more quickly. -Available starting in: .NET 8 +Available starting in: .NET 8. ##### Metric: `http.client.connection.duration` @@ -83,35 +83,35 @@ Available starting in: .NET 8 | -------- | --------------- | ----------- | -------------- | | [`http.client.connection.duration`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientconnectionduration) | Histogram | `s` | The duration of successfully established outbound HTTP connections. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `network.protocol.version` | string | Version of the HTTP protocol used. | `1.1`; `2` | Always | -| `server.address` | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | -| `server.port` | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | -| `network.peer.address` | string | IP address of the socket connection. | `10.5.3.2` | Always | -| `url.scheme` | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | +| Attribute | Type | Description | Examples | Presence | +|----------------------------|----------|------------------------------------|------------|----------| +| `network.protocol.version` | `string` | Version of the HTTP protocol used. | `1.1`; `2` | Always | +| `server.address` | `string` | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | +| `server.port` | `int` | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | +| `network.peer.address` | `string` | IP address of the socket connection. | `10.5.3.2` | Always | +| `url.scheme` | `string` | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | This metric is only captured when is configured to use the default . As this metric is tracking the connection duration, and ideally http connections are used for multiple requests, the buckets should be longer than those used for request durations. For example, using [ 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300 ] provides an upper bucket of 5 mins. -Available starting in: .NET 8 +Available starting in: .NET 8. ##### Metric: `http.client.request.duration` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| [`http.client.request.duration`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpserverrequestduration) | Histogram | `s` | The duration of outbound HTTP requests. | - -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `error.type` | string | Request failure reason: one of the [HTTP request errors](xref:System.Net.Http.HttpRequestError) in snake_case, or a full exception type, or an HTTP 4xx/5xx status code. | `System.Threading.Tasks.TaskCanceledException`; `name_resolution_error`; `secure_connection_error` ; `404` | If request has failed. | -| `http.request.method` | string | HTTP request method. | `GET`; `POST`; `HEAD`; `_OTHER` [2] | Always | -| `http.response.status_code` | int | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | If response was received. | -| `network.protocol.version` | string | Version of the HTTP protocol used. | `1.1`; `2` | If response was received. | -| `server.address` | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | -| `server.port` | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | Depends on .NET version. [3] | -| `url.scheme` | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | +| [`http.client.request.duration`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpserverrequestduration) | | `s` | The duration of outbound HTTP requests. | + +| Attribute | Type | Description | Examples | Presence | +|-----------------------|----------|----------------------|-------------------------------------|----------| +| `error.type` | `string` | Request failure reason: one of the [HTTP request errors](xref:System.Net.Http.HttpRequestError) in snake_case, or a full exception type, or an HTTP 4xx/5xx status code. | `System.Threading.Tasks.TaskCanceledException`; `name_resolution_error`; `secure_connection_error` ; `404` | If request has failed. | +| `http.request.method` | `string` | HTTP request method. | `GET`; `POST`; `HEAD`; `_OTHER` [2] | Always | +| `http.response.status_code` | `int` | [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). | `200` | If response was received. | +| `network.protocol.version` | `string` | Version of the HTTP protocol used. | `1.1`; `2` | If response was received. | +| `server.address` | `string` | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | +| `server.port` | `int` | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | Depends on .NET version. [3] | +| `url.scheme` | `string` | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | **[1] `error.type`:** If the request has failed, the value is set to one of the following: @@ -130,7 +130,7 @@ HTTP client request duration measures the time the underlying client handler tak When using OpenTelemetry, the default buckets for this metric are set to [ 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 ]. -Available starting in: .NET 8 +Available starting in: .NET 8. > [!TIP] > [Enrichment](../../fundamentals/networking/telemetry/metrics.md#enrichment) is possible for this metric. @@ -139,33 +139,33 @@ Available starting in: .NET 8 | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| [`http.client.request.time_in_queue`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientrequesttime_in_queue) | Histogram | `s` | The amount of time requests spent on a queue waiting for an available connection. | +| [`http.client.request.time_in_queue`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpclientrequesttime_in_queue) | | `s` | The amount of time requests spent on a queue waiting for an available connection. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `http.request.method` | string | HTTP request method. | `GET`; `POST`; `HEAD` | Always | -| `network.protocol.version` | string | Version of the HTTP protocol used. | `1.1`; `2` | Always | -| `server.address` | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | -| `server.port` | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | -| `url.scheme` | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | +| Attribute | Type | Description | Examples | Presence | +|----------------------------|----------|------------------------------------|-----------------------|----------| +| `http.request.method` | `string` | HTTP request method. | `GET`; `POST`; `HEAD` | Always | +| `network.protocol.version` | `string` | Version of the HTTP protocol used. | `1.1`; `2` | Always | +| `server.address` | `string` | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | +| `server.port` | `int` | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | +| `url.scheme` | `string` | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | , when configured to use the default , sends HTTP requests using a pool of network connections. If all connections are busy handling other requests, new requests are placed in a queue and wait until a network connection is available for use. This instrument measures the amount of time HTTP requests spend waiting in that queue, prior to anything being sent across the network. -Available starting in: .NET 8 +Available starting in: .NET 8. ##### Metric: `http.client.active_requests` | Name | Instrument Type | Unit (UCUM) | Description | | -------- | --------------- | ----------- | -------------- | -| [`http.client.active_requests`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpserveractive_requests) | UpDownCounter | `{request}` | Number of active HTTP requests. | +| [`http.client.active_requests`](https://opentelemetry.io/docs/specs/semconv/dotnet/dotnet-http-metrics/#metric-httpserveractive_requests) | | `{request}` | Number of active HTTP requests. | -| Attribute | Type | Description | Examples | Presence | -|---|---|---|---|---| -| `http.request.method` | string | HTTP request method. | `GET`; `POST`; `HEAD` | Always | -| `server.address` | string | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | -| `server.port` | int | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | -| `url.scheme` | string | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | +| Attribute | Type | Description | Examples | Presence | +|-----------------------|----------|----------------------|-----------------------|----------| +| `http.request.method` | `string` | HTTP request method. | `GET`; `POST`; `HEAD` | Always | +| `server.address` | `string` | Host identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `example.com` | Always | +| `server.port` | `int` | Port identifier of the ["URI origin"](https://www.rfc-editor.org/rfc/rfc9110.html#name-uri-origin) HTTP request is sent to. | `80`; `8080`; `443` | If not default (`80` for `http` scheme, `443` for `https`) | +| `url.scheme` | `string` | The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. | `http`; `https`; `ftp` | Always | This metric counts how many requests are considered active. Requests are active for the same time period that is measured by the [http.client.request.duration](#metric-httpclientrequestduration) instrument. -Available starting in: .NET 8 +Available starting in: .NET 8. diff --git a/docs/core/diagnostics/metrics-collection.md b/docs/core/diagnostics/metrics-collection.md index f041c4a03c223..0c46afb63aaff 100644 --- a/docs/core/diagnostics/metrics-collection.md +++ b/docs/core/diagnostics/metrics-collection.md @@ -214,7 +214,7 @@ hats-sold recorded measurement 912 ... ``` -### Explaining the sample code +### Sample code explanation The code snippets in this section come from the preceding sample.