packages feed

mu-prometheus 0.4.0.0 → 0.5.0.0

raw patch · 2 files changed

+21/−19 lines, 2 filesdep ~mu-rpcnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: mu-rpc

API changes (from Hackage documentation)

Files

mu-prometheus.cabal view
@@ -1,9 +1,7 @@ name:          mu-prometheus-version:       0.4.0.0+version:       0.5.0.0 synopsis:      Metrics support for Mu using Prometheus-description:-  Get metrics of your running Mu servers using Prometheus-+description:   Get metrics of your running Mu servers using Prometheus license:       Apache-2.0 license-file:  LICENSE author:        Alejandro Serrano@@ -20,18 +18,16 @@   location: https://github.com/higherkindness/mu-haskell  library-  exposed-modules:-    Mu.Instrumentation.Prometheus-+  exposed-modules:  Mu.Instrumentation.Prometheus   build-depends:-      base                  >=4.12 && <5-    , lifted-base           >=0.2  && <0.3-    , monad-control         >1     && <2-    , mu-rpc                ==0.4.*-    , prometheus-client     >1     && <2-    , text                  >=1.2  && <2-    , wai                   >=3.2  && <4-    , wai-middleware-prometheus >1 && <2+      base                       >=4.12 && <5+    , lifted-base                >=0.2  && <0.3+    , monad-control              >1     && <2+    , mu-rpc                     >=0.5  && <0.6+    , prometheus-client          >1     && <2+    , text                       >=1.2  && <2+    , wai                        >=3.2  && <4+    , wai-middleware-prometheus  >1     && <2    hs-source-dirs:   src   default-language: Haskell2010
src/Mu/Instrumentation/Prometheus.hs view
@@ -49,17 +49,23 @@ prometheusMetrics metrics NoRpcInfo run = do   incGauge (activeCalls metrics)   run `finally` decGauge (activeCalls metrics)-prometheusMetrics metrics (RpcInfo _pkg (Service sname _) (Method mname _ _) _ _) run = do+prometheusMetrics metrics (RpcInfo _pkg ss mm _ _) run = do+  let sname' = case ss of+                 Service sname _ -> sname+                 OneOf   sname _ -> sname+      mname' = case mm of+                 Just (Method mname _ _) -> mname+                 Nothing                 -> "<noname>"   incGauge (activeCalls metrics)-  withLabel (messagesReceived metrics) (sname, mname) incCounter+  withLabel (messagesReceived metrics) (sname', mname') incCounter   ( do -- We are forced to use a MVar because 'withLabel' only allows IO ()        r <- liftBaseWith $ \runInIO -> do          result :: MVar (StM m a) <- newEmptyMVar-         withLabel (callsTotal metrics) (sname, mname) $ \h ->+         withLabel (callsTotal metrics) (sname', mname') $ \h ->            h `observeDuration` (runInIO run >>= putMVar result)          takeMVar result        x <- restoreM r-       withLabel (messagesSent metrics) (sname, mname) incCounter+       withLabel (messagesSent metrics) (sname', mname') incCounter        pure x )   `finally` decGauge (activeCalls metrics)