| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.StatsD.Datadog
Description
DogStatsD accepts custom application metrics points over UDP, and then periodically aggregates and forwards the metrics to Datadog, where they can be graphed on dashboards. The data is sent by using a client library such as this one that communicates with a DogStatsD server.
Synopsis
- data DogStatsSettings = DogStatsSettings {}
- defaultSettings :: DogStatsSettings
- withDogStatsD :: MonadUnliftIO m => DogStatsSettings -> (StatsClient -> m a) -> m a
- mkStatsClient :: MonadIO m => DogStatsSettings -> m StatsClient
- finalizeStatsClient :: MonadIO m => StatsClient -> m ()
- send :: (MonadIO m, ToStatsD v) => StatsClient -> v -> m ()
- metric :: ToMetricValue a => MetricName -> MetricType -> a -> Metric
- data Metric
- newtype MetricName = MetricName {}
- data MetricType
- event :: Text -> Text -> Event
- data Event
- serviceCheck :: Text -> ServiceCheckStatus -> ServiceCheck
- data ServiceCheck
- data ServiceCheckStatus
- class ToStatsD a
- data Tag
- tag :: Text -> Text -> Tag
- class ToMetricValue a where
- encodeValue :: a -> Utf8Builder ()
- value :: ToMetricValue a => Setter Metric Metric (Utf8Builder ()) a
- data Priority
- data AlertType
- class HasName s a | s -> a where
- class HasSampleRate s a | s -> a where
- sampleRate :: Lens' s a
- class HasType' s a | s -> a where
- class HasTags s a | s -> a where
- class HasTitle s a | s -> a where
- class HasText s a | s -> a where
- class HasDateHappened s a | s -> a where
- dateHappened :: Lens' s a
- class HasHostname s a | s -> a where
- class HasAggregationKey s a | s -> a where
- aggregationKey :: Lens' s a
- class HasPriority s a | s -> a where
- class HasSourceTypeName s a | s -> a where
- sourceTypeName :: Lens' s a
- class HasAlertType s a | s -> a where
- class HasHost s a | s -> a where
- class HasPort s a | s -> a where
- class HasBufferSize s a | s -> a where
- bufferSize :: Lens' s a
- class HasMaxDelay s a | s -> a where
- class HasOnException s a | s -> a where
- onException :: Lens' s a
- class HasStatus s a | s -> a where
- class HasMessage s a | s -> a where
- data StatsClient = Dummy
Client interface
data DogStatsSettings #
Constructors
| DogStatsSettings | |
Fields
| |
Instances
| HasPort DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
| HasMaxDelay DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
| HasHost DogStatsSettings HostName # | |
Defined in Network.StatsD.Datadog Methods | |
| HasBufferSize DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
| HasOnException DogStatsSettings (SomeException -> Seq ByteString -> IO (Seq ByteString -> Seq ByteString)) # | |
Defined in Network.StatsD.Datadog Methods onException :: Lens' DogStatsSettings (SomeException -> Seq ByteString -> IO (Seq ByteString -> Seq ByteString)) # | |
withDogStatsD :: MonadUnliftIO m => DogStatsSettings -> (StatsClient -> m a) -> m a #
Create a StatsClient and provide it to the provided function. The StatsClient will be finalized as soon as the inner block is exited, whether normally or via an exception.
mkStatsClient :: MonadIO m => DogStatsSettings -> m StatsClient #
Create a stats client. Be sure to close it with finalizeStatsClient in order to send any pending stats and close the underlying handle when done using it. Alternatively, use withDogStatsD to finalize it automatically.
finalizeStatsClient :: MonadIO m => StatsClient -> m () #
Send all pending unsent events and close the connection to the specified statsd server.
send :: (MonadIO m, ToStatsD v) => StatsClient -> v -> m () #
Send a Metric, Event, or StatusCheck to the DogStatsD server.
Since UDP is used to send the events, there is no ack that sent values are successfully dealt with.
withDogStatsD defaultSettings $ \client -> do send client $ event "Wombat attack" "A host of mighty wombats has breached the gates" send client $ metric "wombat.force_count" Gauge (9001 :: Int) send client $ serviceCheck "Wombat Radar" ServiceOk
Data supported by DogStatsD
metric :: ToMetricValue a => MetricName -> MetricType -> a -> Metric #
Smart Metric constructor. Use the lens functions to set the optional fields.
The fields accessible through corresponding lenses are:
name::MetricNamesampleRate::Doubletype'::MetricTypevalue::ToMetricValuea => atags::[Tag]
Instances
| ToStatsD Metric # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: Metric -> Utf8Builder () | |
| HasType' Metric MetricType # | |
Defined in Network.StatsD.Datadog Methods type' :: Lens' Metric MetricType # | |
| HasSampleRate Metric Double # | |
Defined in Network.StatsD.Datadog Methods sampleRate :: Lens' Metric Double # | |
| HasName Metric MetricName # | |
Defined in Network.StatsD.Datadog Methods name :: Lens' Metric MetricName # | |
| HasTags Metric [Tag] # | |
newtype MetricName #
Constructors
| MetricName | |
Fields | |
Instances
| HasName Metric MetricName # | |
Defined in Network.StatsD.Datadog Methods name :: Lens' Metric MetricName # | |
data MetricType #
Constructors
| Gauge | Gauges measure the value of a particular thing at a particular time, like the amount of fuel in a car’s gas tank or the number of users connected to a system. |
| Counter | Counters track how many times something happened per second, like the number of database requests or page views. |
| Timer | StatsD only supports histograms for timing, not generic values (like the size of uploaded files or the number of rows returned from a query). Timers are essentially a special case of histograms, so they are treated in the same manner by DogStatsD for backwards compatibility. |
| Histogram | Histograms track the statistical distribution of a set of values, like the duration of a number of database queries or the size of files uploaded by users. Each histogram will track the average, the minimum, the maximum, the median and the 95th percentile. |
| Set | Sets are used to count the number of unique elements in a group. If you want to track the number of unique visitor to your site, sets are a great way to do that. |
Instances
| HasType' Metric MetricType # | |
Defined in Network.StatsD.Datadog Methods type' :: Lens' Metric MetricType # | |
event :: Text -> Text -> Event #
Smart Event constructor. Use the lens functions to set the optional fields.
The fields accessible through corresponding lenses are:
Instances
| ToStatsD Event # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: Event -> Utf8Builder () | |
| HasTitle Event Text # | |
| HasText Event Text # | |
| HasTags Event [Tag] # | |
| HasSourceTypeName Event (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
| HasPriority Event (Maybe Priority) # | |
| HasHostname Event (Maybe Text) # | |
| HasDateHappened Event (Maybe UTCTime) # | |
Defined in Network.StatsD.Datadog | |
| HasAlertType Event (Maybe AlertType) # | |
| HasAggregationKey Event (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
Arguments
| :: Text | name |
| -> ServiceCheckStatus | |
| -> ServiceCheck |
data ServiceCheck #
The fields accessible through corresponding lenses are:
Instances
| ToStatsD ServiceCheck # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: ServiceCheck -> Utf8Builder () | |
| HasName ServiceCheck Text # | |
Defined in Network.StatsD.Datadog Methods name :: Lens' ServiceCheck Text # | |
| HasStatus ServiceCheck ServiceCheckStatus # | |
Defined in Network.StatsD.Datadog Methods | |
| HasTags ServiceCheck [Tag] # | |
Defined in Network.StatsD.Datadog Methods tags :: Lens' ServiceCheck [Tag] # | |
| HasHostname ServiceCheck (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
| HasDateHappened ServiceCheck (Maybe UTCTime) # | |
Defined in Network.StatsD.Datadog Methods | |
| HasMessage ServiceCheck (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
data ServiceCheckStatus #
Constructors
| ServiceOk | |
| ServiceWarning | |
| ServiceCritical | |
| ServiceUnknown |
Instances
Minimal complete definition
toStatsD
Instances
| ToStatsD Metric # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: Metric -> Utf8Builder () | |
| ToStatsD Event # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: Event -> Utf8Builder () | |
| ToStatsD ServiceCheck # | |
Defined in Network.StatsD.Datadog Methods toStatsD :: ServiceCheck -> Utf8Builder () | |
Optional fields
Tags are a Datadog specific extension to StatsD. They allow you to tag a metric with a dimension that’s meaningful to you and slice and dice along that dimension in your graphs. For example, if you wanted to measure the performance of two video rendering algorithms, you could tag the rendering time metric with the version of the algorithm you used.
Create a tag from a key-value pair. Useful for slicing and dicing events in Datadog.
Key and value text values are normalized by converting ":"s, "|"s, and "@"s to underscores ("_").
class ToMetricValue a where #
Converts a supported numeric type to the format understood by DogStatsD. Currently limited by BufferBuilder encoding options.
Methods
encodeValue :: a -> Utf8Builder () #
Instances
| ToMetricValue Double # | |
Defined in Network.StatsD.Datadog Methods encodeValue :: Double -> Utf8Builder () # | |
| ToMetricValue Int # | |
Defined in Network.StatsD.Datadog Methods encodeValue :: Int -> Utf8Builder () # | |
value :: ToMetricValue a => Setter Metric Metric (Utf8Builder ()) a #
Special setter to update the value of a Metric.
metric ("foo"" :: Text) Counter (1 :: Int) & value .~ (5 :: Double)class HasName s a | s -> a where #
Instances
| HasName Metric MetricName # | |
Defined in Network.StatsD.Datadog Methods name :: Lens' Metric MetricName # | |
| HasName ServiceCheck Text # | |
Defined in Network.StatsD.Datadog Methods name :: Lens' ServiceCheck Text # | |
class HasSampleRate s a | s -> a where #
Methods
sampleRate :: Lens' s a #
Instances
| HasSampleRate Metric Double # | |
Defined in Network.StatsD.Datadog Methods sampleRate :: Lens' Metric Double # | |
class HasType' s a | s -> a where #
Instances
| HasType' Metric MetricType # | |
Defined in Network.StatsD.Datadog Methods type' :: Lens' Metric MetricType # | |
class HasDateHappened s a | s -> a where #
Methods
dateHappened :: Lens' s a #
Instances
| HasDateHappened Event (Maybe UTCTime) # | |
Defined in Network.StatsD.Datadog | |
| HasDateHappened ServiceCheck (Maybe UTCTime) # | |
Defined in Network.StatsD.Datadog Methods | |
class HasHostname s a | s -> a where #
Instances
| HasHostname Event (Maybe Text) # | |
| HasHostname ServiceCheck (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
class HasAggregationKey s a | s -> a where #
Methods
aggregationKey :: Lens' s a #
Instances
| HasAggregationKey Event (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
class HasPriority s a | s -> a where #
class HasSourceTypeName s a | s -> a where #
Methods
sourceTypeName :: Lens' s a #
Instances
| HasSourceTypeName Event (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
class HasAlertType s a | s -> a where #
class HasHost s a | s -> a where #
Instances
| HasHost DogStatsSettings HostName # | |
Defined in Network.StatsD.Datadog Methods | |
class HasPort s a | s -> a where #
Instances
| HasPort DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
class HasBufferSize s a | s -> a where #
Methods
bufferSize :: Lens' s a #
Instances
| HasBufferSize DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
class HasMaxDelay s a | s -> a where #
Instances
| HasMaxDelay DogStatsSettings Int # | |
Defined in Network.StatsD.Datadog Methods | |
class HasOnException s a | s -> a where #
Methods
onException :: Lens' s a #
Instances
| HasOnException DogStatsSettings (SomeException -> Seq ByteString -> IO (Seq ByteString -> Seq ByteString)) # | |
Defined in Network.StatsD.Datadog Methods onException :: Lens' DogStatsSettings (SomeException -> Seq ByteString -> IO (Seq ByteString -> Seq ByteString)) # | |
class HasStatus s a | s -> a where #
Instances
| HasStatus ServiceCheck ServiceCheckStatus # | |
Defined in Network.StatsD.Datadog Methods | |
class HasMessage s a | s -> a where #
Instances
| HasMessage ServiceCheck (Maybe Text) # | |
Defined in Network.StatsD.Datadog | |
Dummy client
data StatsClient #
Note that Dummy is not the only constructor, just the only publicly available one.
Constructors
| Dummy | Just drops all stats. |