Skip to content

feat(runtime): add six instance_nodejs_* meters (6 -> 12) - #142

Closed
songzhendong wants to merge 1 commit into
apache:masterfrom
songzhendong:internal/feature-runtime-metrics-v2-six
Closed

feat(runtime): add six instance_nodejs_* meters (6 -> 12)#142
songzhendong wants to merge 1 commit into
apache:masterfrom
songzhendong:internal/feature-runtime-metrics-v2-six

Conversation

@songzhendong

Copy link
Copy Markdown
Contributor

Extend Node.js runtime metrics from 6 to 12 instance_nodejs_* meters reported via MeterReportService.collect, building on the six meters introduced in #139.

This PR is metrics-only — no gRPC/TLS/DNS/CommandService changes.

Motivation

Operators need richer Node.js process/V8 visibility (array buffers, uptime, malloc stats, heap generations) alongside the existing CPU/heap/RSS meters.

Changes

Six additional meters

Node.js source Meter name Unit
process.memoryUsage().arrayBuffers instance_nodejs_array_buffers bytes
process.uptime() instance_nodejs_uptime seconds
v8.getHeapStatistics().peak_malloced_memory instance_nodejs_peak_malloced_memory bytes
v8.getHeapStatistics().malloced_memory instance_nodejs_malloced_memory bytes
v8.getHeapSpaceStatistics() old_space instance_nodejs_old_space_used bytes
v8.getHeapSpaceStatistics() new_space instance_nodejs_new_space_used bytes

12 total with the six baseline meters: process_cpu, heap_used, heap_total, heap_limit, rss, external_memory.

Other

  • SW_AGENT_RUNTIME_METRICS_HEAP_SPACE_DETAIL (default true); when false, skip getHeapSpaceStatistics() and report old_space_used / new_space_used as 0.
  • Process CPU: process.cpuUsage() user + system, normalized by logical CPU count (0–100%).
  • README: twelve-meter table + env documentation.
  • Unit tests: tests/runtime/RuntimeSampler.test.ts, tests/runtime/RuntimeMetricsCollector.test.ts.
  • CI: TestUnitRemote matrix on Node 20 / 22 / 24 (tests/remote, tests/config, tests/runtime).
  • Express plugin e2e: meterSize: 12, assertions for all twelve meters.

Report array_buffers, uptime, peak_malloced_memory, malloced_memory,
old_space_used, and new_space_used alongside the existing six process
meters. Replace detached_contexts with malloced_memory for reliable
non-zero dashboard lines. Add CPU normalization unit test and document
SW_AGENT_RUNTIME_METRICS_HEAP_SPACE_DETAIL.

Signed-off-by: songzhendong <289505773@qq.com>
@songzhendong

Copy link
Copy Markdown
Contributor Author

Closing temporarily for follow-up fixes before re-opening.

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