prometheus 2.1.3 → 2.2.1
raw patch · 4 files changed
+35/−25 lines, 4 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
- System.Metrics.Prometheus.Http.Scrape: serveHttpTextMetrics :: MonadIO m => Port -> Path -> IO RegistrySample -> m ()
- System.Metrics.Prometheus.Http.Scrape: serveHttpTextMetricsT :: MonadIO m => Port -> Path -> RegistryT m ()
+ System.Metrics.Prometheus.Http.Scrape: serveMetrics :: MonadIO m => Port -> Path -> IO RegistrySample -> m ()
+ System.Metrics.Prometheus.Http.Scrape: serveMetricsT :: MonadIO m => Port -> Path -> RegistryT m ()
Files
- Example.hs +2/−2
- README.md +12/−2
- prometheus.cabal +15/−15
- src/System/Metrics/Prometheus/Http/Scrape.hs +6/−6
Example.hs view
@@ -3,7 +3,7 @@ module Example where import Control.Monad.IO.Class (liftIO)-import System.Metrics.Prometheus.Http.Scrape (serveHttpTextMetricsT)+import System.Metrics.Prometheus.Http.Scrape (serveMetricsT) import System.Metrics.Prometheus.Concurrent.RegistryT import System.Metrics.Prometheus.Metric.Counter (inc) import System.Metrics.Prometheus.MetricId@@ -20,4 +20,4 @@ -- [...] pass metric handles to the rest of the app - serveHttpTextMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server+ serveMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server
README.md view
@@ -25,7 +25,7 @@ module Example where import Control.Monad.IO.Class (liftIO)-import System.Metrics.Prometheus.Http.Scrape (serveHttpTextMetricsT)+import System.Metrics.Prometheus.Http.Scrape (serveMetricsT) import System.Metrics.Prometheus.Concurrent.RegistryT import System.Metrics.Prometheus.Metric.Counter (inc) import System.Metrics.Prometheus.MetricId@@ -42,7 +42,7 @@ -- [...] pass metric handles to the rest of the app - serveHttpTextMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server+ serveMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server ``` ## Advanced Usage@@ -50,6 +50,16 @@ A `Registry` and `StateT`-based `RegistryT` are available for unit testing or generating lists of `[IO a]` actions that can be `sequenced` and returned from pure code to be applied.++## Concurrency Model++Metrics are "values" and the Registry is the map of "name_labels" to metric "keys".++Metrics may be created/registered at any point, not just at start up, in the `RegistryT` monad transformer. Thread the `RegistryT` through your transformer stack to tell the type system you intend to register new metrics in that call stack. The `RegistryT` has a thread safe version in the `Concurrent` module.++The metrics are thread safe on their own and do not require locking the entire registry to update them. They use high performance check-and-set atomic primitives. This is because metrics may be updated many times in between scrapes where the Reigstry needs to be lock. You do NOT want to lock all the metrics just to update one.++The scraping operation of the server to collect all the metrics locks the registry to ensure no new metrics are being created/keyed in a race with the scrape. ## Tasks
prometheus.cabal view
@@ -1,5 +1,5 @@ name: prometheus-version: 2.1.3+version: 2.2.1 synopsis: Prometheus Haskell Client homepage: http://github.com/bitnomial/prometheus bug-reports: http://github.com/bitnomial/prometheus/issues@@ -7,7 +7,7 @@ license-file: LICENSE author: Luke Hoersten maintainer: luke@bitnomial.com, opensource@bitnomial.com-copyright: Bitnomial, Inc. (c) 2016-2018+copyright: Bitnomial, Inc. (c) 2016-2019 category: Metrics, Monitoring, Web, System build-type: Simple cabal-version: >=1.10@@ -31,7 +31,7 @@ > module Example where > > import Control.Monad.IO.Class (liftIO)- > import System.Metrics.Prometheus.Http.Scrape (serveHttpTextMetricsT)+ > import System.Metrics.Prometheus.Http.Scrape (serveMetricsT) > import System.Metrics.Prometheus.Concurrent.RegistryT > import System.Metrics.Prometheus.Metric.Counter (inc) > import System.Metrics.Prometheus.MetricId@@ -48,7 +48,7 @@ > > -- [...] pass metric handles to the rest of the app >- > serveHttpTextMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server+ > serveMetricsT 8080 ["metrics"] -- http://localhost:8080/metric server > . [Advanced Usage]@@ -82,18 +82,18 @@ , System.Metrics.Prometheus.Registry , System.Metrics.Prometheus.RegistryT - build-depends: base >= 4.9 && < 4.14- , atomic-primops >= 0.8 && < 0.9- , bytestring >= 0.10 && < 0.11- , containers >= 0.5 && < 0.7- , http-client >= 0.4 && < 0.7+ build-depends: base >= 4.9 && < 5+ , atomic-primops >= 0.8 && < 0.9+ , bytestring >= 0.10 && < 0.11+ , containers >= 0.5 && < 0.7+ , http-client >= 0.4 && < 0.7 , http-client-tls >= 0.3 && < 0.4- , http-types >= 0.8 && < 0.13- , network-uri >= 2.5 && < 2.7- , text >= 1.2 && < 1.3- , transformers >= 0.4 && < 0.6- , wai >= 3.2 && < 3.3- , warp >= 3.2 && < 3.5+ , http-types >= 0.8 && < 0.13+ , network-uri >= 2.5 && < 2.7+ , text >= 1.2 && < 1.3+ , transformers >= 0.4 && < 0.6+ , wai >= 3.2 && < 3.3+ , warp >= 3.2 && < 3.5 source-repository head type: git
src/System/Metrics/Prometheus/Http/Scrape.hs view
@@ -2,8 +2,8 @@ module System.Metrics.Prometheus.Http.Scrape ( Path- , serveHttpTextMetrics- , serveHttpTextMetricsT+ , serveMetrics+ , serveMetricsT , prometheusApp ) where@@ -40,12 +40,12 @@ type Path = [Text] -serveHttpTextMetrics :: MonadIO m => Port -> Path -> IO RegistrySample -> m ()-serveHttpTextMetrics port path = liftIO . run port . prometheusApp path+serveMetrics :: MonadIO m => Port -> Path -> IO RegistrySample -> m ()+serveMetrics port path = liftIO . run port . prometheusApp path -serveHttpTextMetricsT :: MonadIO m => Port -> Path -> RegistryT m ()-serveHttpTextMetricsT port path = liftIO . serveHttpTextMetrics port path =<< sample+serveMetricsT :: MonadIO m => Port -> Path -> RegistryT m ()+serveMetricsT port path = liftIO . serveMetrics port path =<< sample prometheusApp :: Path -> IO RegistrySample -> Application