distributed-process-ekg 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+25/−13 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- System.Metrics.DistributedProcess: registerLocalNodeMetrics :: LocalNode -> Store -> IO ()
+ System.Metrics.DistributedProcess: registerLocalNodeMetrics :: LocalNode -> Store -> IO ProcessId
Files
- CHANGELOG.md +7/−0
- distributed-process-ekg.cabal +1/−1
- src/System/Metrics/DistributedProcess.hs +17/−12
CHANGELOG.md view
@@ -3,11 +3,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.1.0] - 2016-03-10++### Changed++- Wrap metric sampling in a looped process to prevent trace spam.+ ## [0.1.0.0] - 2016-02-27 ### Added - registerLocalNodeMetrics +[0.1.1.0]: https://bitbucket.org/dpwiz/distributed-process-ekg/commits/tag/0.1.1.0 [0.1.0.0]: https://bitbucket.org/dpwiz/distributed-process-ekg/commits/tag/0.1.0.0
distributed-process-ekg.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: distributed-process-ekg-version: 0.1.0.0+version: 0.1.1.0 synopsis: Collect node stats for EKG category: System, Network license: BSD3
src/System/Metrics/DistributedProcess.hs view
@@ -2,24 +2,29 @@ ( registerLocalNodeMetrics ) where -import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)-import Control.Distributed.Process (NodeStats (..), getLocalNodeStats,- liftIO)-import Control.Distributed.Process.Node (LocalNode, runProcess)+import Control.Concurrent.MVar+import Control.Distributed.Process (NodeStats (..), Process, ProcessId,+ getLocalNodeStats, liftIO)+import Control.Distributed.Process.Node (LocalNode, forkProcess) import System.Metrics (Store, Value (..), registerGroup) import qualified Data.HashMap.Strict as HM import qualified Data.Text as T -registerLocalNodeMetrics :: LocalNode -> Store -> IO ()-registerLocalNodeMetrics node = registerGroup stats sample+registerLocalNodeMetrics :: LocalNode -> Store -> IO ProcessId+registerLocalNodeMetrics node store = do+ s <- newEmptyMVar+ registerGroup stats (sample s) store+ forkProcess node (collect s) where- sample :: IO NodeStats- sample = do- s <- newEmptyMVar- runProcess node- (getLocalNodeStats >>= liftIO . putMVar s)- takeMVar s+ -- Throw away stale stats first so collect can refresh them.+ sample :: MVar NodeStats -> IO NodeStats+ sample s =+ tryTakeMVar s >> takeMVar s++ collect :: MVar NodeStats -> Process ()+ collect s =+ getLocalNodeStats >>= liftIO . putMVar s >> collect s stats :: HM.HashMap T.Text (NodeStats -> Value) stats = HM.fromList