Skip to content

Commit

Permalink
Add container.cpu.usage metric
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <[email protected]>
  • Loading branch information
ChrsMark committed Jun 12, 2024
1 parent 53d5244 commit af97de0
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/add_container_cpu_usage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Use this changelog template to create an entry for release notes.
#
# If your change doesn't affect end users you should instead start
# your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
component: container

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add container.cpu.usage metric

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
# The values here must be integers.
issues: []

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
51 changes: 51 additions & 0 deletions docs/system/container-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,57 @@ This metric is [opt-in][MetricOptIn].



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

### Metric: `container.cpu.usage`

This metric is [opt-in][MetricOptIn].

<!-- semconv metric.container.cpu.usage(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 |
| -------- | --------------- | ----------- | -------------- | --------- |
| `container.cpu.usage` | Gauge | `{cpu}` | CPU usage [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |


**[1]:** CPU usage of the specific container on all available CPU cores, averaged over the sample window



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

<!-- semconv metric.container.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 |
|---|---|---|---|---|---|
| [`container.cpu.state`](/docs/attributes-registry/container.md) | string | The CPU state for this data point. A container SHOULD be characterized _either_ by data points with no `state` labels, _or only_ data points with `state` labels. | `user`; `kernel` | `Opt-In` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

`container.cpu.state` 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 |
|---|---|---|
| `kernel` | When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel mode (Windows). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `system` | When CPU is used by the system (host OS) | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| `user` | When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode (Windows). | ![Experimental](https://img.shields.io/badge/-experimental-blue) |



<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand Down
14 changes: 14 additions & 0 deletions model/metrics/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ groups:
brief: "The CPU state for this data point. A container SHOULD be characterized _either_ by data points with no `state` labels, _or only_ data points with `state` labels."
requirement_level: opt_in

- id: metric.container.cpu.usage
type: metric
metric_name: container.cpu.usage
stability: experimental
brief: "CPU usage"
note: >
CPU usage of the specific container on all available CPU cores, averaged over the sample window
instrument: gauge
unit: "{cpu}"
attributes:
- ref: container.cpu.state
brief: "The CPU state for this data point. A container SHOULD be characterized _either_ by data points with no `state` labels, _or only_ data points with `state` labels."
requirement_level: opt_in

# container.memory.* metrics and attribute group
- id: metric.container.memory.usage
type: metric
Expand Down

0 comments on commit af97de0

Please sign in to comment.