[Part 4/6] feat(telemetry): add memory monitor with activity-aware recording and tests#8122
Conversation
f689e49 to
2bd6cc1
Compare
|
@jacob314 @joshualitt PR 4 Ready for Review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive MemoryMonitor for telemetry, featuring activity-aware recording, high-water mark tracking, and rate limiting. The implementation is well-structured and includes a thorough test suite. My review focuses on improving the testability of the singleton pattern and the robustness and clarity of the tests to ensure long-term maintainability.
2bd6cc1 to
75744ac
Compare
|
Thanks for the PR! Thoughts on periodically calling the cleanup() methods on |
75744ac to
bcf71bc
Compare
Great call on proactively cleaning up the tracker state. I've improved it, the latest commit now schedules periodic pruning of both the high-water mark tracker and the rate limiter, so even if we start emitting dynamic keys we won’t leak memory. While we were in there, we finished aligning the memory monitor with PR #10215 schema update, so the new metric attributes flow end-to-end. Tests are still all green. |
…cording and tests (google-gemini#8122) Co-authored-by: Jacob Richman <jacob314@gmail.com>

Summary
Adds comprehensive MemoryMonitor that provides activity-aware memory tracking, automatic lifecycle management, and integration APIs for global monitoring. Uses components from Parts 1-3 for intelligent recording strategies.
Dependencies
Review Order: Please review Parts 1-3 first (#8110, #8111, #8113), then this PR.
Related PRs - Enhanced Performance Monitoring Split
This is Part 4 of 6 in the split implementation of #2127:
Changes in This PR
MemoryMonitor (
packages/core/src/telemetry/memory-monitor.ts)Complete memory monitoring solution with activity-aware recording, high-water mark tracking, rate limiting with priority bypass, and comprehensive metrics including heap used, heap total, RSS, and external memory.
Memory Snapshot Types
ProcessMetrics and MemorySnapshot interfaces providing structured memory data with component attribution and activity state context.