1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

More beautification.

This commit is contained in:
Rob Rix 2018-04-03 14:16:36 -04:00
parent 0ce1bdcaeb
commit 3b2c8577a4

View File

@ -22,26 +22,27 @@ module Semantic.Stat
) where ) where
import Prologue
import Data.List (intercalate)
import Data.List.Split (splitOneOf)
import Network.Socket (Socket(..), SocketType(..), socket, connect, close, getAddrInfo, addrFamily, addrAddress, defaultProtocol)
import Network.Socket.ByteString
import Network.URI
import Numeric
import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Char8 as B
import System.Environment import Data.List (intercalate)
import System.IO.Error import Data.List.Split (splitOneOf)
import qualified Data.Time.Clock as Time import qualified Data.Time.Clock as Time
import qualified Data.Time.Clock.POSIX as Time (getCurrentTime) import qualified Data.Time.Clock.POSIX as Time (getCurrentTime)
import Network.Socket
(Socket (..), SocketType (..), addrAddress, addrFamily, close, connect, defaultProtocol, getAddrInfo, socket)
import Network.Socket.ByteString
import Network.URI
import Numeric
import Prologue
import System.Environment
import System.IO.Error
-- | A named piece of data you wish to record a specific 'Metric' for. -- | A named piece of data you wish to record a specific 'Metric' for.
-- See https://docs.datadoghq.com/guides/dogstatsd/ for more details. -- See https://docs.datadoghq.com/guides/dogstatsd/ for more details.
data Stat data Stat
= Stat = Stat
{ statName :: String -- ^ Stat name, usually separated by '.' (e.g. "system.metric.name") { statName :: String -- ^ Stat name, usually separated by '.' (e.g. "system.metric.name")
, statValue :: Metric -- ^ 'Metric' value. , statValue :: Metric -- ^ 'Metric' value.
, statTags :: Tags -- ^ Key/value 'Tags' (optional). , statTags :: Tags -- ^ Key/value 'Tags' (optional).
} }
-- | The various supported metric types in Datadog. -- | The various supported metric types in Datadog.
@ -99,8 +100,8 @@ data StatsClient
= StatsClient = StatsClient
{ statsClientUDPSocket :: Socket { statsClientUDPSocket :: Socket
, statsClientNamespace :: String , statsClientNamespace :: String
, statsClientUDPHost :: String , statsClientUDPHost :: String
, statsClientUDPPort :: String , statsClientUDPPort :: String
} }
-- | Create a default stats client. This function consults two optional -- | Create a default stats client. This function consults two optional
@ -193,7 +194,7 @@ instance Render Tags where
renders xs = renderString "|#" . (\x -> x <> intercalate "," (renderTag <$> xs)) renders xs = renderString "|#" . (\x -> x <> intercalate "," (renderTag <$> xs))
where where
renderTag (k, "") = k renderTag (k, "") = k
renderTag (k, v) = k <> ":" <> v renderTag (k, v) = k <> ":" <> v
instance Render Int where instance Render Int where
renders = shows renders = shows