Skip to content

Commit 05d5332

Browse files
committed
Follow new naming in GHC.Stats. Fixes #29.
GHC commit 24e6594cc7890babe69b8ba122d171affabad2d1 changed a lot of the stats names. Until now, EKG stuck to the old names, which can be very confusing; especially since some names were clearly misleading and have been renamed in GHC consequentially. This commit changes all names to the new names (provided we're on base >= 4.10; the #ifdef for even older base versions remains unchanged). This change may break some users that rely on the old names, so a new major release should be made.
1 parent 20b5017 commit 05d5332

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

Diff for: System/Metrics.hs

+37-24
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,6 @@ createDistribution name store = do
332332
-- function.
333333

334334
#if MIN_VERSION_base(4,10,0)
335-
-- | Convert nanoseconds to milliseconds.
336-
nsToMs :: Int64 -> Int64
337-
nsToMs s = round (realToFrac s / (1000000.0 :: Double))
338335
#else
339336
-- | Convert seconds to milliseconds.
340337
sToMs :: Double -> Int64
@@ -424,32 +421,48 @@ registerGcMetrics store =
424421
registerGroup
425422
#if MIN_VERSION_base(4,10,0)
426423
(M.fromList
427-
[ ("rts.gc.bytes_allocated" , Counter . fromIntegral . Stats.allocated_bytes)
428-
, ("rts.gc.num_gcs" , Counter . fromIntegral . Stats.gcs)
429-
, ("rts.gc.num_bytes_usage_samples" , Counter . fromIntegral . Stats.major_gcs)
430-
, ("rts.gc.cumulative_bytes_used" , Counter . fromIntegral . Stats.cumulative_live_bytes)
431-
, ("rts.gc.bytes_copied" , Counter . fromIntegral . Stats.copied_bytes)
424+
-- We order them the same way as they are in GHC.Stats for easy comparison.
425+
[ ("rts.gcs" , Counter . fromIntegral . Stats.gcs)
426+
, ("rts.major_gcs" , Counter . fromIntegral . Stats.major_gcs)
427+
, ("rts.allocated_bytes" , Counter . fromIntegral . Stats.allocated_bytes)
428+
, ("rts.max_live_bytes" , Gauge . fromIntegral . Stats.max_live_bytes)
429+
, ("rts.max_large_objects_bytes" , Gauge . fromIntegral . Stats.max_large_objects_bytes)
430+
, ("rts.max_compact_bytes" , Gauge . fromIntegral . Stats.max_compact_bytes)
431+
, ("rts.max_slop_bytes" , Gauge . fromIntegral . Stats.max_slop_bytes)
432+
, ("rts.max_mem_in_use_bytes" , Gauge . fromIntegral . Stats.max_mem_in_use_bytes)
433+
, ("rts.cumulative_live_bytes" , Counter . fromIntegral . Stats.cumulative_live_bytes)
434+
, ("rts.copied_bytes" , Counter . fromIntegral . Stats.copied_bytes)
435+
, ("rts.par_copied_bytes" , Gauge . fromIntegral . Stats.par_copied_bytes)
436+
, ("rts.cumulative_par_max_copied_bytes" , Gauge . fromIntegral . Stats.cumulative_par_max_copied_bytes)
437+
, ("rts.cumulative_par_balanced_copied_bytes" , Gauge . fromIntegral . Stats.cumulative_par_balanced_copied_bytes)
432438
#if MIN_VERSION_base(4,12,0)
433-
, ("rts.gc.init_cpu_ms" , Counter . nsToMs . Stats.init_cpu_ns)
434-
, ("rts.gc.init_wall_ms" , Counter . nsToMs . Stats.init_elapsed_ns)
439+
, ("rts.init_cpu_ns" , Counter . Stats.init_cpu_ns)
440+
, ("rts.init_elapsed_ns" , Counter . Stats.init_elapsed_ns)
435441
#endif
436-
, ("rts.gc.mutator_cpu_ms" , Counter . nsToMs . Stats.mutator_cpu_ns)
437-
, ("rts.gc.mutator_wall_ms" , Counter . nsToMs . Stats.mutator_elapsed_ns)
438-
, ("rts.gc.gc_cpu_ms" , Counter . nsToMs . Stats.gc_cpu_ns)
439-
, ("rts.gc.gc_wall_ms" , Counter . nsToMs . Stats.gc_elapsed_ns)
440-
, ("rts.gc.cpu_ms" , Counter . nsToMs . Stats.cpu_ns)
441-
, ("rts.gc.wall_ms" , Counter . nsToMs . Stats.elapsed_ns)
442-
, ("rts.gc.max_bytes_used" , Gauge . fromIntegral . Stats.max_live_bytes)
443-
, ("rts.gc.current_bytes_used" , Gauge . fromIntegral . Stats.gcdetails_live_bytes . Stats.gc)
444-
, ("rts.gc.current_bytes_slop" , Gauge . fromIntegral . Stats.gcdetails_slop_bytes . Stats.gc)
445-
, ("rts.gc.max_bytes_slop" , Gauge . fromIntegral . Stats.max_slop_bytes)
446-
, ("rts.gc.peak_megabytes_allocated" , Gauge . fromIntegral . (`quot` (1024*1024)) . Stats.max_mem_in_use_bytes)
447-
, ("rts.gc.par_tot_bytes_copied" , Gauge . fromIntegral . Stats.par_copied_bytes)
448-
, ("rts.gc.par_avg_bytes_copied" , Gauge . fromIntegral . Stats.par_copied_bytes)
449-
, ("rts.gc.par_max_bytes_copied" , Gauge . fromIntegral . Stats.cumulative_par_max_copied_bytes)
442+
, ("rts.mutator_cpu_ns" , Counter . Stats.mutator_cpu_ns)
443+
, ("rts.mutator_elapsed_ns" , Counter . Stats.mutator_elapsed_ns)
444+
, ("rts.gc_cpu_ns" , Counter . Stats.gc_cpu_ns)
445+
, ("rts.gc_elapsed_ns" , Counter . Stats.gc_elapsed_ns)
446+
, ("rts.cpu_ns" , Counter . Stats.cpu_ns)
447+
, ("rts.elapsed_ns" , Counter . Stats.elapsed_ns)
448+
-- GCDetails
449+
, ("rts.gc.gen" , Gauge . fromIntegral . Stats.gcdetails_gen . Stats.gc)
450+
, ("rts.gc.threads" , Gauge . fromIntegral . Stats.gcdetails_threads . Stats.gc)
451+
, ("rts.gc.allocated_bytes" , Gauge . fromIntegral . Stats.gcdetails_allocated_bytes . Stats.gc)
452+
, ("rts.gc.live_bytes" , Gauge . fromIntegral . Stats.gcdetails_live_bytes . Stats.gc)
453+
, ("rts.gc.large_objects_bytes" , Gauge . fromIntegral . Stats.gcdetails_large_objects_bytes . Stats.gc)
454+
, ("rts.gc.compact_bytes" , Gauge . fromIntegral . Stats.gcdetails_compact_bytes . Stats.gc)
455+
, ("rts.gc.slop_bytes" , Gauge . fromIntegral . Stats.gcdetails_slop_bytes . Stats.gc)
456+
, ("rts.gc.mem_in_use_bytes" , Gauge . fromIntegral . Stats.gcdetails_mem_in_use_bytes . Stats.gc)
457+
, ("rts.gc.copied_bytes" , Gauge . fromIntegral . Stats.gcdetails_copied_bytes . Stats.gc)
458+
, ("rts.gc.par_max_copied_bytes" , Gauge . fromIntegral . Stats.gcdetails_par_max_copied_bytes . Stats.gc)
459+
, ("rts.gc.sync_elapsed_ns" , Gauge . fromIntegral . Stats.gcdetails_sync_elapsed_ns . Stats.gc)
460+
, ("rts.gc.cpu_ns" , Gauge . fromIntegral . Stats.gcdetails_cpu_ns . Stats.gc)
461+
, ("rts.gc.elapsed_ns" , Gauge . fromIntegral . Stats.gcdetails_elapsed_ns . Stats.gc)
450462
])
451463
getRTSStats
452464
#else
465+
-- Pre base-4.10 we have the names from before GHC commit 24e6594cc7890babe69b8ba122d171affabad2d1.
453466
(M.fromList
454467
[ ("rts.gc.bytes_allocated" , Counter . Stats.bytesAllocated)
455468
, ("rts.gc.num_gcs" , Counter . Stats.numGcs)

0 commit comments

Comments
 (0)