@@ -14,11 +14,11 @@ public class ProcessCollector : IOnDemandCollector
1414 private readonly Process _process ;
1515 private Counter _cpuTotal ;
1616 private Counter _errorCounter ;
17-
18- private Untyped _numThreads ;
19- private Untyped _privateMemorySize ;
20- private Untyped _virtualMemorySize ;
21- private Untyped _workingSet ;
17+
18+ private Gauge _numThreads ;
19+ private Gauge _privateMemorySize ;
20+ private Gauge _virtualMemorySize ;
21+ private Gauge _workingSet ;
2222
2323
2424 /// <inheritdoc />
@@ -47,16 +47,16 @@ public void RegisterMetrics()
4747 _cpuTotal = _metricFactory . CreateCounter ( "process_cpu_seconds_total" , "Total user and system CPU time spent in seconds" ) ;
4848
4949 var epoch = new DateTime ( 1970 , 1 , 1 , 0 , 0 , 0 , DateTimeKind . Utc ) ;
50-
50+
5151 _metricFactory . CreateGauge ( "process_start_time_seconds" , "Start time of the process since unix epoch in seconds" )
5252 . Set ( ( _process . StartTime . ToUniversalTime ( ) - epoch ) . TotalSeconds ) ;
53-
54- _virtualMemorySize = _metricFactory . CreateUntyped ( "process_virtual_bytes" , "Process virtual memory size" ) ;
55- _workingSet = _metricFactory . CreateUntyped ( "process_working_set" , "Process working set" ) ;
56- _privateMemorySize = _metricFactory . CreateUntyped ( "process_private_bytes" , "Process private memory size" ) ;
57- _numThreads = _metricFactory . CreateUntyped ( "process_num_threads" , "Total number of threads" ) ;
58-
59- _metricFactory . CreateUntyped ( "process_processid" , "Process ID" ) . Set ( _process . Id ) ;
53+
54+ _virtualMemorySize = _metricFactory . CreateGauge ( "process_virtual_bytes" , "Process virtual memory size" ) ;
55+ _workingSet = _metricFactory . CreateGauge ( "process_working_set" , "Process working set" ) ;
56+ _privateMemorySize = _metricFactory . CreateGauge ( "process_private_bytes" , "Process private memory size" ) ;
57+ _numThreads = _metricFactory . CreateGauge ( "process_num_threads" , "Total number of threads" ) ;
58+
59+ _metricFactory . CreateGauge ( "process_processid" , "Process ID" ) . Set ( _process . Id ) ; // todo: Untyped
6060 }
6161
6262 public void UpdateMetrics ( )
@@ -66,7 +66,7 @@ public void UpdateMetrics()
6666 _process . Refresh ( ) ;
6767
6868 _cpuTotal . Inc ( _process . TotalProcessorTime . TotalSeconds - _cpuTotal . Value ) ;
69-
69+
7070 _virtualMemorySize . Set ( _process . VirtualMemorySize64 ) ;
7171 _workingSet . Set ( _process . WorkingSet64 ) ;
7272 _privateMemorySize . Set ( _process . PrivateMemorySize64 ) ;
@@ -78,4 +78,4 @@ public void UpdateMetrics()
7878 }
7979 }
8080 }
81- }
81+ }
0 commit comments