Skip to content
Open
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
31 changes: 22 additions & 9 deletions router/src/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,33 @@ pub(crate) fn prometheus_builer(
duration_buckets.push(value);
}

// Input Length buckets
// Input Length buckets: half-steps up to 32k, then powers of 2
let input_length_matcher = Matcher::Full(String::from("te_request_input_length"));
let input_length_buckets: Vec<f64> = (0..20)
.map(|x| 2.0_f64.powi(x))
.filter(|x| (*x as usize) <= max_input_length)
.collect();
let input_length_buckets: Vec<f64> = [
1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 768.0, 1024.0, 1536.0, 2048.0,
3072.0, 4096.0, 6144.0, 8192.0, 12288.0, 16384.0, 24576.0, 32768.0, 65536.0, 131072.0,
262144.0, 524288.0,
]
.into_iter()
.filter(|x| (*x as usize) <= max_input_length)
.collect();

// Batch size buckets
// Batch size buckets: 1-32 (all integers), then powers of 2
let batch_size_matcher = Matcher::Full(String::from("te_batch_next_size"));
let batch_size_buckets: Vec<f64> = (0..13).map(|x| 2.0_f64.powi(x)).collect();
let batch_size_buckets: Vec<f64> = (1..=32)
.map(|x| x as f64)
.chain((7..13).map(|x| 2.0_f64.powi(x)))
.collect();

// Batch tokens buckets
// Batch tokens buckets: half-steps up to 32k, then powers of 2
let batch_tokens_matcher = Matcher::Full(String::from("te_batch_next_tokens"));
let batch_tokens_buckets: Vec<f64> = (0..21).map(|x| 2.0_f64.powi(x)).collect();
let batch_tokens_buckets: Vec<f64> = [
1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 768.0, 1024.0, 1536.0, 2048.0,
3072.0, 4096.0, 6144.0, 8192.0, 12288.0, 16384.0, 24576.0, 32768.0, 65536.0, 131072.0,
262144.0, 524288.0, 1048576.0,
]
.into_iter()
.collect();

// Prometheus handler
PrometheusBuilder::new()
Expand Down