@@ -53,27 +53,6 @@ struct ProcessIdentifier {
53
53
comm : String ,
54
54
}
55
55
56
- struct Gauge ( metrics:: Gauge ) ;
57
-
58
- impl std:: fmt:: Debug for Gauge {
59
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
60
- f. debug_struct ( "Gauge" ) . finish_non_exhaustive ( )
61
- }
62
- }
63
-
64
- impl From < metrics:: Gauge > for Gauge {
65
- fn from ( gauge : metrics:: Gauge ) -> Self {
66
- Self ( gauge)
67
- }
68
- }
69
-
70
- impl Gauge {
71
- #[ inline]
72
- fn set ( & self , value : f64 ) {
73
- self . 0 . set ( value) ;
74
- }
75
- }
76
-
77
56
#[ derive( Debug ) ]
78
57
pub ( crate ) struct Sampler {
79
58
parent : Process ,
@@ -82,7 +61,6 @@ pub(crate) struct Sampler {
82
61
page_size : u64 ,
83
62
previous_samples : FxHashMap < ProcessIdentifier , Sample > ,
84
63
previous_totals : Sample ,
85
- previous_gauges : Vec < Gauge > ,
86
64
have_logged_perms_err : bool ,
87
65
}
88
66
@@ -97,7 +75,6 @@ impl Sampler {
97
75
page_size : procfs:: page_size ( ) ,
98
76
previous_samples : FxHashMap :: default ( ) ,
99
77
previous_totals : Sample :: default ( ) ,
100
- previous_gauges : Vec :: default ( ) ,
101
78
have_logged_perms_err : false ,
102
79
} )
103
80
}
@@ -127,12 +104,6 @@ impl Sampler {
127
104
let uptime_seconds: f64 = procfs:: Uptime :: current ( ) ?. uptime ; // seconds since boot
128
105
let uptime_ticks: u64 = uptime_seconds. round ( ) as u64 * self . ticks_per_second ; // CPU-ticks since boot
129
106
130
- // Clear values from previous sample run. This ensures that processes
131
- // that no longer exist will be reported with a 0 value.
132
- for gauge in self . previous_gauges . drain ( ..) {
133
- gauge. set ( 0.0 ) ;
134
- }
135
-
136
107
// Every sample run we collect all the child processes rooted at the
137
108
// parent. As noted by the procfs documentation is this done by
138
109
// dereferencing the `/proc/<pid>/root` symlink.
@@ -295,21 +266,13 @@ impl Sampler {
295
266
] ;
296
267
297
268
// Number of pages that the process has in real memory.
298
- let rss_gauge = gauge ! ( "rss_bytes" , & labels) ;
299
- rss_gauge. set ( rss as f64 ) ;
300
- self . previous_gauges . push ( rss_gauge. into ( ) ) ;
269
+ gauge ! ( "rss_bytes" , & labels) . set ( rss as f64 ) ;
301
270
// Soft limit on RSS bytes, see RLIMIT_RSS in getrlimit(2).
302
- let rsslim_gauge = gauge ! ( "rsslim_bytes" , & labels) ;
303
- rsslim_gauge. set ( rsslim as f64 ) ;
304
- self . previous_gauges . push ( rsslim_gauge. into ( ) ) ;
271
+ gauge ! ( "rsslim_bytes" , & labels) . set ( rsslim as f64 ) ;
305
272
// The size in bytes of the process in virtual memory.
306
- let vsize_gauge = gauge ! ( "vsize_bytes" , & labels) ;
307
- vsize_gauge. set ( vsize as f64 ) ;
308
- self . previous_gauges . push ( vsize_gauge. into ( ) ) ;
273
+ gauge ! ( "vsize_bytes" , & labels) . set ( vsize as f64 ) ;
309
274
// Number of threads this process has active.
310
- let num_threads_gauge = gauge ! ( "num_threads" , & labels) ;
311
- num_threads_gauge. set ( stats. num_threads as f64 ) ;
312
- self . previous_gauges . push ( num_threads_gauge. into ( ) ) ;
275
+ gauge ! ( "num_threads" , & labels) . set ( stats. num_threads as f64 ) ;
313
276
314
277
total_rss += rss;
315
278
total_processes += 1 ;
@@ -423,15 +386,9 @@ impl Sampler {
423
386
( "comm" , comm. clone ( ) ) ,
424
387
] ;
425
388
426
- let cpu_gauge = gauge ! ( "cpu_percentage" , & labels) ;
427
- cpu_gauge. set ( calc. cpu ) ;
428
- self . previous_gauges . push ( cpu_gauge. into ( ) ) ;
429
- let kernel_gauge = gauge ! ( "kernel_cpu_percentage" , & labels) ;
430
- kernel_gauge. set ( calc. kernel ) ;
431
- self . previous_gauges . push ( kernel_gauge. into ( ) ) ;
432
- let user_cpu_gauge = gauge ! ( "user_cpu_percentage" , & labels) ;
433
- user_cpu_gauge. set ( calc. user ) ;
434
- self . previous_gauges . push ( user_cpu_gauge. into ( ) ) ;
389
+ gauge ! ( "cpu_percentage" , & labels) . set ( calc. cpu ) ;
390
+ gauge ! ( "kernel_cpu_percentage" , & labels) . set ( calc. kernel ) ;
391
+ gauge ! ( "user_cpu_percentage" , & labels) . set ( calc. user ) ;
435
392
}
436
393
437
394
let total_sample = samples
0 commit comments