packages feed

network-metrics 0.1.9 → 0.2.0

raw patch · 4 files changed

+74/−64 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Network.Metric.Sink.Stdout: Counter :: Group -> Bucket -> Integer -> Metric
- Network.Metric.Sink.Stdout: Gauge :: Group -> Bucket -> Double -> Metric
- Network.Metric.Sink.Stdout: Timer :: Group -> Bucket -> Double -> Metric
- Network.Metric.Sink.Stdout: class Sink a
- Network.Metric.Sink.Stdout: close :: Sink a => a -> IO ()
- Network.Metric.Sink.Stdout: data Metric
- Network.Metric.Sink.Stdout: instance Show Stdout
- Network.Metric.Sink.Stdout: instance Sink Stdout
- Network.Metric.Sink.Stdout: open :: Host -> HostName -> PortNumber -> IO AnySink
- Network.Metric.Sink.Stdout: push :: (Sink a, Measurable b) => a -> b -> IO ()
- Network.Metric.Sink.Stdout: type Bucket = ByteString
- Network.Metric.Sink.Stdout: type Group = ByteString
+ Network.Metric.Sink.SinkHandle: Counter :: Group -> Bucket -> Integer -> Metric
+ Network.Metric.Sink.SinkHandle: Gauge :: Group -> Bucket -> Double -> Metric
+ Network.Metric.Sink.SinkHandle: SinkHandle :: Host -> (String -> IO ()) -> SinkHandle
+ Network.Metric.Sink.SinkHandle: Timer :: Group -> Bucket -> Double -> Metric
+ Network.Metric.Sink.SinkHandle: class Sink a
+ Network.Metric.Sink.SinkHandle: close :: Sink a => a -> IO ()
+ Network.Metric.Sink.SinkHandle: data Metric
+ Network.Metric.Sink.SinkHandle: data SinkHandle
+ Network.Metric.Sink.SinkHandle: instance Sink SinkHandle
+ Network.Metric.Sink.SinkHandle: open :: Host -> HostName -> PortNumber -> IO AnySink
+ Network.Metric.Sink.SinkHandle: push :: (Sink a, Measurable b) => a -> b -> IO ()
+ Network.Metric.Sink.SinkHandle: type Bucket = ByteString
+ Network.Metric.Sink.SinkHandle: type Group = ByteString

Files

