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

Conversation

xrmx
Copy link
Contributor

@xrmx xrmx commented Feb 24, 2025

Fixes #1930

Changes

This adds 3 new metrics to track CPython runtime garbage collector work.

Note: if the PR is touching an area that is not listed in the existing areas, or the area does not have sufficient domain experts coverage, the PR might be tagged as experts needed and move slowly until experts are identified.

Merge requirement checklist

@trask
Copy link
Member

trask commented Feb 24, 2025

cc @open-telemetry/python-approvers @open-telemetry/opentelemetry-python-contrib-approvers

@xrmx xrmx force-pushed the python-runtime-metrics branch from e52b14a to 039cd81 Compare March 6, 2025 20:42
@xrmx xrmx force-pushed the python-runtime-metrics branch from 039cd81 to f9c7a06 Compare March 6, 2025 20:43
@kamalmarhubi
Copy link
Contributor

Drive-by from seeing this in the #otel-python channel on cncf slack. We recently implemented a metric like this, so I'd be quite happy to see this make its way into semconv / the python contrib repo.

We also added spans for gen2 collections, which helped us understand some gaps in our slow traces, and figure out we could improve tail latencies by calling gc.collect(generation=2) between handling requests in our synchronous web workers, as in this Rippling blog post.

Copy link
Contributor

@lmolkova lmolkova left a comment

Choose a reason for hiding this comment

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

LGTM!

xrmx and others added 2 commits March 7, 2025 16:20
Co-authored-by: Liudmila Molkova <[email protected]>
Comment on lines +10 to +23
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
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


- id: metric.cpython.gc.collected.objects
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

- ref: cpython.gc.generation
requirement_level: required

- id: metric.cpython.gc.uncollectable.objects
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- id: metric.cpython.gc.uncollectable.objects
- id: metric.cpython.gc.uncollectable_objects

Comment on lines +10 to +23
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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs More Approval
Development

Successfully merging this pull request may close these issues.

CPython runtime gc metrics
5 participants