@@ -70,7 +70,6 @@ module System.Metrics
70
70
71
71
import Control.Applicative ((<$>) )
72
72
import Control.Monad (forM )
73
- import Data.Int (Int64 )
74
73
import qualified Data.IntMap.Strict as IM
75
74
import Data.IORef (IORef , atomicModifyIORef , newIORef , readIORef )
76
75
import qualified Data.HashMap.Strict as M
@@ -133,8 +132,8 @@ data GroupSampler = forall a. GroupSampler
133
132
}
134
133
135
134
-- TODO: Rename this to Metric and Metric to SampledMetric.
136
- data MetricSampler = CounterS ! (IO Int64 )
137
- | GaugeS ! (IO Int64 )
135
+ data MetricSampler = CounterS ! (IO Int )
136
+ | GaugeS ! (IO Int )
138
137
| LabelS ! (IO T. Text )
139
138
| DistributionS ! (IO Distribution. Stats )
140
139
@@ -156,18 +155,18 @@ newStore = do
156
155
-- | Register a non-negative, monotonically increasing, integer-valued
157
156
-- metric. The provided action to read the value must be thread-safe.
158
157
-- Also see 'createCounter'.
159
- registerCounter :: T. Text -- ^ Counter name
160
- -> IO Int64 -- ^ Action to read the current metric value
161
- -> Store -- ^ Metric store
158
+ registerCounter :: T. Text -- ^ Counter name
159
+ -> IO Int -- ^ Action to read the current metric value
160
+ -> Store -- ^ Metric store
162
161
-> IO ()
163
162
registerCounter name sample store =
164
163
register name (CounterS sample) store
165
164
166
165
-- | Register an integer-valued metric. The provided action to read
167
166
-- the value must be thread-safe. Also see 'createGauge'.
168
- registerGauge :: T. Text -- ^ Gauge name
169
- -> IO Int64 -- ^ Action to read the current metric value
170
- -> Store -- ^ Metric store
167
+ registerGauge :: T. Text -- ^ Gauge name
168
+ -> IO Int -- ^ Action to read the current metric value
169
+ -> Store -- ^ Metric store
171
170
-> IO ()
172
171
registerGauge name sample store =
173
172
register name (GaugeS sample) store
@@ -333,11 +332,11 @@ createDistribution name store = do
333
332
334
333
#if MIN_VERSION_base(4,10,0)
335
334
-- | Convert nanoseconds to milliseconds.
336
- nsToMs :: Int64 -> Int64
335
+ nsToMs :: Int -> Int
337
336
nsToMs s = round (realToFrac s / (1000000.0 :: Double ))
338
337
#else
339
338
-- | Convert seconds to milliseconds.
340
- sToMs :: Double -> Int64
339
+ sToMs :: Double -> Int
341
340
sToMs s = round (s * 1000.0 )
342
341
#endif
343
342
@@ -430,15 +429,15 @@ registerGcMetrics store =
430
429
, (" rts.gc.cumulative_bytes_used" , Counter . fromIntegral . Stats. cumulative_live_bytes)
431
430
, (" rts.gc.bytes_copied" , Counter . fromIntegral . Stats. copied_bytes)
432
431
#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)
432
+ , (" rts.gc.init_cpu_ms" , Counter . nsToMs . fromIntegral . Stats. init_cpu_ns)
433
+ , (" rts.gc.init_wall_ms" , Counter . nsToMs . fromIntegral . Stats. init_elapsed_ns)
435
434
#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)
435
+ , (" rts.gc.mutator_cpu_ms" , Counter . nsToMs . fromIntegral . Stats. mutator_cpu_ns)
436
+ , (" rts.gc.mutator_wall_ms" , Counter . nsToMs . fromIntegral . Stats. mutator_elapsed_ns)
437
+ , (" rts.gc.gc_cpu_ms" , Counter . nsToMs . fromIntegral . Stats. gc_cpu_ns)
438
+ , (" rts.gc.gc_wall_ms" , Counter . nsToMs . fromIntegral . Stats. gc_elapsed_ns)
439
+ , (" rts.gc.cpu_ms" , Counter . nsToMs . fromIntegral . Stats. cpu_ns)
440
+ , (" rts.gc.wall_ms" , Counter . nsToMs . fromIntegral . Stats. elapsed_ns)
442
441
, (" rts.gc.max_bytes_used" , Gauge . fromIntegral . Stats. max_live_bytes)
443
442
, (" rts.gc.current_bytes_used" , Gauge . fromIntegral . Stats. gcdetails_live_bytes . Stats. gc)
444
443
, (" rts.gc.current_bytes_slop" , Gauge . fromIntegral . Stats. gcdetails_slop_bytes . Stats. gc)
@@ -615,8 +614,8 @@ sampleGroups cbSamplers = concat `fmap` sequence (map runOne cbSamplers)
615
614
return $! map (\ (n, f) -> (n, f a)) (M. toList groupSamplerMetrics)
616
615
617
616
-- | The value of a sampled metric.
618
- data Value = Counter {- # UNPACK #-} !Int64
619
- | Gauge {- # UNPACK #-} !Int64
617
+ data Value = Counter {- # UNPACK #-} !Int
618
+ | Gauge {- # UNPACK #-} !Int
620
619
| Label {- # UNPACK #-} !T. Text
621
620
| Distribution ! Distribution. Stats
622
621
deriving (Eq , Show )
0 commit comments