-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A convenient wrapper around EKG metrics
--   
--   A convenient wrapper for collecting application metrics. Please see
--   the README.md for more information.
@package monad-metrics
@version 0.2.1.2


-- | This is an internal module. Depend upon it at your own risk --
--   breaking changes in here will <i>not</i> be reflected in the major API
--   version.
module Control.Monad.Metrics.Internal

-- | A container for metrics used by the <tt>MonadMetrics</tt> class.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Metrics
Metrics :: IORef (HashMap Text Counter) -> IORef (HashMap Text Gauge) -> IORef (HashMap Text Distribution) -> IORef (HashMap Text Label) -> Store -> Metrics
[_metricsCounters] :: Metrics -> IORef (HashMap Text Counter)
[_metricsGauges] :: Metrics -> IORef (HashMap Text Gauge)
[_metricsDistributions] :: Metrics -> IORef (HashMap Text Distribution)
[_metricsLabels] :: Metrics -> IORef (HashMap Text Label)
[_metricsStore] :: Metrics -> Store

-- | A lens into the <a>Counter</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsCounters :: Lens' Metrics (IORef (HashMap Text Counter))

-- | A lens into the <a>Gauge</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsGauges :: Lens' Metrics (IORef (HashMap Text Gauge))

-- | A lens into the <a>Distribution</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsDistributions :: Lens' Metrics (IORef (HashMap Text Distribution))

-- | A lens into the <a>Label</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsLabels :: Lens' Metrics (IORef (HashMap Text Label))

-- | A lens into the <a>Store</a> provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsStore :: Lens' Metrics Store

-- | A type representing the resolution of time to use for the
--   <tt>timed</tt> metric.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Resolution
Nanoseconds :: Resolution
Microseconds :: Resolution
Milliseconds :: Resolution
Seconds :: Resolution
Minutes :: Resolution
Hours :: Resolution
Days :: Resolution
diffTime :: Resolution -> TimeSpec -> TimeSpec -> Double
convertTimeSpecTo :: Resolution -> TimeSpec -> Double
nsToUs :: Double -> Double
nsToMs :: Double -> Double
nsToS :: Double -> Double
sToMin :: Double -> Double
sToHour :: Double -> Double
sToDay :: Double -> Double
sToNs :: Double -> Double
sToUs :: Double -> Double
sToMs :: Double -> Double
instance GHC.Enum.Enum Control.Monad.Metrics.Internal.Resolution
instance GHC.Classes.Ord Control.Monad.Metrics.Internal.Resolution
instance GHC.Show.Show Control.Monad.Metrics.Internal.Resolution
instance GHC.Classes.Eq Control.Monad.Metrics.Internal.Resolution


-- | This module presents an easy interface that you can use to collect
--   metrics about your application. It uses EKG from <a>System.Metrics</a>
--   under the hood and is inspired by Taylor Fausak's <a>blunt</a>
--   application.
--   
--   This module is designed to be imported qualified.
module Control.Monad.Metrics

-- | A type can be an instance of <a>MonadMetrics</a> if it can provide a
--   <a>Metrics</a> somehow. Commonly, this will be implemented as a
--   <a>ReaderT</a> where some field in the environment is the
--   <a>Metrics</a> data.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
class Monad m => MonadMetrics m
getMetrics :: MonadMetrics m => m Metrics

-- | Initializes a <a>Metrics</a> value, creating a new <a>Store</a> for
--   it.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
initialize :: IO Metrics

-- | Initializes a <a>Metrics</a> value with the given <a>Store</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
initializeWith :: Store -> IO Metrics

-- | Enhances the base monad with metrics. This works for very simple
--   cases, where you don't have a <tt>Reader</tt> involved yet. If your
--   stack already has a <tt>Reader</tt>, then you'll get some annoying
--   type problems with this. Switch over to <a>run'</a>, or alternatively,
--   define your own <a>MonadMetrics</a> instance.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
run :: MonadIO m => ReaderT Metrics m a -> m a

