SwiftBox Metrics StatsD
SwiftBox Metrics StatsD is a StatsD TCP/UDP client and and handler.
Handler is compatible with official swift-metrics API.
Coming soon: Replace SwiftBoxLogging implementation in favor of official swift-log.

SwiftBoxMetricsStatsD
SatsD handler for official swift-metrics API.
Supported metric types:
Usage
1. Import
import Metrics
import SwiftBoxMetricsStatsD
2. Bootstrap
Metrics must be bootstrap with Factory, that conforms to MetricsFactory
protocol.
Default StatsDMetricsFactory
accepts 2 parameters:
baseMetricsPath
: path that is prepended to every recorded metric path
handlerFactory
: Factory function that returns MetricsHandler
implementation.// StatsD Handler initialization
let statsdClient = UDPStatsDClient(
config: UDPConnectionConfig(
host: "127.0.0.1",
port: 1234
)
)
MetricsSystem.bootstrap(
try StatsDMetricsFactory(
baseMetricPath: "com.allegro"
) { path in
StatsDMetricsHandler(
path: path,
client: statsdClient
)
}
)
3. Usage
Detailed usage details may be found in official swift-metrics GitHub repository.
Handlers
LoggerMetricsHandler
Default handler for metrics that prints gathered metrics to console.
MetricsSystem.bootstrap(
try StatsDMetricsFactory(
baseMetricPath: "com.allegro"
) { path in
LoggerMetricsHandler(path: path)
}
)
StatsDMetricsHandler
StatsD Metrics Handler responsible for sending gathered logs to statsD server. Supports TCP and UDP protocols.
Metrics are sent in separate thread, so operation is non-blocking for application.
StatsDMetricsHandler(
path: "com.allegro.counter",
client: UDPStatsDClient(
config: UDPConnectionConfig(
host: AppConfig.global.statsd.host!,
port: AppConfig.global.statsd.port!
)
)
)
path
is a path that metric will be recorder at.
client
is a TCPStatsDClient
or UDPStatsDClient
instance.
Custom Handlers
To create custom handlers, conform to MetricsHandler
or BaseMetricsHandler
protocol.
SwiftBox Metrics StatsD
SwiftBox Metrics StatsD is a StatsD TCP/UDP client and and handler. Handler is compatible with official swift-metrics API.
Coming soon: Replace SwiftBoxLogging implementation in favor of official swift-log.
SwiftBoxMetricsStatsD
SatsD handler for official swift-metrics API.
Supported metric types:
Usage
1. Import
2. Bootstrap
Metrics must be bootstrap with Factory, that conforms to
MetricsFactory
protocol. DefaultStatsDMetricsFactory
accepts 2 parameters:baseMetricsPath
: path that is prepended to every recorded metric pathhandlerFactory
: Factory function that returnsMetricsHandler
implementation.3. Usage
Detailed usage details may be found in official swift-metrics GitHub repository.
Handlers
LoggerMetricsHandler
Default handler for metrics that prints gathered metrics to console.
StatsDMetricsHandler
StatsD Metrics Handler responsible for sending gathered logs to statsD server. Supports TCP and UDP protocols. Metrics are sent in separate thread, so operation is non-blocking for application.
path
is a path that metric will be recorder at.client
is aTCPStatsDClient
orUDPStatsDClient
instance.Custom Handlers
To create custom handlers, conform to
MetricsHandler
orBaseMetricsHandler
protocol.