@@ -198,14 +198,14 @@ register :: T.Text
198
198
-> IO ()
199
199
register name sample store = do
200
200
atomicModifyIORef (storeState store) $ \ state@ State {.. } ->
201
- case M. member name stateMetrics of
202
- False -> let ! state' = state {
201
+ if M. member name stateMetrics
202
+ then alreadyInUseError name
203
+ else let ! state' = state {
203
204
stateMetrics = M. insert name
204
205
(Left sample)
205
206
stateMetrics
206
207
}
207
208
in (state', () )
208
- True -> alreadyInUseError name
209
209
210
210
-- | Raise an exception indicating that the metric name is already in
211
211
-- use.
@@ -331,16 +331,6 @@ createDistribution name store = do
331
331
-- easily be added to a metrics store by calling their register
332
332
-- function.
333
333
334
- #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 ))
338
- #else
339
- -- | Convert seconds to milliseconds.
340
- sToMs :: Double -> Int64
341
- sToMs s = round (s * 1000.0 )
342
- #endif
343
-
344
334
-- | Register a number of metrics related to garbage collector
345
335
-- behavior.
346
336
--
@@ -420,7 +410,7 @@ sToMs s = round (s * 1000.0)
420
410
-- 1 for a maximally sequential run and approaches the number of
421
411
-- threads (set by the RTS flag @-N@) for a maximally parallel run.
422
412
registerGcMetrics :: Store -> IO ()
423
- registerGcMetrics store =
413
+ registerGcMetrics =
424
414
registerGroup
425
415
#if MIN_VERSION_base(4,10,0)
426
416
(M. fromList
@@ -449,6 +439,10 @@ registerGcMetrics store =
449
439
, (" rts.gc.par_max_bytes_copied" , Gauge . fromIntegral . Stats. cumulative_par_max_copied_bytes)
450
440
])
451
441
getRTSStats
442
+ where
443
+ -- | Convert nanoseconds to milliseconds.
444
+ nsToMs :: Int64 -> Int64
445
+ nsToMs s = round (realToFrac s / (1000000.0 :: Double ))
452
446
#else
453
447
(M. fromList
454
448
[ (" rts.gc.bytes_allocated" , Counter . Stats. bytesAllocated)
@@ -472,8 +466,11 @@ registerGcMetrics store =
472
466
, (" rts.gc.par_max_bytes_copied" , Gauge . Stats. parMaxBytesCopied)
473
467
])
474
468
getGcStats
469
+ where
470
+ -- | Convert seconds to milliseconds.
471
+ sToMs :: Double -> Int64
472
+ sToMs s = round (s * 1000.0 )
475
473
#endif
476
- store
477
474
478
475
#if MIN_VERSION_base(4,10,0)
479
476
-- | Get RTS statistics.
0 commit comments