Move code to new repository
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.
SatsD handler for official swift-metrics API.
Supported metric types:
import Metrics import SwiftBoxMetricsStatsD
Metrics must be bootstrap with Factory, that conforms to MetricsFactory protocol. Default StatsDMetricsFactory accepts 2 parameters:
MetricsFactory
StatsDMetricsFactory
baseMetricsPath
handlerFactory
MetricsHandler
// 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 ) } )
Detailed usage details may be found in official swift-metrics GitHub repository.
Default handler for metrics that prints gathered metrics to console.
MetricsSystem.bootstrap( try StatsDMetricsFactory( baseMetricPath: "com.allegro" ) { path in LoggerMetricsHandler(path: path) } )
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
client
TCPStatsDClient
UDPStatsDClient
To create custom handlers, conform to MetricsHandler or BaseMetricsHandler protocol.
BaseMetricsHandler
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
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.