Skip to content

feat(attributes): Add Android Runtime (ART) GC and memory attributes#382

Open
markushi wants to merge 7 commits into
mainfrom
feat/art-gc-attributes
Open

feat(attributes): Add Android Runtime (ART) GC and memory attributes#382
markushi wants to merge 7 commits into
mainfrom
feat/art-gc-attributes

Conversation

@markushi
Copy link
Copy Markdown
Member

@markushi markushi commented May 15, 2026

Summary

Adds Android Runtime (ART) garbage collection and memory attributes for tracking GC activity and memory usage on Android. Similar to the existing jvm and dotnet top-level event context attributes.

GC attributes (art.gc.*)

  • art.gc.blocking_count / art.gc.blocking_time — blocking (stop-the-world) GC
  • art.gc.total_count / art.gc.total_time — all GC activity
  • art.gc.waiting_time — time threads spent waiting for GC
  • art.gc.pre_oome_count — last-resort GCs before OutOfMemoryError

Memory attributes (art.memory.*)

  • art.memory.free — free memory available to the process
  • art.memory.free_until_gc — free memory before GC would trigger
  • art.memory.free_until_oome — free memory before OOM
  • art.memory.total / art.memory.max — allocated and max memory

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

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 ✨

Docs

  • Add links to deprecated and aliased attributes by Lms24 in #396
  • Add filtering capability by nsdeschenes in #395

Other

  • (attributes) Add Android Runtime (ART) GC and memory attributes by markushi in #382

Bug Fixes 🐛

  • Change type of sentry.dsc.project_id to string by elramen in #400

🤖 This preview updates automatically when you update the PR.

@markushi markushi marked this pull request as ready for review May 15, 2026 07:39
@markushi markushi requested review from a team, Lms24, cleptric, mjq and nsdeschenes as code owners May 15, 2026 07:39
@markushi markushi requested a review from a team May 15, 2026 07:55
Copy link
Copy Markdown
Contributor

@buenaflor buenaflor left a comment

Choose a reason for hiding this comment

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

I wonder if we should further split it into sub namespaces e.g

art.gc_blocking.count vs art.gc.blocking.count

@markushi
Copy link
Copy Markdown
Member Author

I wonder if we should further split it into sub namespaces e.g

art.gc_blocking.count vs art.gc.blocking.count

I've split them into art.gc and art.memory

markushi and others added 4 commits May 15, 2026 16:36
Add top-level runtime.* attributes mapping to the Sentry runtime context:
runtime.name, runtime.version, runtime.build, and runtime.raw_description.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 11 new attributes under the `art` namespace for Android Runtime
garbage collection stats and memory info, parsed from ANR thread dumps.

GC attributes: gc_total_count, gc_total_time, gc_blocking_count,
gc_blocking_time, gc_pre_oome_count, gc_waiting_time

Memory attributes: free_memory, free_memory_until_gc,
free_memory_until_oome, total_memory, max_memory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename ART attribute keys to use dot-separated sub-namespaces,
consistent with existing patterns like jvm.gc.*, jvm.memory.*, and
browser.web_vital.*. GC attributes move under art.gc.* and memory
attributes under art.memory.*, with a max nesting depth of 2 dots.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…espace

Rename art.* attributes to runtime.art.* to nest them under the runtime
context namespace. This aligns with the runtime context attribute structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@markushi markushi force-pushed the feat/art-gc-attributes branch from 6265928 to 4ee2e0c Compare May 15, 2026 14:40
@markushi markushi changed the title feat(attributes): Add Android Runtime (ART) GC and memory attributes feat(attributes): Add Android Runtime (ART) GC and memory attributes under runtime namespace May 15, 2026
@markushi markushi marked this pull request as draft May 15, 2026 14:52
@markushi
Copy link
Copy Markdown
Member Author

Moving back to draft for now, as we need to sort out the "runtime" vs. "process.runtime" discussion first.

@buenaflor
Copy link
Copy Markdown
Contributor

From what I can tell otel also prefers setting runtime specifics into its own namespace e.g

dotnet.gc.heap.total_allocated, jvm.gc.duration (and we also follow this with jvm)

It looks like art.gc.xyz fits as well

@buenaflor
Copy link
Copy Markdown
Contributor

what do you think of this, I had 🤖 run through the GC and Memory attributes of OTEL runtime conventions to check how we can align with naming:

Key Description OTel alignment
art.memory.free Free heap memory available to the process ART-specific; V8 has available_size
art.memory.free_until_gc Free memory before next GC triggers ART-specific; Go has go.memory.gc.goal (target, not headroom)
art.memory.free_until_oome Free memory before OutOfMemoryError ART-specific
art.memory.committed Heap currently allocated to the process Matches jvm.memory.committed, .NET committed_size
art.memory.limit Maximum heap size the process can grow to Matches jvm.memory.limit, go.memory.limit
art.gc.collections Total GC collections since process start Matches dotnet.gc.collections, go.memory.gc.cycles
art.gc.duration Cumulative GC time since process start Matches jvm.gc.duration, v8js.gc.duration (leaf name)
art.gc.blocking_collections Stop-the-world GC collections since process start ART-specific; JVM uses jvm.gc.action attribute instead
art.gc.blocking_duration Cumulative stop-the-world GC time since process start ART-specific; closest to go.memory.gc.pause.duration
art.gc.pre_oome_collections Last-resort GC attempts to prevent OOM ART-specific
art.gc.wait_duration Cumulative thread wait time due to GC ART-specific

markushi added a commit to getsentry/sentry-java that referenced this pull request May 15, 2026
Use dotted attribute names (e.g. gc.total_count, memory.free) to match
the sentry-conventions schema from getsentry/sentry-conventions#382.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ART GC and memory attributes under the `art` namespace with dotted
sub-namespaces (`art.gc.*`, `art.memory.*`). Remove incorrectly added
top-level `runtime` context attributes. Add required `visibility: public`
field to all ART attributes. Regenerate code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@markushi markushi changed the title feat(attributes): Add Android Runtime (ART) GC and memory attributes under runtime namespace feat(attributes): Add Android Runtime (ART) GC and memory attributes May 26, 2026
@markushi markushi marked this pull request as ready for review May 26, 2026 10:11
@markushi
Copy link
Copy Markdown
Member Author

I decided to move these new attributes into a top-level art namespace, similar to existing platform specific attributes (go.*, jvm.*, dotnet.*). It's worth pointing out that these attributes will be used within the event.contexts protocol (as opposed to the span.data bag)

@markushi markushi requested a review from buenaflor May 26, 2026 10:13
isInOtel: false,
visibility: 'public',
example: 1,
sdks: ['sentry.java.android'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need to mention hybrid SDKs for all these, too?

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.

3 participants