packages feed

prometheus 0.1.1 → 0.2.0

raw patch · 4 files changed

+19/−15 lines, 4 files

Files

prometheus.cabal view
@@ -1,5 +1,5 @@ name:                prometheus-version:             0.1.1+version:             0.2.0 synopsis:            Prometheus Haskell Client homepage:            http://github.com/LukeHoersten/prometheus#readme bug-reports:         http://github.com/LukeHoersten/prometheus/issues@@ -22,8 +22,6 @@   .   [Usage Example]   .-  > {-# LANGUAGE OverloadedStrings #-}-  >   > module Example where   >   > import           System.Metrics.Prometheus.GlobalRegistry
src/System/Metrics/Prometheus/Encode.hs view
@@ -33,8 +33,8 @@   encodeMetrics :: RegistrySample -> Builder-encodeMetrics = mconcat . intersperse "\n\n" . map encodeMetricGroup . groupByName-    . Map.toList . unRegistrySample+encodeMetrics = (<> newline) . mconcat . intersperse newline . map encodeMetricGroup+    . groupByName . Map.toList . unRegistrySample   where groupByName = groupBy ((==) `on` (name . fst))  
src/System/Metrics/Prometheus/Http.hs view
@@ -2,7 +2,7 @@  module System.Metrics.Prometheus.Http where -+import           Data.Text                                (Text) import           Network.HTTP.Types                       (hContentType,                                                            methodGet, status200,                                                            status404)@@ -18,16 +18,23 @@                                                            sample)  -serveHttpTextMetrics :: Port -> GlobalRegistry -> IO ()-serveHttpTextMetrics port = run port . prometheusApp+type Path = [Text]  -prometheusApp :: GlobalRegistry -> Application-prometheusApp globalRegistry request respond+serveHttpTextMetricsDef :: Port -> GlobalRegistry -> IO ()+serveHttpTextMetricsDef = serveHttpTextMetrics ["metrics"]+++serveHttpTextMetrics :: Path -> Port -> GlobalRegistry -> IO ()+serveHttpTextMetrics path port = run port . prometheusApp path+++prometheusApp :: Path -> GlobalRegistry -> Application+prometheusApp path globalRegistry request respond     | prometheusRequest = prometheusResponse respond globalRegistry     | otherwise = respond $ responseLBS status404 header404 body404   where-    prometheusRequest = requestMethod request == methodGet && pathInfo request == ["metrics"]+    prometheusRequest = requestMethod request == methodGet && pathInfo request == path     header404 = [(hContentType, "text/plain")]     body404 = "404" @@ -36,4 +43,4 @@ prometheusResponse respond gr =     respond . responseBuilder status200 headers . encodeMetrics =<< sample gr   where-      headers = [(hContentType, "text/plain; version=0.0.4")]+    headers = [(hContentType, "text/plain; version=0.0.4")]
src/System/Metrics/Prometheus/Metric/Histogram.hs view
@@ -11,6 +11,7 @@        ) where  +import           Data.Bool  (bool) import           Data.IORef (IORef, atomicModifyIORef', newIORef, readIORef) import           Data.Map   (Map) import qualified Data.Map   as Map@@ -52,9 +53,7 @@  updateBuckets :: Double -> Buckets -> Buckets updateBuckets x = Map.mapWithKey updateBucket-  where updateBucket key val-            | x <= key  = val + 1-            | otherwise = val+  where updateBucket key val = bool val (val + 1) (x <= key)   sample :: Histogram -> IO HistogramSample