-- | Adds metric recording capabilities to the given action. The first
--   parameter is a function which accepts a <a>Metrics</a> value and
--   creates the final <tt>r</tt> value to be used in the action. This is
--   useful when you have a preexisting <a>ReaderT</a> in your stack, and
--   you want to enhance it with metrics.
--   
--   <pre>
--   data Config = Config { size :: Int, metrics' :: Metrics }
--   
--   main = <tt>runWithMetrics</tt> (Config 10) $ do
--       num &lt;- asks size
--       forM_ [1 .. size] _ -&gt; Metrics.increment "foo"
--   </pre>
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
run' :: MonadIO m => (Metrics -> r) -> ReaderT r m a -> m a

-- | Increment the named counter by 1.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
increment :: (MonadIO m, MonadMetrics m) => Text -> m ()

-- | A type specialized version of <a>counter'</a> to avoid ambiguous type
--   errors.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Adds the value to the named <a>Counter</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
counter' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | A type specialized version of <a>gauge'</a> to avoid ambiguous types.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge :: (MonadIO m, MonadMetrics m) => Text -> Int -> m ()

-- | Set the value of the named <a>Gauge</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
gauge' :: (MonadIO m, MonadMetrics m, Integral int) => Text -> int -> m ()

-- | Add the value to the named <a>Distribution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
distribution :: (MonadIO m, MonadMetrics m) => Text -> Double -> m ()

-- | Record the time of executing the given action in seconds. Defers to
--   <a>timed'</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed :: (MonadIO m, MonadMetrics m, MonadMask m) => Text -> m a -> m a

-- | Record the time taken to perform the named action. The number is
--   stored in a <a>Distribution</a> and is converted to the specified
--   <a>Resolution</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
timed' :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> Text -> m a -> m a

-- | Record the time taken to perform the action, under several names at
--   once. The number is stored in a <a>Distribution</a> and is converted
--   to the specified <a>Resolution</a>.
--   
--   This is useful to store the same durations data sectioned by different
--   criteria, e.g.:
--   
--   <pre>
--   timedList Seconds ["request.byUser." &lt;&gt; userName, "request.byType." &lt;&gt; requestType] $ do
--       ...
--   </pre>
--   
--   So you will have <tt>"request.byUser.someuser"</tt> storing duration
--   distribution for requests of user <tt>"someuser"</tt> of any type; and
--   <tt>"request.byType.sometype"</tt> storing duration distribution for
--   requests of type <tt>"sometype"</tt> from any user.
timedList :: (MonadIO m, MonadMetrics m, MonadMask m) => Resolution -> [Text] -> m a -> m a

-- | Set the <a>Label</a> to the given <a>Text</a> value.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label :: (MonadIO m, MonadMetrics m) => Text -> Text -> m ()

-- | Set the <a>Label</a> to the <a>Show</a>n value of whatever you pass
--   in.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
label' :: (MonadIO m, MonadMetrics m, Show a) => Text -> a -> m ()

-- | A type representing the resolution of time to use for the
--   <tt>timed</tt> metric.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Resolution
Nanoseconds :: Resolution
Microseconds :: Resolution
Milliseconds :: Resolution
Seconds :: Resolution
Minutes :: Resolution
Hours :: Resolution
Days :: Resolution

-- | A container for metrics used by the <tt>MonadMetrics</tt> class.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
data Metrics

-- | A lens into the <a>Counter</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsCounters :: Lens' Metrics (IORef (HashMap Text Counter))

-- | A lens into the <a>Gauge</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsGauges :: Lens' Metrics (IORef (HashMap Text Gauge))

-- | A lens into the <a>Label</a>s provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsLabels :: Lens' Metrics (IORef (HashMap Text Label))

-- | A lens into the <a>Store</a> provided by the <a>Metrics</a>.
--   
--   <ul>
--   <li><i>Since v0.1.0.0</i></li>
--   </ul>
metricsStore :: Lens' Metrics Store
instance (Control.Monad.Metrics.MonadMetrics m, Control.Monad.Trans.Class.MonadTrans t, GHC.Base.Monad (t m)) => Control.Monad.Metrics.MonadMetrics (t m)
instance GHC.Base.Monad m => Control.Monad.Metrics.MonadMetrics (Control.Monad.Trans.Reader.ReaderT Control.Monad.Metrics.Internal.Metrics m)
