Skip to content

Commit dc53c2b

Browse files
committed
make buffer length configurable
1 parent ae4b63c commit dc53c2b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/datadog-serverless-compat/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const AGENT_HOST: &str = "0.0.0.0";
4646

4747
#[tokio::main]
4848
pub async fn main() {
49-
info!("Stats test - buffer length: 90, bucket duration: 10");
49+
info!("Stats test - buffer length: configurable / default 90, bucket duration: 10");
5050

5151
let log_level = env::var("DD_LOG_LEVEL")
5252
.map(|val| val.to_lowercase())

crates/datadog-trace-agent/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ pub struct Config {
8484
pub stats_flush_interval: u64,
8585
/// how often to flush traces, in seconds
8686
pub trace_flush_interval: u64,
87+
/// buffer length for span concentrator
88+
pub stats_buffer_length: usize,
8789
pub trace_intake: Endpoint,
8890
pub trace_stats_intake: Endpoint,
8991
/// timeout for environment verification, in milliseconds
@@ -131,6 +133,11 @@ impl Config {
131133
Tags::new()
132134
};
133135

136+
let stats_buffer_length: usize = env::var("DD_STATS_BUFFER_LENGTH")
137+
.ok()
138+
.and_then(|val| val.parse::<usize>().ok())
139+
.unwrap_or(90);
140+
134141
#[allow(clippy::unwrap_used)]
135142
Ok(Config {
136143
app_name: Some(app_name),
@@ -157,6 +164,7 @@ impl Config {
157164
.or_else(|_| env::var("HTTPS_PROXY"))
158165
.ok(),
159166
tags,
167+
stats_buffer_length,
160168
})
161169
}
162170
}

crates/datadog-trace-agent/src/stats_concentrator_service.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use tracing::error;
1010

1111
const S_TO_NS: u64 = 1_000_000_000;
1212
const BUCKET_DURATION_NS: u64 = 10 * S_TO_NS; // 10 seconds
13-
const BUFFER_LENGTH: usize = 90;
1413

1514
#[derive(Debug, thiserror::Error)]
1615
pub enum StatsError {
@@ -119,7 +118,7 @@ impl StatsConcentratorService {
119118
SystemTime::now(),
120119
vec![],
121120
vec![],
122-
BUFFER_LENGTH,
121+
config.stats_buffer_length,
123122
);
124123
let service: StatsConcentratorService = Self {
125124
concentrator,

0 commit comments

Comments
 (0)