ekg-statsd 0.2.0.4 → 0.2.1.0
raw patch · 3 files changed
+27/−8 lines, 3 filesdep ~timePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: time
API changes (from Hackage documentation)
Files
- CHANGES.md +5/−0
- System/Remote/Monitoring/Statsd.hs +20/−6
- ekg-statsd.cabal +2/−2
CHANGES.md view
@@ -1,3 +1,8 @@+## 0.2.1.0 (2016-08-11)++ * Send distributions as gauges and counters.+ * Update examples.+ ## 0.2.0.4 (2016-05-28) * GHC 8.0 support.
System/Remote/Monitoring/Statsd.hs view
@@ -37,6 +37,7 @@ import qualified Network.Socket as Socket import qualified Network.Socket.ByteString as Socket import qualified System.Metrics as Metrics+import qualified System.Metrics.Distribution.Internal as Distribution import System.IO (stderr) #if __GLASGOW_HASKELL__ >= 706@@ -170,18 +171,31 @@ diffMetric (Metrics.Label n1) (Metrics.Label n2) | n1 == n2 = Nothing | otherwise = Just $ Metrics.Label n2- -- Distributions are assumed to be non-equal.+ 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 -> Socket.Socket -> StatsdOptions -> IO ()-flushSample sample socket opts = do- forM_ (M.toList $ sample) $ \ (name, val) ->+flushSample sample socket opts =+ forM_ (M.toList sample) $ \ (name, val) -> let fullName = dottedPrefix <> name <> dottedSuffix in flushMetric fullName val where- flushMetric name (Metrics.Counter n) = send "|c" name (show n)- flushMetric name (Metrics.Gauge n) = send "|g" name (show n)- flushMetric _ _ = return ()+ flushMetric name (Metrics.Counter n) = send "|c" name (show n)+ flushMetric name (Metrics.Gauge n) = send "|g" name (show n)+ flushMetric name (Metrics.Distribution d) = sendDistribution name d+ flushMetric _ (Metrics.Label _) = return ()++ sendDistribution name d = do+ send "|g" (name <> "." <> "mean" ) (show $ Distribution.mean d)+ send "|g" (name <> "." <> "variance") (show $ Distribution.variance d)+ send "|c" (name <> "." <> "count" ) (show $ Distribution.count d)+ send "|g" (name <> "." <> "sum" ) (show $ Distribution.sum d)+ send "|g" (name <> "." <> "min" ) (show $ Distribution.min d)+ send "|g" (name <> "." <> "max" ) (show $ Distribution.max d) isDebug = debug opts dottedPrefix = if T.null (prefix opts) then "" else prefix opts <> "."
ekg-statsd.cabal view
@@ -1,5 +1,5 @@ name: ekg-statsd-version: 0.2.0.4+version: 0.2.1.0 synopsis: Push metrics to statsd description: This library lets you push system metrics to a statsd server.@@ -24,7 +24,7 @@ ekg-core >= 0.1 && < 1.0, network < 2.7, text < 1.3,- time < 1.6,+ time < 1.7, unordered-containers < 0.3 default-language: Haskell2010