Skip to content

Commit

Permalink
add ttfb to store client output (#308)
Browse files Browse the repository at this point in the history
Adds Time-to-First-Byte (ttfb) to the store client output.
  • Loading branch information
brayniac authored Nov 7, 2024
1 parent 731d016 commit e12df02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/clients/cache/momento/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ async fn task(
let start = Instant::now();

if let Ok((response, mut stream)) = sender.send_request(request, false) {
if stream
.send_data(Bytes::from(r.value.clone()), true)
.is_err()
{
if stream.send_data(r.value.clone(), true).is_err() {
continue;
}

Expand Down
5 changes: 2 additions & 3 deletions src/clients/store/s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ async fn task(

let work_item = match work_receiver.recv().await {
Ok(w) => w,
Err(e) => {
error!("error while attempting to receive work item: {e}");
Err(_) => {
continue;
}
};
Expand Down Expand Up @@ -440,7 +439,7 @@ impl S3RequestBuilder {

self.inner
.header("authorization", authorization)
.body(Full::<Bytes>::new(self.content.into()))
.body(Full::<Bytes>::new(self.content))
.unwrap()
}

Expand Down
10 changes: 10 additions & 0 deletions src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ fn store_stats(snapshot: &mut MetricsSnapshot) {
let connect_sr = 100.0 * connect_ok / connect_total;

let response_latency = snapshot.percentiles(STORE_RESPONSE_LATENCY_HISTOGRAM);
let response_ttfb = snapshot.percentiles(STORE_RESPONSE_TTFB_HISTOGRAM);

output!(
"Store Client Connection: Open: {} Success Rate: {:.2} %",
Expand Down Expand Up @@ -313,6 +314,15 @@ fn store_stats(snapshot: &mut MetricsSnapshot) {
}

output!("{latencies}");

let mut latencies = "Store Client Time-to-First-Byte (us):".to_owned();

for (label, _percentile, nanoseconds) in response_ttfb {
let microseconds = nanoseconds / 1000;
latencies.push_str(&format!(" {label}: {microseconds}"))
}

output!("{latencies}");
}

/// Outputs store stats
Expand Down

0 comments on commit e12df02

Please sign in to comment.