@@ -7,6 +7,7 @@ import { EventLoopMetrics } from "./metrics/event-loop";
77import { HeapMetrics } from "./metrics/heap" ;
88import { MemoryUsageMetrics } from "./metrics/memory-usage" ;
99import * as os from "os" ;
10+ import { GCObserver } from "./metrics/gc-observer" ;
1011
1112const DEFAULT_INTERVAL = 30 ; //seconds
1213
@@ -20,19 +21,22 @@ export class MetricsProbe {
2021 private readonly heap : HeapMetrics ;
2122 private readonly memoryUsage : MemoryUsageMetrics ;
2223
24+ private readonly gcObserver : GCObserver ;
25+
2326 constructor ( options : TraceoOptions ) {
24- if ( ! options . metrics . collect ) {
27+ if ( ! options ?. collectMetrics ) {
2528 return ;
2629 }
2730
28- this . interval = options . metrics . interval || DEFAULT_INTERVAL ;
31+ this . interval = options . scrapMetricsInterval || DEFAULT_INTERVAL ;
2932
3033 this . http = new HttpModule ( "/api/worker/metrics" ) ;
3134
3235 this . cpuUsage = new CpuUsageMetrics ( ) ;
3336 this . eventLoop = new EventLoopMetrics ( ) ;
3437 this . heap = new HeapMetrics ( ) ;
3538 this . memoryUsage = new MemoryUsageMetrics ( ) ;
39+ this . gcObserver = new GCObserver ( ) ;
3640 }
3741
3842 public register ( ) {
@@ -44,13 +48,15 @@ export class MetricsProbe {
4448 const eventLoop = this . eventLoop . collect ( ) ;
4549 const heap = this . heap . collect ( ) ;
4650 const memory = this . memoryUsage . collect ( ) ;
51+ const gc = this . gcObserver . collect ( ) ;
4752
4853 const metrics : Partial < Metrics > = {
4954 cpuUsage,
5055 eventLoopLag : eventLoop ,
5156 heap,
5257 memory,
5358 loadAvg : this . loadAvg ,
59+ gc,
5460 } ;
5561
5662 this . http . request ( {
0 commit comments