network-metrics.cabal view
@@ -1,5 +1,5 @@ name:               network-metrics-version:            0.1.9+version:            0.2.0 synopsis:           Send metrics to Ganglia, Graphite, and statsd. license:            OtherLicense license-file:       LICENSE@@ -14,7 +14,7 @@  description:     .-    Send metrics directly from Haskell various monitoring and metrics services.+    Send metrics directly from Haskell to various monitoring and metrics services.     .     Supported services are Ganglia, Graphite, and statsd.     .@@ -27,13 +27,12 @@   type:     git   location: git://github.com/brendanhay/network-metrics.git - library   exposed-modules:  Network.Metric                   , Network.Metric.Sink.Ganglia                   , Network.Metric.Sink.Graphite                   , Network.Metric.Sink.Statsd-                  , Network.Metric.Sink.Stdout+                  , Network.Metric.Sink.SinkHandle   other-modules:    Network.Metric.Internal    hs-source-dirs:   src
src/Network/Metric.hs view
@@ -29,10 +29,10 @@ import Data.Data               (Data, Typeable) import Network.Metric.Internal -import qualified Network.Metric.Sink.Ganglia  as GangliaSink-import qualified Network.Metric.Sink.Graphite as GraphiteSink-import qualified Network.Metric.Sink.Statsd   as StatsdSink-import qualified Network.Metric.Sink.Stdout   as StdoutSink+import qualified Network.Metric.Sink.Ganglia    as GangliaSink+import qualified Network.Metric.Sink.Graphite   as GraphiteSink+import qualified Network.Metric.Sink.Statsd     as StatsdSink+import qualified Network.Metric.Sink.SinkHandle as HandleSink  -- | An enumeration of supplied sink types data SinkType =@@ -51,4 +51,4 @@ open Ganglia  = GangliaSink.open open Graphite = GraphiteSink.open open Statsd   = StatsdSink.open-open Stdout   = StdoutSink.open+open Stdout   = HandleSink.open
+ src/Network/Metric/Sink/SinkHandle.hs view
@@ -0,0 +1,66 @@+-- |+-- Module      : Network.Metric.Sink.SinkHandle+-- Copyright   : (c) 2012 Brendan Hay <brendan@soundcloud.com>+-- License     : This Source Code Form is subject to the terms of+--               the Mozilla Public License, v. 2.0.+--               A copy of the MPL can be found in the LICENSE file or+--               you can obtain it at http://mozilla.org/MPL/2.0/.+-- Maintainer  : Brendan Hay <brendan@soundcloud.com>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--++module Network.Metric.Sink.SinkHandle (+    -- * Exported Types+      SinkHandle(..)++    -- * Sink Functions+    , open+    , Sink(..)++    -- * Re-exports+    , Group+    , Bucket+    , Metric(..)+    ) where++import Network.Metric.Internal++import qualified Data.ByteString.Char8 as BS++-- | A generic sink handle+data SinkHandle = SinkHandle Host (String -> IO ())++instance Sink SinkHandle where+    push h = mapM_ enc . measure+      where+        enc (Counter g b v) = put "Counter" h g b v+        enc (Timer g b v)   = put "Timer" h g b v+        enc (Gauge g b v)   = put "Gauge" h g b v++    close _ = return ()++--+-- API+--++-- | Open a new sink to stdout, conforming to the interface in Metric.hs+-- .+-- If you want to create a sink to a given handle fn, use the exported SinkHandle constructor+open :: Host -> HostName -> PortNumber -> IO AnySink+open host _ _ = return . AnySink $ SinkHandle host putStrLn++--+-- Private+--++put :: Encodable a+    => BS.ByteString+    -> SinkHandle+    -> Group+    -> Bucket+    -> a+    -> IO ()+put p (SinkHandle h f) g b v = f msg+  where+    msg = BS.unpack $ BS.concat [p, ": ", key h g b, " ", encode v]
− src/Network/Metric/Sink/Stdout.hs
@@ -1,55 +0,0 @@--- |--- Module      : Network.Metric.Sink.Stdout--- Copyright   : (c) 2012 Brendan Hay <brendan@soundcloud.com>--- License     : This Source Code Form is subject to the terms of---               the Mozilla Public License, v. 2.0.---               A copy of the MPL can be found in the LICENSE file or---               you can obtain it at http://mozilla.org/MPL/2.0/.--- Maintainer  : Brendan Hay <brendan@soundcloud.com>--- Stability   : experimental--- Portability : non-portable (GHC extensions)-----module Network.Metric.Sink.Stdout (-    -- * Sink Functions-      open-    , Sink(..)--    -- * Re-exports-    , Group-    , Bucket-    , Metric(..)-    ) where--import Network.Metric.Internal--import qualified Data.ByteString.Char8 as BS---- | A handle to a stdout sink-data Stdout = Stdout Host deriving (Show)--instance Sink Stdout where-    push (Stdout host) = mapM_ enc . measure-      where-        enc (Counter g b v) = put "Counter" host g b v-        enc (Timer g b v)   = put "Timer" host g b v-        enc (Gauge g b v)   = put "Gauge" host g b v--    close _ = return ()------- API------- | Open a new Stdout sink-open :: Host -> HostName -> PortNumber -> IO AnySink-open host _ _ = return . AnySink $ Stdout host------- Private-----put :: Encodable a => BS.ByteString -> Host -> Group -> Bucket -> a -> IO ()-put prefix host group bucket value = putStrLn s-  where-    s = BS.unpack $ BS.concat [prefix, ": ", key host group bucket, " ", encode value]