getsentry / getsentry/sentry-javascript
feat(node): Add garbage collection metrics to NodeRuntimeMetrics
- Dominant language
- TypeScript
- Stars
- 8.7k
- Forks
- 1.8k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 515
Description
### Description
`NodeRuntimeMetrics` already collects heap, RSS, event loop delay, and ELU, but has no visibility into GC — often the direct cause of event-loop stalls and tail latency.
Add GC pause metrics collected via a `perf_hooks` `PerformanceObserver` on `gc` entries, aggregated over the existing collection interval:
- `gc.pause.duration` (total/avg pause time)
- `gc.pause.max` or `gc.pause.p95` (worst pause in the window)
- `gc.count` broken down by kind (minor/scavenge vs major/mark-sweep)
Opt-in by default, consistent with the other advanced metrics in the `collect` option. Aligns with the OTel `process.runtime.v8js.gc.*` conventions.
Contributor guide
Research direction
Start at the NodeRuntimeMetrics implementation and its existing collection interval and advanced collect options. Read the Node.js perf_hooks PerformanceObserver documentation for gc entries, then trace how current heap, RSS, event-loop delay, and ELU metrics are aggregated. Done means GC pause totals and an aggregate worst-pause metric are reported, with counts split by minor and major collection kind.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100