Skip to content

Add standalone CPython GC metrics through existing OpenTelemetry collection #46732

Open

Description

@QuantumGhost

AI disclosure: This issue was drafted with Codex using gpt-6.1-sol. The author is responsible for reviewing and approving the final content.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

We need to compare cyclic-GC frequency, cumulative collection elapsed time and pause distributions by process/Pod under real workloads, including blue/green deployments. These observations should be available independently of changes to GC behavior, so enabling metrics does not require enabling gc.freeze() or changing GC thresholds.

Requested behavior:

  • Enable GC telemetry through the existing ENABLE_OTEL configuration, metric collection/export cycle and collector.
  • Reuse SystemMetricsInstrumentor for native per-generation collection, collected-object and uncollectable-object counters.
  • Record collection elapsed time with lightweight gc.callbacks, and expose duration histograms, scheduling counters, thresholds and automatic-GC state.
  • Keep callback work free of I/O and SDK recording/export. Buffer duration samples with a bounded capacity for each generation, preserving Gen2 samples during bursts of young-generation collections, and report dropped samples per generation.
  • Avoid heap walks, manual collections, GC tuning, additional publisher threads, metrics services and HTTP endpoints.

2. Additional context or comments

Implementation: #46693.

The metrics originated in #46432. This issue tracks their standalone extraction, including the per-generation buffer fix in fac16a79ed3ad2e80b4fdc6875a8bf81bb3fbaeb. GC freeze and other behavior optimizations remain outside its scope.

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions