Skip to content

Commit

Permalink
add metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierDehaene committed Apr 19, 2023
1 parent b908ca7 commit 6d5a5f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion router/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,10 @@ fn filter_send_generations(generations: Vec<Generation>, entries: &mut IntMap<u6
// Send generation responses back to the infer task
// If the receive an error from the Flume channel, it means that the client dropped the
// request and we need to stop generating hence why we unwrap_or(true)
let stopped = send_responses(generation, entry).unwrap_or(true);
let stopped = send_responses(generation, entry).map_err(|err| {
metrics::increment_counter!("tgi_request_failure", "err" => "dropped");
err
}).unwrap_or(true);
if stopped {
entries.remove(&id).expect("ID not found in entries. This is a bug.");
}
Expand Down
4 changes: 3 additions & 1 deletion router/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl State {
// Filter entries where the response receiver was dropped (== entries where the request
// was dropped by the client)
if entry.response_tx.is_disconnected() {
metrics::increment_counter!("tgi_request_failure", "err" => "dropped");
continue;
}

Expand Down Expand Up @@ -190,6 +191,8 @@ impl State {
}
}

metrics::gauge!("tgi_queue_size", self.entries.len() as f64);

// Maybe all entries were dropped because their channel were closed
if batch_requests.is_empty() {
return None;
Expand All @@ -207,7 +210,6 @@ impl State {
// Increment batch id
self.next_batch_id += 1;

metrics::gauge!("tgi_queue_size", self.entries.len() as f64);
metrics::histogram!("tgi_batch_next_size", batch.size as f64);
Some((batch_entries, batch, next_batch_span))
}
Expand Down

0 comments on commit 6d5a5f0

Please sign in to comment.