Skip to content

Commit 373066a

Browse files
authored
feat(core): track system metrics and link plugins to workers when possible (#33411)
- Track relevant CPU and memory system metrics. - Link plugins to workers when possible. - Refactor collector code by splitting it into two separate structs.
1 parent 7458b52 commit 373066a

File tree

7 files changed

+560
-474
lines changed

7 files changed

+560
-474
lines changed

packages/nx/src/native/index.d.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export declare class ProcessMetricsCollector {
117117
getSystemInfo(): SystemInfo
118118
/** Register the main CLI process for metrics collection */
119119
registerMainCliProcess(pid: number): void
120+
/** Register a subprocess of the main CLI for metrics collection */
121+
registerMainCliSubprocess(pid: number, alias?: string | undefined | null): void
120122
/** Register the daemon process for metrics collection */
121123
registerDaemonProcess(pid: number): void
122124
/**
@@ -126,8 +128,6 @@ export declare class ProcessMetricsCollector {
126128
registerTaskProcess(taskId: string, pid: number): void
127129
/** Register a batch with multiple tasks sharing a worker */
128130
registerBatch(batchId: string, taskIds: Array<string>, pid: number): void
129-
/** Register a subprocess of the main CLI for metrics collection */
130-
registerMainCliSubprocess(pid: number): void
131131
/** Subscribe to push-based metrics notifications from TypeScript */
132132
subscribe(callback: (err: Error | null, event: MetricsUpdate) => void): void
133133
}
@@ -343,6 +343,7 @@ export interface ProcessMetadata {
343343
command: string
344344
exePath: string
345345
cwd: string
346+
alias?: string
346347
}
347348

348349
/** Process metrics (dynamic, changes every collection) */
@@ -355,6 +356,7 @@ export interface ProcessMetrics {
355356
/** Organized collection of process metrics with timestamp */
356357
export interface ProcessMetricsSnapshot {
357358
timestamp: number
359+
system: SystemMetrics
358360
mainCli?: ProcessTreeMetrics
359361
daemon?: ProcessTreeMetrics
360362
tasks: Record<string, Array<ProcessMetrics>>
@@ -408,6 +410,15 @@ export interface SystemInfo {
408410
totalMemory: number
409411
}
410412

413+
/** System metrics (dynamic, changes every collection) */
414+
export interface SystemMetrics {
415+
cpu: number
416+
memory: number
417+
availableMemory: number
418+
swapUsed: number
419+
swapTotal: number
420+
}
421+
411422
export interface Target {
412423
executor?: string
413424
inputs?: Array<JsInputs>

0 commit comments

Comments
 (0)