Skip to content

GoodNotes/swift-dogstatsd-client

 
 

Repository files navigation

DogStatsdClient

DogStatsD backend for SwiftMetrics, built on top of StatsdUDPTransport from swift-statsd-client.

Usage

import DogStatsdClient
import Metrics

let dogStatsdClient = try DogStatsdClient(host: "127.0.0.1", port: 8125)
MetricsSystem.bootstrap(dogStatsdClient)

let counter = Counter(label: "requests", dimensions: [("service", "api")])
counter.increment()

Dimensions are mapped to DogStatsD tags, while the label becomes the metric name. After bootstrap, your code only needs to interact with the SwiftMetrics API.

Default tags and container ID

let dogStatsdClient = try DogStatsdClient(
    host: "127.0.0.1",
    port: 8125,
    defaultTags: [("env", "prod"), ("service", "api")],
    containerID: "container-123"
)

Direct emit for DogStatsD extensions

The client also exposes a direct emit API for DogStatsD-specific features such as sample rates and timestamps when needed.

Examples

See Examples/Basic/main.swift for a minimal end-to-end setup.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Swift 100.0%