| Copyright | (c) Matt Parsons 2017 Taylor Fausak 2016 |
|---|---|
| License | MIT |
| Maintainer | parsonsmatt@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.Monad.Metrics
Description
This module presents an easy interface that you can use to collect metrics about your application. It uses EKG under the hood and is inspired by Taylor Fausak's blunt application.
This module is designed to be imported qualified.
- class MonadMetrics m where
- data Metrics
- initialize :: IO Metrics
- initializeWith :: Store -> IO Metrics
- increment :: (MonadIO m, MonadMetrics m) => Text -> m ()
- counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()
- counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()
- gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()
- gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()
- distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m ()
- timed :: (MonadIO m, MonadMetrics m) => Text -> m a -> m a
- timed' :: (MonadIO m, MonadMetrics m) => Resolution -> Text -> m a -> m a
- label :: (MonadIO m, MonadMetrics m) => Text -> Text -> m ()
- label' :: (MonadIO m, MonadMetrics m, Show a) => Text -> a -> m ()
- data Resolution
The Type Class
class MonadMetrics m where Source #
A class is an instance of MonadMetrics if it can provide a Metrics
somehow. Commonly, this will be implemented as a ReaderT where some
field in the environment is the Metrics data.
Since v0.1.0.0
Minimal complete definition
Methods
getMetrics :: m Metrics Source #
Initializing
initialize :: IO Metrics Source #
Collecting Metrics
increment :: (MonadIO m, MonadMetrics m) => Text -> m () Source #
Increment the named counter by 1.
Since v0.1.0.0
counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m () Source #
A type specialized version of counter' to avoid ambiguous type
errors.
Since v0.1.0.0
counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m () Source #
Adds the value to the named Counter.
Since v0.1.0.0
gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m () Source #
A type specialized version of gauge' to avoid ambiguous types.
Since v0.1.0.0
gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m () Source #
Set the value of the named Gauge.
Since v0.1.0.0
distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m () Source #
Add the value to the named Distribution.
Since v0.1.0.0
timed :: (MonadIO m, MonadMetrics m) => Text -> m a -> m a Source #
Record the time of executing the given action in seconds. Defers to
timed'.
Since v0.1.0.0
timed' :: (MonadIO m, MonadMetrics m) => Resolution -> Text -> m a -> m a Source #
Record the time taken to perform the named action. The number is
stored in a Distribution and is converted
to the specified Resolution.
Since v0.1.0.0
data Resolution Source #
A type representing the resolution of time to use for the timed
metric.
Constructors
| Nanoseconds | |
| Microseconds | |
| Milliseconds | |
| Seconds | |
| Minutes | |
| Hours | |
| Days |
Instances