Skip to content

Commit 521f620

Browse files
add metrics
1 parent ca98470 commit 521f620

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

router/src/infer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ fn filter_send_generations(generations: Vec<Generation>, entries: &mut IntMap<u6
446446
// Send generation responses back to the infer task
447447
// If the receive an error from the Flume channel, it means that the client dropped the
448448
// request and we need to stop generating hence why we unwrap_or(true)
449-
let stopped = send_responses(generation, entry).unwrap_or(true);
449+
let stopped = send_responses(generation, entry).map_err(|err| {
450+
metrics::increment_counter!("tgi_request_failure", "err" => "dropped");
451+
err
452+
}).unwrap_or(true);
450453
if stopped {
451454
entries.remove(&id).expect("ID not found in entries. This is a bug.");
452455
}

router/src/queue.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ impl State {
161161
// Filter entries where the response receiver was dropped (== entries where the request
162162
// was dropped by the client)
163163
if entry.response_tx.is_disconnected() {
164+
metrics::increment_counter!("tgi_request_failure", "err" => "dropped");
164165
continue;
165166
}
166167

@@ -190,6 +191,8 @@ impl State {
190191
}
191192
}
192193

194+
metrics::gauge!("tgi_queue_size", self.entries.len() as f64);
195+
193196
// Maybe all entries were dropped because their channel were closed
194197
if batch_requests.is_empty() {
195198
return None;
@@ -207,7 +210,6 @@ impl State {
207210
// Increment batch id
208211
self.next_batch_id += 1;
209212

210-
metrics::gauge!("tgi_queue_size", self.entries.len() as f64);
211213
metrics::histogram!("tgi_batch_next_size", batch.size as f64);
212214
Some((batch_entries, batch, next_batch_span))
213215
}

0 commit comments

Comments
 (0)