network-metrics 0.2.0 → 0.2.1
raw patch · 4 files changed
+60/−73 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- 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
+ Network.Metric.Sink.Handle: Counter :: Group -> Bucket -> Integer -> Metric
+ Network.Metric.Sink.Handle: Gauge :: Group -> Bucket -> Double -> Metric
+ Network.Metric.Sink.Handle: SinkHandle :: Host -> (String -> IO ()) -> SinkHandle
+ Network.Metric.Sink.Handle: Timer :: Group -> Bucket -> Double -> Metric
+ Network.Metric.Sink.Handle: class Sink a
+ Network.Metric.Sink.Handle: close :: Sink a => a -> IO ()
+ Network.Metric.Sink.Handle: data Metric
+ Network.Metric.Sink.Handle: data SinkHandle
+ Network.Metric.Sink.Handle: instance Sink SinkHandle
+ Network.Metric.Sink.Handle: push :: (Sink a, Measurable b) => a -> b -> IO ()
+ Network.Metric.Sink.Handle: type Bucket = ByteString
+ Network.Metric.Sink.Handle: type Group = ByteString
Files
- network-metrics.cabal +2/−2
- src/Network/Metric.hs +5/−5
- src/Network/Metric/Sink/Handle.hs +53/−0
- src/Network/Metric/Sink/SinkHandle.hs +0/−66
network-metrics.cabal view
@@ -1,5 +1,5 @@ name: network-metrics-version: 0.2.0+version: 0.2.1 synopsis: Send metrics to Ganglia, Graphite, and statsd. license: OtherLicense license-file: LICENSE@@ -32,7 +32,7 @@ , Network.Metric.Sink.Ganglia , Network.Metric.Sink.Graphite , Network.Metric.Sink.Statsd- , Network.Metric.Sink.SinkHandle+ , Network.Metric.Sink.Handle 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.SinkHandle as HandleSink+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.Handle as H -- | 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 = HandleSink.open+open Stdout = \h _ _ -> return . AnySink $ H.SinkHandle h putStrLn
+ src/Network/Metric/Sink/Handle.hs view
@@ -0,0 +1,53 @@+-- |+-- Module : Network.Metric.Sink.Handle+-- 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.Handle (+ -- * Exported Types+ SinkHandle(..)++ -- * Re-exports+ , Group+ , Bucket+ , Metric(..)+ , Sink(..)+ ) 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 ()++--+-- 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/SinkHandle.hs
@@ -1,66 +0,0 @@--- |--- 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]