ekg-statsd 0.2.1.1 → 0.2.2.0
raw patch · 3 files changed
+13/−35 lines, 3 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGES.md +5/−0
- System/Remote/Monitoring/Statsd.hs +4/−33
- ekg-statsd.cabal +4/−2
CHANGES.md view
@@ -1,3 +1,8 @@+## 0.2.2.0 (2017-09-25)++ * Remove internal `diffSample` optimisation and always report the full+ state of the `Store` instead of only what's changed between iterations.+ ## 0.2.1.1 (2017-07-31) * Support GHC 8.2.1.
System/Remote/Monitoring/Statsd.hs view
@@ -132,7 +132,7 @@ return (sendSample, Socket.close socket) me <- myThreadId- tid <- forkFinally (loop store emptySample sendSample opts) $ \ r -> do+ tid <- forkFinally (loop store sendSample opts) $ \ r -> do closeSocket case r of Left e -> throwTo me e@@ -141,52 +141,23 @@ where unsupportedAddressError = ioError $ userError $ "unsupported address: " ++ T.unpack (host opts)- emptySample = M.empty loop :: Metrics.Store -- ^ Metric store- -> Metrics.Sample -- ^ Last sampled metrics -> (B8.ByteString -> IO ()) -- ^ Action to send a sample -> StatsdOptions -- ^ Options -> IO ()-loop store lastSample sendSample opts = do+loop store sendSample opts = do start <- time sample <- Metrics.sampleAll store- let !diff = diffSamples lastSample sample- flushSample diff sendSample opts+ flushSample sample sendSample opts end <- time threadDelay (flushInterval opts * 1000 - fromIntegral (end - start))- loop store sample sendSample opts+ loop store sendSample opts -- | Microseconds since epoch. time :: IO Int64 time = (round . (* 1000000.0) . toDouble) `fmap` getPOSIXTime where toDouble = realToFrac :: Real a => a -> Double--diffSamples :: Metrics.Sample -> Metrics.Sample -> Metrics.Sample-diffSamples prev curr = M.foldlWithKey' combine M.empty curr- where- combine m name new = case M.lookup name prev of- Just old -> case diffMetric old new of- Just val -> M.insert name val m- Nothing -> m- _ -> M.insert name new m-- diffMetric :: Metrics.Value -> Metrics.Value -> Maybe Metrics.Value- diffMetric (Metrics.Counter n1) (Metrics.Counter n2)- | n1 == n2 = Nothing- | otherwise = Just $! Metrics.Counter $ n2 - n1- diffMetric (Metrics.Gauge n1) (Metrics.Gauge n2)- | n1 == n2 = Nothing- | otherwise = Just $ Metrics.Gauge n2- diffMetric (Metrics.Label n1) (Metrics.Label n2)- | n1 == n2 = Nothing- | otherwise = Just $ Metrics.Label n2- diffMetric (Metrics.Distribution d1) (Metrics.Distribution d2)- | Distribution.count d1 == Distribution.count d2 = Nothing- | otherwise = Just $ Metrics.Distribution $ d2- { Distribution.count = Distribution.count d2 - Distribution.count d1- }- diffMetric _ _ = Nothing flushSample :: Metrics.Sample -> (B8.ByteString -> IO ()) -> StatsdOptions -> IO () flushSample sample sendSample opts = do
ekg-statsd.cabal view
@@ -1,5 +1,5 @@ name: ekg-statsd-version: 0.2.1.1+version: 0.2.2.0 synopsis: Push metrics to statsd description: This library lets you push system metrics to a statsd server.@@ -8,11 +8,13 @@ license: BSD3 license-file: LICENSE author: Johan Tibell-maintainer: johan.tibell@gmail.com+maintainer: Johan Tibell <johan.tibell@gmail.com>,+ Mikhail Glushenkov <mikhail.glushenkov@gmail.com> category: System build-type: Simple extra-source-files: CHANGES.md cabal-version: >=1.10+tested-with: GHC==8.2.1, GHC==8.0.2, GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3 library exposed-modules: