rylv-metrics
A high-performance DogStatsD metrics client for Rust with support for client-side aggregation.
Features
- High Performance: Lock-free data structures and optimized UDP batching
- Client-Side Aggregation: Reduces network overhead by aggregating metrics before sending
- Multiple Writer Backends:
Simple: Standard UDP writer (all platforms)LinuxBatch: Usessendmmsgfor batch UDP writes (Linux only)AppleBatch: Usessendmsg_xfor batch UDP writes (macOS only)Custom: Bring your own writer implementation
- Metric Types: Histograms, Counters, and Gauges
- Flexible Tags: Support for static and owned string tags
- Configurable Histograms: Adjustable significant figures, custom percentile lists, and optional base metrics (
count,min,avg,max)
Installation
Add to your Cargo.toml:
[]
= "0.2.1"
Quick Start
use ;
use SocketAddr;
use Duration;
Metric Types
Histogram
Records distribution of values with configurable precision and percentiles:
histogram!;
You can configure per-metric or default histogram behavior with HistogramConfig
(significant figures, percentile list, and base metric toggles).
Counter
Increments a counter, aggregated client-side:
count!;
count_add!;
Gauge
Records point-in-time values:
gauge!;
Custom Writer
Implement StatsWriterTrait for custom metric destinations:
use ;
// Use with StatsWriterType::Custom(Box::new(MyWriter { ... }))
Feature Flags
dhat-heap: Enables heap profiling support viadhatallocationcounter: Enables allocation counting instrumentation
Platform Support
- Linux (x86_64, aarch64)
- macOS (x86_64, aarch64)
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Release Workflow
Before publishing, run:
This runs prepare-commit, package/doc checks, and cargo publish --dry-run.