Skip to content

feat(attributes): Add CPython garbage collection conventions - #719

Draft
sentrivana wants to merge 1 commit into
mainfrom
ivana/cpython-gc
Draft

sentrivana wants to merge 1 commit into
mainfrom
ivana/cpython-gc

Conversation

@sentrivana

@sentrivana sentrivana commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds conventions for spans that represent a run of the CPython garbage collector. These will be emitted by an upcoming GC integration in the Python SDK, which hooks into gc.callbacks and creates a child span of the active span for each (by default: full) collection.

Attributes (model/attributes/cpython/, all integers):

  • cpython.gc.generation: the generation that was collected. Defined in OTel, so is_in_otel: true. Has a note about free-threaded builds, where the GC isn't generational: every collection is a full one, automatic collections report generation 0.
  • cpython.gc.collected_objects: the number of objects collected in a single run.
  • cpython.gc.uncollectable_objects: the number of uncollectable objects found in a single run.

OTel only defines cpython.gc.collected_objects and cpython.gc.uncollectable_objects as counter metrics (totals since interpreter start), not as attributes, so the two count attributes are is_in_otel: false and have a note pointing out the difference.

Op: a new runtime category with a gc op. None of the existing categories fit, and other runtime ops could live there in the future.

Span name: a runtime name convention mapping the gc op to the static name Garbage collection.

PR Checklist

  • I have run yarn test and verified that the tests pass.
  • I have run yarn generate to generate and format code and docs.

If an attribute was added:

  • The attribute is in a namespace (e.g. nextjs.function_id, not function_id)
  • I have used the correct value for apply_scrubbing (i.e. manual or auto. Use never only for values that should never be scrubbed such as IDs)

Add conventions for spans that represent a run of the CPython garbage
collector, to be emitted by an upcoming GC integration in the Python SDK.

- cpython.gc.generation: the generation that was collected. Defined in
  OTel, so it's added with is_in_otel: true.
- cpython.gc.collected_objects and cpython.gc.uncollectable_objects: the
  object counts of a single run. OTel only has counter metrics with these
  names, which track totals since interpreter start.
- A new `runtime` op category with a `gc` op.
- A span name convention for `gc` spans: "Garbage collection".
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-conventions Ready Ready Preview Oct 14, 2026 2:46pm UTC

Request Review

@github-actions

Copy link
Copy Markdown

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Attributes

  • Add CPython garbage collection conventions by sentrivana in #719
  • Add http.request.duration by loewenheim in #697

Bug Fixes 🐛

  • (attributes) Apply consistent scrubbing across deprecations by mjq in #692

Internal Changes 🔧

  • (repo) Update CODEOWNERS to include @giortzisg by Lms24 in #708

🤖 This preview updates automatically when you update the PR.

This branch was successfully deployed

1 active deployment
Preview — 0fe9f45f Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant