{-# LANGUAGE TemplateHaskell #-}
module Tendermint.SDK.BaseApp.Metrics where
import Data.String (IsString (..))
import Data.Text (Text)
import Polysemy
data CountName = CountName
{ CountName -> Text
countName :: Text
, CountName -> [(Text, Text)]
countLabels :: [(Text, Text)]
} deriving (CountName -> CountName -> Bool
(CountName -> CountName -> Bool)
-> (CountName -> CountName -> Bool) -> Eq CountName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CountName -> CountName -> Bool
$c/= :: CountName -> CountName -> Bool
== :: CountName -> CountName -> Bool
$c== :: CountName -> CountName -> Bool
Eq, Eq CountName
Eq CountName =>
(CountName -> CountName -> Ordering)
-> (CountName -> CountName -> Bool)
-> (CountName -> CountName -> Bool)
-> (CountName -> CountName -> Bool)
-> (CountName -> CountName -> Bool)
-> (CountName -> CountName -> CountName)
-> (CountName -> CountName -> CountName)
-> Ord CountName
CountName -> CountName -> Bool
CountName -> CountName -> Ordering
CountName -> CountName -> CountName
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CountName -> CountName -> CountName
$cmin :: CountName -> CountName -> CountName
max :: CountName -> CountName -> CountName
$cmax :: CountName -> CountName -> CountName
>= :: CountName -> CountName -> Bool
$c>= :: CountName -> CountName -> Bool
> :: CountName -> CountName -> Bool
$c> :: CountName -> CountName -> Bool
<= :: CountName -> CountName -> Bool
$c<= :: CountName -> CountName -> Bool
< :: CountName -> CountName -> Bool
$c< :: CountName -> CountName -> Bool
compare :: CountName -> CountName -> Ordering
$ccompare :: CountName -> CountName -> Ordering
$cp1Ord :: Eq CountName
Ord)
instance IsString CountName where
fromString :: String -> CountName
fromString s :: String
s = Text -> [(Text, Text)] -> CountName
CountName (String -> Text
forall a. IsString a => String -> a
fromString String
s) [(Text, Text)]
forall a. Monoid a => a
mempty
data HistogramName = HistogramName
{ HistogramName -> Text
histogramName :: Text
, HistogramName -> [(Text, Text)]
histogramLabels :: [(Text, Text)]
, HistogramName -> [Double]
histogramBuckets :: [Double]
} deriving (HistogramName -> HistogramName -> Bool
(HistogramName -> HistogramName -> Bool)
-> (HistogramName -> HistogramName -> Bool) -> Eq HistogramName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistogramName -> HistogramName -> Bool
$c/= :: HistogramName -> HistogramName -> Bool
== :: HistogramName -> HistogramName -> Bool
$c== :: HistogramName -> HistogramName -> Bool
Eq, Eq HistogramName
Eq HistogramName =>
(HistogramName -> HistogramName -> Ordering)
-> (HistogramName -> HistogramName -> Bool)
-> (HistogramName -> HistogramName -> Bool)
-> (HistogramName -> HistogramName -> Bool)
-> (HistogramName -> HistogramName -> Bool)
-> (HistogramName -> HistogramName -> HistogramName)
-> (HistogramName -> HistogramName -> HistogramName)
-> Ord HistogramName
HistogramName -> HistogramName -> Bool
HistogramName -> HistogramName -> Ordering
HistogramName -> HistogramName -> HistogramName
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: HistogramName -> HistogramName -> HistogramName
$cmin :: HistogramName -> HistogramName -> HistogramName
max :: HistogramName -> HistogramName -> HistogramName
$cmax :: HistogramName -> HistogramName -> HistogramName
>= :: HistogramName -> HistogramName -> Bool
$c>= :: HistogramName -> HistogramName -> Bool
> :: HistogramName -> HistogramName -> Bool
$c> :: HistogramName -> HistogramName -> Bool
<= :: HistogramName -> HistogramName -> Bool
$c<= :: HistogramName -> HistogramName -> Bool
< :: HistogramName -> HistogramName -> Bool
$c< :: HistogramName -> HistogramName -> Bool
compare :: HistogramName -> HistogramName -> Ordering
$ccompare :: HistogramName -> HistogramName -> Ordering
$cp1Ord :: Eq HistogramName
Ord)
instance IsString HistogramName where
fromString :: String -> HistogramName
fromString s :: String
s = Text -> [(Text, Text)] -> [Double] -> HistogramName
HistogramName (String -> Text
forall a. IsString a => String -> a
fromString String
s) [(Text, Text)]
forall a. Monoid a => a
mempty [Double]
defaultBuckets
where defaultBuckets :: [Double]
defaultBuckets = [0.0001, 0.001, 0.01, 0.1, 0.25, 0.5, 0.75, 1, 10, 100]
data Metrics m a where
IncCount :: CountName -> Metrics m ()
WithTimer :: HistogramName -> m a -> Metrics m a
makeSem ''Metrics