Skip to content

Commit a739e34

Browse files
committed
cf
1 parent ec30386 commit a739e34

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

rust/otap-dataflow/crates/contrib-nodes/examples/mock_la_server.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ use std::sync::Arc;
4040
use std::sync::atomic::{AtomicU64, Ordering};
4141
use std::time::Duration;
4242

43+
use axum::Router;
4344
use axum::body::Bytes;
4445
use axum::extract::{Path, State};
4546
use axum::http::{HeaderMap, StatusCode, header};
4647
use axum::response::IntoResponse;
4748
use axum::routing::post;
48-
use axum::Router;
4949
use clap::Parser;
5050
use flate2::read::GzDecoder;
5151
use rand::RngExt;
@@ -124,10 +124,7 @@ async fn ingest_handler(
124124
let compressed_size = body.len() as u64;
125125

126126
// Update request counters.
127-
state
128-
.stats
129-
.total_requests
130-
.fetch_add(1, Ordering::Relaxed);
127+
state.stats.total_requests.fetch_add(1, Ordering::Relaxed);
131128
state
132129
.stats
133130
.interval_requests
@@ -303,11 +300,27 @@ async fn stats_reporter(state: AppState) {
303300
let elapsed = start.elapsed().as_secs_f64();
304301

305302
let secs = interval.as_secs_f64();
306-
let int_entries_per_sec = if secs > 0.0 { int_entries as f64 / secs } else { 0.0 };
307-
let int_comp_per_sec = if secs > 0.0 { int_comp as f64 / secs } else { 0.0 };
303+
let int_entries_per_sec = if secs > 0.0 {
304+
int_entries as f64 / secs
305+
} else {
306+
0.0
307+
};
308+
let int_comp_per_sec = if secs > 0.0 {
309+
int_comp as f64 / secs
310+
} else {
311+
0.0
312+
};
308313

309-
let cum_entries_per_sec = if elapsed > 0.0 { total_entries as f64 / elapsed } else { 0.0 };
310-
let cum_comp_per_sec = if elapsed > 0.0 { total_comp as f64 / elapsed } else { 0.0 };
314+
let cum_entries_per_sec = if elapsed > 0.0 {
315+
total_entries as f64 / elapsed
316+
} else {
317+
0.0
318+
};
319+
let cum_comp_per_sec = if elapsed > 0.0 {
320+
total_comp as f64 / elapsed
321+
} else {
322+
0.0
323+
};
311324

312325
println!("[mock-la] --- Stats ---");
313326
println!(
@@ -394,7 +407,5 @@ async fn main() {
394407
.await
395408
.expect("failed to bind to port");
396409

397-
axum::serve(listener, app)
398-
.await
399-
.expect("server error");
410+
axum::serve(listener, app).await.expect("server error");
400411
}

rust/otap-dataflow/crates/contrib-nodes/src/exporters/azure_monitor_exporter/fakegen-ame-local.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# cargo run --features azure-monitor-exporter -- --config crates/contrib-nodes/src/exporters/azure_monitor_exporter/fakegen-ame-local.yaml
1212
#
1313
# Error simulation examples:
14-
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --fail-rate 0.1 # 10% 500
15-
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --fail-rate 0.1 --retry-after 5 # 10% 429
14+
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --fail-rate 0.1 # 10% -> 500
15+
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --fail-rate 0.1 --retry-after 5 # 10% -> 429
1616
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --latency 200ms # slow responses
1717
# cargo run --example mock_la_server -p otap-df-contrib-nodes --features azure-monitor-exporter -- --fail-after 1000 # 503 after 1000 OK
1818

0 commit comments

Comments
 (0)