packages feed

network-metrics 0.1.1 → 0.1.2

raw patch · 4 files changed

+23/−25 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Network.Metrics.Graphite: metricBucket :: Metric -> ByteString
- Network.Metrics.Graphite: metricValue :: Metric -> ByteString
- Network.Metrics.Statsd: metricBucket :: Metric -> ByteString
- Network.Metrics.Statsd: metricRate :: Metric -> Double
- Network.Metrics.Statsd: metricType :: Metric -> MetricType
- Network.Metrics.Statsd: metricValue :: Metric -> Integer
+ Network.Metrics.Graphite: bucket :: Metric -> ByteString
+ Network.Metrics.Graphite: value :: Metric -> ByteString
+ Network.Metrics.Statsd: bucket :: Metric -> ByteString
+ Network.Metrics.Statsd: rate :: Metric -> Double
+ Network.Metrics.Statsd: type' :: Metric -> MetricType
+ Network.Metrics.Statsd: value :: Metric -> Integer
- Network.Metrics.Ganglia: test :: IO a
+ Network.Metrics.Ganglia: test :: String -> String -> IO a

Files

network-metrics.cabal view
@@ -1,5 +1,5 @@ name:               network-metrics-version:            0.1.1+version:            0.1.2 synopsis:           Send metrics to Ganglia, Graphite, and statsd. license:            OtherLicense license-file:       LICENSE@@ -19,7 +19,7 @@     Supported services are Ganglia, Graphite, and statsd.     .     These modules are intended to be imported qualified, to avoid name-    clashes with other module, e.g.+    clashes with other modules, e.g.     .     > import qualified Network.Metrics.Ganglia  as A     > import qualified Network.Metrics.Graphite as B
src/Network/Metrics/Ganglia.hs view
@@ -31,17 +31,17 @@     , I.close     ) where -import Control.Concurrent             (threadDelay)-import Control.Monad                  (unless, liftM)+import Control.Concurrent (threadDelay)+import Control.Monad      (unless, liftM) import Data.Binary.Put-import Data.Bits                      ((.&.))-import Data.Char                      (toLower)-import Data.Data                      (Data, Typeable)-import Data.Default                   (Default, def)-import Data.Int                       (Int32)-import Data.Word                      (Word32)+import Data.Bits          ((.&.))+import Data.Char          (toLower)+import Data.Data          (Data, Typeable)+import Data.Default       (Default, def)+import Data.Int           (Int32)+import Data.Word          (Word32) import Network.Socket-import System.Random                  (randomRIO)+import System.Random      (randomRIO)  import qualified Data.ByteString          as B import qualified Data.ByteString.Char8    as BS@@ -198,10 +198,8 @@ sample xs = liftM (xs !!) (randomRIO (0, length xs - 1))  -- | Used to emit a default metric via GHCi-test :: IO a-test = do-    conn <- open "239.2.11.71" "8649"-    loop conn+test :: String -> String -> IO a+test host port = open host port >>= loop   where     loop h = do         r <- randomRIO variance :: IO Int
src/Network/Metrics/Graphite.hs view
@@ -31,8 +31,8 @@ import qualified Network.Metrics.Internal   as I  data Metric = Metric-    { metricBucket :: BS.ByteString-    , metricValue  :: BS.ByteString+    { bucket :: BS.ByteString+    , value  :: BS.ByteString     } deriving (Show)  --@@ -49,5 +49,5 @@     time <- getPOSIXTime     I.emit (encoded time) handle   where-    encoded n   = BL.fromChunks [metricBucket, metricValue, timestamp n]+    encoded n   = BL.fromChunks [bucket, value, timestamp n]     timestamp n = BS.pack $ show (truncate n :: Integer)
src/Network/Metrics/Statsd.hs view
@@ -34,10 +34,10 @@ data MetricType = Counter | Timer | Gauge deriving (Show)  data Metric = Metric-    { metricType   :: MetricType-    , metricBucket :: BS.ByteString-    , metricValue  :: Integer-    , metricRate   :: Double+    { type'  :: MetricType+    , bucket :: BS.ByteString+    , value  :: Integer+    , rate   :: Double     } deriving (Show)  data Sampled = Sampled | Exact | Ignore@@ -56,7 +56,7 @@     rand <- randomRIO (0.0, 1.0)     I.emit (encoded rand) handle   where-    encoded = BL.fromChunks . components metric . sample (metricRate metric)+    encoded = BL.fromChunks . components metric . sample (rate metric)  -- -- Sampling@@ -69,11 +69,11 @@  components :: Metric -> Sampled -> [BS.ByteString] components Metric{..} sampled = case sampled of-    Sampled -> base ++ ["@", BS.pack $ show metricRate]+    Sampled -> base ++ ["@", BS.pack $ show rate]     Exact   -> base     Ignore  -> []   where-    base = [metricBucket, ":", BS.pack $ show metricValue, "|", suffix metricType]+    base = [bucket, ":", BS.pack $ show value, "|", suffix type']  suffix :: MetricType -> BS.ByteString suffix typ = case typ of