{-# language GeneralizedNewtypeDeriving #-}
module Prometheus.Metric (
Metric (..)
, Sample (..)
, SampleGroup (..)
, SampleType (..)
) where
import Prometheus.Info
import Prometheus.Label
import Control.DeepSeq
import qualified Data.ByteString as BS
import Data.Text (Text)
data SampleType
= CounterType
| GaugeType
| SummaryType
| HistogramType
| UntypedType
instance Show SampleType where
show :: SampleType -> String
show SampleType
CounterType = String
"counter"
show SampleType
GaugeType = String
"gauge"
show SampleType
SummaryType = String
"summary"
show SampleType
HistogramType = String
"histogram"
show SampleType
UntypedType = String
"untyped"
data Sample = Sample Text LabelPairs BS.ByteString
deriving (Int -> Sample -> ShowS
[Sample] -> ShowS
Sample -> String
(Int -> Sample -> ShowS)
-> (Sample -> String) -> ([Sample] -> ShowS) -> Show Sample
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Sample -> ShowS
showsPrec :: Int -> Sample -> ShowS
$cshow :: Sample -> String
show :: Sample -> String
$cshowList :: [Sample] -> ShowS
showList :: [Sample] -> ShowS
Show)
data SampleGroup = SampleGroup Info SampleType [Sample]
deriving (Int -> SampleGroup -> ShowS
[SampleGroup] -> ShowS
SampleGroup -> String
(Int -> SampleGroup -> ShowS)
-> (SampleGroup -> String)
-> ([SampleGroup] -> ShowS)
-> Show SampleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SampleGroup -> ShowS
showsPrec :: Int -> SampleGroup -> ShowS
$cshow :: SampleGroup -> String
show :: SampleGroup -> String
$cshowList :: [SampleGroup] -> ShowS
showList :: [SampleGroup] -> ShowS
Show)
newtype Metric s =
Metric
{
forall s. Metric s -> IO (s, IO [SampleGroup])
construct :: IO (s, IO [SampleGroup])
}
instance NFData a => NFData (Metric a) where
rnf :: Metric a -> ()
rnf (Metric IO (a, IO [SampleGroup])
a) = IO (a, IO [SampleGroup])
a IO (a, IO [SampleGroup]) -> () -> ()
forall a b. a -> b -> b
`seq` ()