-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: add a new DogStatsD-specific exporter (#548)
- Loading branch information
Showing
35 changed files
with
2,734 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
too-many-lines-threshold = 150 | ||
ignore-interior-mutability = ["metrics::key::Key"] | ||
doc-valid-idents = ["DogStatsD", ".."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
<!-- next-header --> | ||
|
||
## [Unreleased] - ReleaseDate | ||
|
||
### Added | ||
|
||
- Genesis. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "metrics-exporter-dogstatsd" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bytes = { version = "1", default-features = false } | ||
ryu = { version = "1", default-features = false } | ||
itoa = { version = "1", default-features = false } | ||
metrics = { version = "^0.24", path = "../metrics" } | ||
metrics-util = { version = "^0.18", path = "../metrics-util" } | ||
thiserror = { workspace = true } | ||
tracing = { workspace = true } | ||
|
||
[dev-dependencies] | ||
proptest = { workspace = true } | ||
rand = { workspace = true } | ||
rand_xoshiro = { version = "0.6", default-features = false } | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true, features = ["fmt"] } |
28 changes: 28 additions & 0 deletions
28
metrics-exporter-dogstatsd/examples/dogstatsd_idle_counter.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::time::{Duration, Instant}; | ||
|
||
use metrics::counter; | ||
use metrics_exporter_dogstatsd::DogStatsDBuilder; | ||
|
||
fn main() { | ||
tracing_subscriber::fmt::init(); | ||
|
||
DogStatsDBuilder::default() | ||
.with_remote_address("localhost:9125") | ||
.expect("failed to parse remote address") | ||
.with_telemetry(false) | ||
.install() | ||
.expect("failed to install DogStatsD recorder"); | ||
|
||
counter!("idle_metric").increment(1); | ||
|
||
// Loop over and over, incrementing our counter every 10 seconds or so. | ||
let mut last_update = Instant::now(); | ||
loop { | ||
if last_update.elapsed() > Duration::from_secs(10) { | ||
counter!("idle_metric").increment(1); | ||
last_update = Instant::now(); | ||
} | ||
|
||
std::thread::sleep(Duration::from_secs(1)); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
metrics-exporter-dogstatsd/examples/dogstatsd_synchronous.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use metrics::{counter, gauge, histogram}; | ||
use metrics_exporter_dogstatsd::DogStatsDBuilder; | ||
use rand::{thread_rng, Rng, SeedableRng as _}; | ||
use rand_xoshiro::Xoshiro256StarStar; | ||
|
||
fn main() { | ||
tracing_subscriber::fmt::init(); | ||
|
||
DogStatsDBuilder::default() | ||
.with_remote_address("localhost:9125") | ||
.expect("failed to parse remote address") | ||
.install() | ||
.expect("failed to install DogStatsD recorder"); | ||
|
||
counter!("idle_metric").increment(1); | ||
gauge!("testing").set(42.0); | ||
|
||
let server_loops = counter!("tcp_server_loops", "system" => "foo"); | ||
let server_loops_delta_secs = histogram!("tcp_server_loop_delta_secs", "system" => "foo"); | ||
|
||
let mut rng = Xoshiro256StarStar::from_rng(thread_rng()).unwrap(); | ||
|
||
// Loop over and over, pretending to do some work. | ||
loop { | ||
server_loops.increment(1); | ||
server_loops_delta_secs.record(rng.gen_range(0.0..1.0)); | ||
|
||
let increment_gauge = thread_rng().gen_bool(0.75); | ||
let gauge = gauge!("lucky_iterations"); | ||
if increment_gauge { | ||
gauge.increment(1.0); | ||
} else { | ||
gauge.decrement(1.0); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
metrics-exporter-dogstatsd/proptest-regressions/forwarder/writer.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc 996294ee8ec0a637930c95346f0165bbaba2cbf701d321de8d713d7f723f0ff0 # shrinks to payload_limit = 43, inputs = [Histogram(Key { name: KeyName("A0AA0A0A"), labels: [], hashed: true, hash: 18423047812237334005 }, [-0.0, 3.1748022040256364e164], 10000000)] |
Oops, something went wrong.