Skip to content

Commit

Permalink
Add CPU metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Aug 5, 2024
1 parent 1aefc29 commit 5d63a8f
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
106 changes: 106 additions & 0 deletions docs/runtime/dotnet-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ This document describes semantic conventions for .NET CLR runtime metrics in Ope
- [Metric: `dotnet.thread_pool.thread.count`](#metric-dotnetthread_poolthreadcount)
- [Metric: `dotnet.thread_pool.work_item.count`](#metric-dotnetthread_poolwork_itemcount)
- [Metric: `dotnet.thread_pool.queue.length`](#metric-dotnetthread_poolqueuelength)
- [CPU](#cpu)
- [Metric: `dotnet.cpu.count`](#metric-dotnetcpucount)
- [Metric: `dotnet.cpu.time`](#metric-dotnetcputime)
- [General](#general)
- [Metric: `dotnet.monitor.lock_contentions`](#metric-dotnetmonitorlock_contentions)
- [Metric: `dotnet.timer.count`](#metric-dotnettimercount)
Expand Down Expand Up @@ -588,6 +591,109 @@ This metric is [recommended][MetricRecommended].
<!-- markdownlint-disable -->


<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## CPU

**Status**: [Experimental][DocumentStatus]

**Description:** .NET Common Language Runtime (CLR) metrics captured under the namespace `dotnet.cpu.*`.

_Note: These metrics represent CPU information from the perspective of the .NET process and may differ from
CPU metrics measured from outside the process (e.g. `system.cpu.*`)._

### Metric: `dotnet.cpu.count`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.dotnet.cpu.count(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `dotnet.cpu.count` | UpDownCounter | `{cpu}` | The number of processors available to the process. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |


**[1]:** This metric reports the same values as accessing [`Environment.ProcessorCount`](https://learn.microsoft.com/dotnet/api/system.environment.processorcount).



<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

<!-- semconv metric.dotnet.cpu.count(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->


<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

### Metric: `dotnet.cpu.time`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.dotnet.cpu.time(metric_table) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `dotnet.cpu.time` | Counter | `s` | CPU time used by the process as reported by the CLR. [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |


**[1]:** This metric reports the same values as accessing the corresponding processor time properties on [`System.Diagnostics.Process`](https://learn.microsoft.com/dotnet/api/system.diagnostics.process)."



<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

<!-- semconv metric.dotnet.cpu.time(full) -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`cpu.mode`](/docs/attributes-registry/cpu.md) | string | The mode of the CPU | `user`; `system` | `Required` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

`cpu.mode` 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.

| Value | Description | Stability |
|---|---|---|
| `idle` | idle | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `interrupt` | interrupt | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `iowait` | iowait | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `kernel` | kernel | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `nice` | nice | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `steal` | steal | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `system` | system | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `user` | user | ![Experimental](https://img.shields.io/badge/-experimental-blue) |



<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand Down
23 changes: 23 additions & 0 deletions model/metrics/dotnet-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,26 @@ groups:
attributes:
- ref: error.type
requirement_level: required

- id: metric.dotnet.cpu.count
type: metric
metric_name: dotnet.cpu.count
brief: "The number of processors available to the process."
note: "This metric reports the same values as accessing [`Environment.ProcessorCount`](https://learn.microsoft.com/dotnet/api/system.environment.processorcount)."
instrument: updowncounter
unit: "{cpu}"
stability: experimental

- id: metric.dotnet.cpu.time
type: metric
metric_name: dotnet.cpu.time
brief: "CPU time used by the process as reported by the CLR."
note: >
This metric reports the same values as accessing the corresponding
processor time properties on [`System.Diagnostics.Process`](https://learn.microsoft.com/dotnet/api/system.diagnostics.process)."
instrument: counter
unit: "s"
stability: experimental
attributes:
- ref: cpu.mode
requirement_level: required

0 comments on commit 5d63a8f

Please sign in to comment.