Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ci/fingerprints/dogstatsd_http/lading.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
generator:
- id: "dogstatsd_http"
http:
seed: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]
target_uri: "http://127.0.0.1:8125"
headers:
content-type: application/x-protobuf
method:
post:
variant:
dogstatsd_http: {}
maximum_prebuild_cache_size_bytes: "10 Mb"
bytes_per_second: "100 Mb"
maximum_block_size: "1 Mb"
parallel_connections: 1

blackhole:
- http:
binding_addr: "127.0.0.1:9999"
4 changes: 4 additions & 0 deletions lading_payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ harness = false
name = "dogstatsd"
harness = false

[[bench]]
name = "dogstatsd_http"
harness = false

[[bench]]
name = "fluent"
harness = false
Expand Down
60 changes: 60 additions & 0 deletions lading_payload/benches/dogstatsd_http.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//! Benchmarks for `DogStatsDHttp` payload generation.

use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use lading_payload::{Serialize, dogstatsd, dogstatsd_http::DogStatsDHttp};
use rand::{SeedableRng, rngs::SmallRng};
use std::time::Duration;

const MIB: usize = 1_048_576;

fn dogstatsd_http_setup(c: &mut Criterion) {
c.bench_function("dogstatsd_http_setup", |b| {
b.iter(|| {
let mut rng = SmallRng::seed_from_u64(19_690_716);
let config = dogstatsd::Config::default();
let _dd = DogStatsDHttp::new(&config, &mut rng);
});
});
}

fn dogstatsd_http_throughput(c: &mut Criterion) {
let mut group = c.benchmark_group("dogstatsd_http_throughput");
for size in &[MIB, 10 * MIB, 100 * MIB] {
group.throughput(Throughput::Bytes(*size as u64));
group.bench_with_input(BenchmarkId::from_parameter(size), size, |b, &size| {
b.iter_batched(
|| {
let mut rng = SmallRng::seed_from_u64(19_690_716);
let config = dogstatsd::Config::default();
let dd = DogStatsDHttp::new(&config, &mut rng)
.expect("failed to create DogStatsDHttp");
(rng, dd, Vec::with_capacity(size))
},
|(rng, mut dd, mut writer)| {
dd.to_bytes(rng, size, &mut writer)
.expect("failed to convert to bytes");
},
BatchSize::PerIteration,
);
});
}
group.finish();
}

criterion_group!(
name = setup_benches;
config = Criterion::default()
.measurement_time(Duration::from_secs(5))
.warm_up_time(Duration::from_secs(1));
targets = dogstatsd_http_setup,
);

criterion_group!(
name = throughput_benches;
config = Criterion::default()
.measurement_time(Duration::from_secs(30))
.warm_up_time(Duration::from_secs(1));
targets = dogstatsd_http_throughput,
);

criterion_main!(setup_benches, throughput_benches);
7 changes: 7 additions & 0 deletions lading_payload/proptest-regressions/dogstatsd_http.txt
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 7bb60665af78073dc7447e24d33711ca088d8e001cbbf923670d7d598094ce35 # shrinks to seed = 0, max_bytes = 1622
21 changes: 21 additions & 0 deletions lading_payload/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,27 @@ impl Cache {

construct_block_cache_inner(rng, &mut pyld, maximum_block_bytes, total_bytes.get())?
}
crate::Config::DogStatsDHttp(conf) => {
match conf.valid() {
Ok(()) => (),
Err(e) => {
warn!("Invalid DogStatsDHttp configuration: {}", e);
return Err(Error::InvalidConfig(e));
}
}

let mut serializer = crate::DogStatsDHttp::new(conf, &mut rng)?;

let span = span!(Level::INFO, "fixed", payload = "dogstatsd-http");
let _guard = span.enter();

construct_block_cache_inner(
&mut rng,
&mut serializer,
maximum_block_bytes,
total_bytes.get(),
)?
}
};

let total_cycle_size = blocks
Expand Down
22 changes: 11 additions & 11 deletions lading_payload/src/dogstatsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use self::{

use super::Generator;

mod common;
pub(crate) mod common;
pub mod event;
pub mod metric;
pub mod service_check;
Expand Down Expand Up @@ -72,12 +72,12 @@ impl Default for KindWeights {
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct MetricWeights {
count: u8,
gauge: u8,
timer: u8,
distribution: u8,
set: u8,
histogram: u8,
pub(crate) count: u8,
pub(crate) gauge: u8,
pub(crate) timer: u8,
pub(crate) distribution: u8,
pub(crate) set: u8,
pub(crate) histogram: u8,
}

impl MetricWeights {
Expand Down Expand Up @@ -354,10 +354,10 @@ struct MemberGenerator {
/// Cheap to clone.
#[derive(Clone, Debug)]
pub(crate) struct StringPools {
tag_name: Rc<strings::PoolKind>,
tag_value: Rc<strings::PoolKind>,
name: Rc<strings::PoolKind>,
randomstring: Rc<strings::RandomStringPool>,
pub(crate) tag_name: Rc<strings::PoolKind>,
pub(crate) tag_value: Rc<strings::PoolKind>,
pub(crate) name: Rc<strings::PoolKind>,
pub(crate) randomstring: Rc<strings::RandomStringPool>,
}

impl MemberGenerator {
Expand Down
Loading
Loading