packages feed

prometheus 0.4.1 → 0.4.2

raw patch · 4 files changed

+34/−21 lines, 4 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ System.Metrics.Prometheus.Metric.Counter: addAndSample :: Int -> Counter -> IO CounterSample
+ System.Metrics.Prometheus.Metric.Gauge: modifyAndSample :: (Double -> (Double, a)) -> Gauge -> IO a
+ System.Metrics.Prometheus.Metric.Histogram: observeAndSample :: Double -> Histogram -> IO HistogramSample

Files

prometheus.cabal view
@@ -1,12 +1,12 @@ name:                prometheus-version:             0.4.1+version:             0.4.2 synopsis:            Prometheus Haskell Client-homepage:            http://github.com/LukeHoersten/prometheus#readme-bug-reports:         http://github.com/LukeHoersten/prometheus/issues+homepage:            http://github.com/bitnomial/prometheus+bug-reports:         http://github.com/bitnomial/prometheus/issues license:             BSD3 license-file:        LICENSE author:              Luke Hoersten-maintainer:          luke@hoersten.org, opensource@bitnomial.com+maintainer:          luke@bitnomial.com, opensource@bitnomial.com copyright:           Bitnomial, Inc. (c) 2016 category:            Metrics, Monitoring, Web, System build-type:          Simple@@ -74,7 +74,7 @@                  , System.Metrics.Prometheus.RegistryT    build-depends: atomic-primops >= 0.8  && < 0.9-               , base           >= 4.7  && < 4.10+               , base           >= 4.7  && < 4.11                , bytestring     >= 0.10 && < 0.11                , containers     >= 0.5  && < 0.6                , http-types     >= 0.8  && < 0.10@@ -85,4 +85,4 @@  source-repository head   type:     git-  location: https://github.com/LukeHoersten/prometheus+  location: https://github.com/bitnomial/prometheus
src/System/Metrics/Prometheus/Metric/Counter.hs view
@@ -5,11 +5,11 @@        , add        , inc        , sample+       , addAndSample        ) where  -import           Data.Atomics.Counter (AtomicCounter, incrCounter_, newCounter,-                                       readCounter)+import           Data.Atomics.Counter (AtomicCounter, incrCounter, newCounter)   newtype Counter = Counter { unCounter :: AtomicCounter }@@ -20,14 +20,16 @@ new = Counter <$> newCounter 0  -add :: Int -> Counter -> IO ()-add by | by >= 0 = incrCounter_ by . unCounter-       | otherwise = error "must be >= 0"+addAndSample :: Int -> Counter -> IO CounterSample+addAndSample by | by >= 0 = fmap CounterSample . incrCounter by . unCounter+                | otherwise = error "must be >= 0" +add :: Int -> Counter -> IO ()+add by c = addAndSample by c >> pure ()  inc :: Counter -> IO () inc = add 1   sample :: Counter -> IO CounterSample-sample = fmap CounterSample . readCounter . unCounter+sample = addAndSample 0
src/System/Metrics/Prometheus/Metric/Gauge.hs view
@@ -8,6 +8,7 @@        , dec        , set        , sample+       , modifyAndSample        ) where  import           Data.IORef (IORef, atomicModifyIORef', atomicWriteIORef,@@ -22,13 +23,17 @@ new = Gauge <$> newIORef 0  +modifyAndSample :: (Double -> (Double, a)) -> Gauge -> IO a+modifyAndSample f = flip atomicModifyIORef' f . unGauge++ add :: Double -> Gauge -> IO ()-add x = flip atomicModifyIORef' f . unGauge+add x = modifyAndSample f   where f v = (v + x, ())   sub :: Double -> Gauge -> IO ()-sub x = flip atomicModifyIORef' f . unGauge+sub x = modifyAndSample f   where f v = (v - x, ())  
src/System/Metrics/Prometheus/Metric/Histogram.hs view
@@ -8,13 +8,15 @@        , new        , observe        , sample+       , observeAndSample        ) where  -import           Data.Bool  (bool)-import           Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef)-import           Data.Map   (Map)-import qualified Data.Map   as Map+import           Control.Monad (void)+import           Data.Bool     (bool)+import           Data.IORef    (IORef, atomicModifyIORef', newIORef, readIORef)+import           Data.Map      (Map)+import qualified Data.Map      as Map   newtype Histogram = Histogram { unHistogram :: IORef HistogramSample }@@ -40,15 +42,19 @@     zeroCount = 0  -observe :: Double -> Histogram -> IO ()-observe x = flip atomicModifyIORef' update . unHistogram+observeAndSample :: Double -> Histogram -> IO HistogramSample+observeAndSample x = flip atomicModifyIORef' update . unHistogram   where-    update histData = (hist' histData, ())+    update histData = (hist' histData, histData)     hist' histData =         histData { histBuckets = updateBuckets x $ histBuckets histData                  , histSum = histSum histData + x                  , histCount = histCount histData + 1                  }+++observe :: Double -> Histogram -> IO ()+observe x = void . observeAndSample x   updateBuckets :: Double -> Buckets -> Buckets