Skip to content

Commit 7ffada1

Browse files
committed
Expose distribution internals for use in ekg-json
1 parent 59daa93 commit 7ffada1

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

System/Metrics.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ data Value = Counter {-# UNPACK #-} !Int64
517517
| Gauge {-# UNPACK #-} !Int64
518518
| Label {-# UNPACK #-} !T.Text
519519
| Distribution !Distribution.Stats
520-
deriving Show
520+
deriving (Eq, Show)
521521

522522
sampleOne :: MetricSampler -> IO Value
523523
sampleOne (CounterS m) = Counter <$> m

System/Metrics/Distribution.hsc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import Foreign.Storable (Storable(alignment, peek, poke, sizeOf), peekByteOff,
3737
import Prelude hiding (max, min, read, sum)
3838

3939
import Data.Array
40+
import System.Metrics.Distribution.Internal (Stats(..))
4041
import System.Metrics.ThreadId
4142

4243
-- | An metric for tracking events.
@@ -162,13 +163,3 @@ read distrib = do
162163
, min = cMin
163164
, max = cMax
164165
}
165-
166-
-- | Distribution statistics
167-
data Stats = Stats
168-
{ mean :: !Double -- ^ Sample mean
169-
, variance :: !Double -- ^ Biased sample variance
170-
, count :: !Int64 -- ^ Event count
171-
, sum :: !Double -- ^ Sum of values
172-
, min :: !Double -- ^ Min value seen
173-
, max :: !Double -- ^ Max value seen
174-
} deriving Show
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{-# OPTIONS_GHC -funbox-strict-fields #-}
2+
3+
-- | Internal module used to share implementation details between the
4+
-- family of ekg packages. DO NOT DEPEND ON THIS MODULE.
5+
module System.Metrics.Distribution.Internal
6+
( Stats(..)
7+
) where
8+
9+
import Data.Int (Int64)
10+
11+
-- | Distribution statistics
12+
data Stats = Stats
13+
{ mean :: !Double -- ^ Sample mean
14+
, variance :: !Double -- ^ Biased sample variance
15+
, count :: !Int64 -- ^ Event count
16+
, sum :: !Double -- ^ Sum of values
17+
, min :: !Double -- ^ Min value seen
18+
, max :: !Double -- ^ Max value seen
19+
} deriving (Eq, Show)

ekg-core.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ library
1919
System.Metrics
2020
System.Metrics.Counter
2121
System.Metrics.Distribution
22+
System.Metrics.Distribution.Internal
2223
System.Metrics.Gauge
2324
System.Metrics.Label
2425

0 commit comments

Comments
 (0)