ekg-statsd 0.2.2.0 → 0.2.3.0
raw patch · 3 files changed
+35/−16 lines, 3 filesdep ~networkPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: network
API changes (from Hackage documentation)
+ System.Remote.Monitoring.Statsd: statsdFlush :: Statsd -> IO ()
Files
- CHANGES.md +11/−4
- System/Remote/Monitoring/Statsd.hs +20/−9
- ekg-statsd.cabal +4/−3
CHANGES.md view
@@ -1,12 +1,20 @@+## 0.2.3.0 (2018-04-10)++ * API addition: 'statsdFlush', allows to flush the sample to statsd+ server manually+ ([#18](https://github.com/tibbe/ekg-statsd/pull/18)).+ ## 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.+ * Remove internal `diffSample` optimisation and always report the+ full state of the `Store` instead of only what's changed between+ iterations ([#17](https://github.com/tibbe/ekg-statsd/pull/17)). ## 0.2.1.1 (2017-07-31) * Support GHC 8.2.1.- * Suppress errors when sending to a non-existent receiver (#6).+ * Suppress errors when sending to a non-existent receiver+ ([#6](https://github.com/tibbe/ekg-statsd/pull/6)). ## 0.2.1.0 (2016-08-11) @@ -37,4 +45,3 @@ ## 0.1.0.0 (2014-05-01) * Initial release.-
System/Remote/Monitoring/Statsd.hs view
@@ -17,6 +17,7 @@ ( -- * The statsd syncer Statsd+ , statsdFlush , statsdThreadId , forkStatsd , StatsdOptions(..)@@ -52,6 +53,7 @@ -- Created by 'forkStatsd'. data Statsd = Statsd { threadId :: {-# UNPACK #-} !ThreadId+ , flush :: IO () } -- | The thread ID of the statsd sync thread. You can stop the sync by@@ -60,6 +62,12 @@ statsdThreadId :: Statsd -> ThreadId statsdThreadId = threadId +-- | Flush a sample to the statsd server+--+-- @since 0.2.3.0+statsdFlush :: Statsd -> IO ()+statsdFlush = flush+ -- | Options to control how to connect to the statsd server and how -- often to flush metrics. The flush interval should be shorter than -- the flush interval statsd itself uses to flush data to its@@ -131,28 +139,31 @@ return (sendSample, Socket.close socket) + let flush = do+ sample <- Metrics.sampleAll store+ flushSample sample sendSample opts+ me <- myThreadId- tid <- forkFinally (loop store sendSample opts) $ \ r -> do+ tid <- forkFinally (loop opts flush) $ \ r -> do closeSocket case r of Left e -> throwTo me e Right _ -> return ()- return $ Statsd tid++ return $ Statsd tid flush where unsupportedAddressError = ioError $ userError $ "unsupported address: " ++ T.unpack (host opts) -loop :: Metrics.Store -- ^ Metric store- -> (B8.ByteString -> IO ()) -- ^ Action to send a sample- -> StatsdOptions -- ^ Options+loop :: StatsdOptions -- ^ Options+ -> IO () -- ^ Action to flush the sample -> IO ()-loop store sendSample opts = do+loop opts flush = do start <- time- sample <- Metrics.sampleAll store- flushSample sample sendSample opts+ flush end <- time threadDelay (flushInterval opts * 1000 - fromIntegral (end - start))- loop store sendSample opts+ loop opts flush -- | Microseconds since epoch. time :: IO Int64
ekg-statsd.cabal view
@@ -1,5 +1,5 @@ name: ekg-statsd-version: 0.2.2.0+version: 0.2.3.0 synopsis: Push metrics to statsd description: This library lets you push system metrics to a statsd server.@@ -14,14 +14,15 @@ 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+tested-with: GHC == 8.4.1, GHC == 8.2.2, GHC == 8.0.2,+ GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3 library exposed-modules: System.Remote.Monitoring.Statsd build-depends:- base >= 4.5 && < 4.11,+ base >= 4.5 && < 4.12, bytestring < 1.0, ekg-core >= 0.1 && < 1.0, network < 2.7,