StatsdClient
A metrics backend implementation using the StatsD protocol.
import StatsdClient
Module information
- Declarations
- 16
- Symbols
- 18
Overview
StatsdClient is a metrics backend for SwiftMetrics that uses the StatsD protocol, and can be used to integrate applications with observability solutions that support StatsD including:
Getting started
Create an instance of the StatsdClient
and boostrap the MetricsSystem
in your application’s main
:
let statsdClient = try StatsdClient(host: host, port: port)
MetricsSystem.bootstrap(statsdClient)
See selecting a metrics backend implementation for more information.
Remember to also shutdown the client before you application terminates:
statsdClient.shutdown()
Architecture
StatsdClient
uses SwiftNIO to establish a UDP connection to the statsd
server.
Metrics types are mapped as following:
Counter -> Counter
Gauge -> Gauge
Recorder -> Histogram
Timer -> Timer
Client API
init(eventLoopGroupProvider: EventLoopGroupProvider, host: String, port: Int, metricNameSanitizer: @escaping StatsdClient.MetricNameSanitizer
) throws Create a new instance of
StatsdClient
.func shutdown(@escaping (Error?) -> Void
) Shutdown the client. This is a noop when using the
shared(_:)
strategy.