Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPython runtime garbage collections metrics #1931

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
22 changes: 22 additions & 0 deletions .chloggen/cpython-runtime-gc.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: new_component

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add CPython runtime garbage collector metrics

# 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: [1930]

# (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:
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ body:
- area:code
- area:container
- area:cpu
- area:cpython
- area:db
- area:deployment
- area:destination
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/change_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ body:
- area:code
- area:container
- area:cpu
- area:cpython
- area:db
- area:deployment
- area:destination
Expand Down
1 change: 1 addition & 0 deletions docs/attributes-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Currently, the following namespaces exist:
- [Code](code.md)
- [Container](container.md)
- [CPU](cpu.md)
- [CPython](cpython.md)
- [DB](db.md)
- [Deployment](deployment.md)
- [Destination](destination.md)
Expand Down
22 changes: 22 additions & 0 deletions docs/attributes-registry/cpython.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- NOTE: THIS FILE IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/attribute_namespace.md.j2 -->

# CPython

## CPython attributes

This document defines CPython related attributes.

| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| <a id="cpython-gc-generation" href="#cpython-gc-generation">`cpython.gc.generation`</a> | string | Name of the garbage collector collection generation. | `gen0`; `gen1`; `gen2` | ![Development](https://img.shields.io/badge/-development-blue) |

---

`cpython.gc.generation` 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 |
|---|---|---|
| `gen0` | Generation 0 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen1` | Generation 1 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen2` | Generation 2 | ![Development](https://img.shields.io/badge/-development-blue) |
1 change: 1 addition & 0 deletions docs/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Also consider the
[OS process metrics](/docs/system/process-metrics.md)
semantic conventions when instrumenting runtime environments.

- [CPython](cpython-metrics.md)
- [Go](go-metrics.md)
- [JVM](jvm-metrics.md)
- [Node.js](nodejs-metrics.md)
Expand Down
135 changes: 135 additions & 0 deletions docs/runtime/cpython-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!--- Hugo front matter used to generate the website version of this page:
linkTitle: CPython
--->

# Semantic conventions for CPython runtime metrics

**Status**: [Development][DocumentStatus]

This document describes semantic conventions for CPython Runtime metrics in OpenTelemetry.

<!-- toc -->

- [CPython Garbage Collection](#cpython-garbage-collection)
- [Metric: `cpython.gc.collections`](#metric-cpythongccollections)
- [Metric: `cpython.gc.collected`](#metric-cpythongccollected)
- [Metric: `cpython.gc.uncollectable`](#metric-cpythongcuncollectable)

<!-- tocstop -->

## CPython Garbage Collection

**Status**: [development][DocumentStatus]

**Description:** CPython metrics related to garbage collection, captured under the namespace `cpython.gc.*`.

### Metric: `cpython.gc.collections`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.cpython.gc.collections -->
<!-- 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 |
| -------- | --------------- | ----------- | -------------- | --------- |
| `cpython.gc.collections` | Counter | `{collection}` | The number of times a generation was collected since interpreter start. [1] | ![Development](https://img.shields.io/badge/-development-blue) |

**[1]:** This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`cpython.gc.generation`](/docs/attributes-registry/cpython.md) | string | Name of the garbage collector collection generation. | `gen0`; `gen1`; `gen2` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |

---

`cpython.gc.generation` 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 |
|---|---|---|
| `gen0` | Generation 0 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen1` | Generation 1 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen2` | Generation 2 | ![Development](https://img.shields.io/badge/-development-blue) |

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

### Metric: `cpython.gc.collected`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.cpython.gc.collected -->
<!-- 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 |
| -------- | --------------- | ----------- | -------------- | --------- |
| `cpython.gc.collected.objects` | Counter | `{object}` | The total number of objects collected inside a generation that have occurred since interpreter start. [1] | ![Development](https://img.shields.io/badge/-development-blue) |

**[1]:** This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`cpython.gc.generation`](/docs/attributes-registry/cpython.md) | string | Name of the garbage collector collection generation. | `gen0`; `gen1`; `gen2` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |

---

`cpython.gc.generation` 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 |
|---|---|---|
| `gen0` | Generation 0 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen1` | Generation 1 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen2` | Generation 2 | ![Development](https://img.shields.io/badge/-development-blue) |

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

### Metric: `cpython.gc.uncollectable`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.cpython.gc.uncollectable -->
<!-- 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 |
| -------- | --------------- | ----------- | -------------- | --------- |
| `cpython.gc.uncollectable.objects` | Counter | `{object}` | The total number of uncollectable objects inside a generation that have occurred since interpreter start. [1] | ![Development](https://img.shields.io/badge/-development-blue) |

**[1]:** This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`cpython.gc.generation`](/docs/attributes-registry/cpython.md) | string | Name of the garbage collector collection generation. | `gen0`; `gen1`; `gen2` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |

---

`cpython.gc.generation` 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 |
|---|---|---|
| `gen0` | Generation 0 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen1` | Generation 1 | ![Development](https://img.shields.io/badge/-development-blue) |
| `gen2` | Generation 2 | ![Development](https://img.shields.io/badge/-development-blue) |

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

[DocumentStatus]: https://github.com/open-telemetry/opentelemetry-specification/tree/v1.42.0/specification/document-status.md
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended
2 changes: 1 addition & 1 deletion docs/runtime/v8js-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ of `[ 0.01, 0.1, 1, 10 ]`.
| -------- | --------------- | ----------- | -------------- | --------- |
| `v8js.gc.duration` | Histogram | `s` | Garbage collection duration. [1] | ![Development](https://img.shields.io/badge/-development-blue) |

**[1]:** The values can be retrieve from [`perf_hooks.PerformanceObserver(...).observe({ entryTypes: ['gc'] })`](https://nodejs.org/api/perf_hooks.html#performanceobserverobserveoptions)
**[1]:** The values can be retrieved from [`perf_hooks.PerformanceObserver(...).observe({ entryTypes: ['gc'] })`](https://nodejs.org/api/perf_hooks.html#performanceobserverobserveoptions)

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
Expand Down
39 changes: 39 additions & 0 deletions model/cpython/metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
groups:
- id: metric.cpython.gc.collections
type: metric
metric_name: cpython.gc.collections
brief: "The number of times a generation was collected since interpreter start."
note: >
This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)
instrument: counter
unit: "{collection}"
stability: development
attributes:
- ref: cpython.gc.generation
requirement_level: required

- id: metric.cpython.gc.collected
type: metric
metric_name: cpython.gc.collected.objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this fits the "adjective_noun" guidance, see #1755 (comment)

Suggested change
metric_name: cpython.gc.collected.objects
metric_name: cpython.gc.collected_objects

brief: "The total number of objects collected inside a generation that have occurred since interpreter start."
note: >
This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)
instrument: counter
unit: "{object}"
stability: development
attributes:
- ref: cpython.gc.generation
requirement_level: required

- id: metric.cpython.gc.uncollectable
type: metric
metric_name: cpython.gc.uncollectable.objects
brief: "The total number of uncollectable objects inside a generation that have occurred since interpreter start."
note: >
This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats)
instrument: counter
unit: "{object}"
stability: development
attributes:
- ref: cpython.gc.generation
requirement_level: required
25 changes: 25 additions & 0 deletions model/cpython/registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
groups:
- id: registry.cpython
type: attribute_group
display_name: CPython attributes
brief: >
This document defines CPython related attributes.
attributes:
- id: cpython.gc.generation
stability: development
type:
members:
- id: gen0
value: 'gen0'
brief: "Generation 0"
stability: development
- id: gen1
value: 'gen1'
brief: "Generation 1"
stability: development
- id: gen2
value: 'gen2'
brief: "Generation 2"
stability: development
Comment on lines +10 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xrmx one quick question: is there specific rationale behind the enum gen0, gen1, gen2 vs just an integer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are gen0, gen1, gen2 common names for these generations in cpython? I didn't have much too luck in google: https://www.google.com/search?q=%22gen0%22+%22gen1%22+%22gen2%22+cpython

brief: Name of the garbage collector collection generation.
examples: ["gen0", "gen1", "gen2"]
2 changes: 1 addition & 1 deletion model/v8js/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ groups:
- ref: v8js.gc.type
requirement_level: required
note: >
The values can be retrieve from [`perf_hooks.PerformanceObserver(...).observe({ entryTypes: ['gc'] })`](https://nodejs.org/api/perf_hooks.html#performanceobserverobserveoptions)
The values can be retrieved from [`perf_hooks.PerformanceObserver(...).observe({ entryTypes: ['gc'] })`](https://nodejs.org/api/perf_hooks.html#performanceobserverobserveoptions)

- id: metric.v8js.memory.heap.limit
type: metric
Expand Down
1 change: 1 addition & 0 deletions templates/registry/markdown/weaver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ acronyms:
- CloudEvents
- CloudFoundry
- CLR
- CPython
- CPU
- CSI
- DB
Expand Down
Loading