fix: single callback for memory/handle collector#1118
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the ExternalMemoryCollector to register a single OpenTelemetry batch callback for multiple observable gauges, ensuring process.memoryUsage() is read only once per collection cycle.
Changes:
- Replaced three per-gauge observable callbacks with one
meter.addBatchObservableCallbackcovering external, ArrayBuffers, and RSS gauges. - Added a Vitest unit test to validate that all gauges are observed from a single
process.memoryUsage()call.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/internal/monitoring/system/memory-collector.ts | Consolidates memory metric collection into a single batch observable callback to avoid multiple process.memoryUsage() reads. |
| src/internal/monitoring/system/memory-collector.test.ts | Adds test coverage ensuring the collector observes all gauges and calls process.memoryUsage() only once per batch invocation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 26217125033Coverage increased (+0.2%) to 75.171%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
fcbe538 to
ab00845
Compare
fenos
approved these changes
May 21, 2026
ab00845 to
8c43b1c
Compare
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
8c43b1c to
3d7b1a9
Compare
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
3d7b1a9 to
2df3e3b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
refactor
What is the current behavior?
Each memory/handle metric is using a separate observable callback which does calculation which could be shared.
What is the new behavior?
Do a single batch callback instead that does computation once and shares between metrics.