From e67e9868bef9aca06eeb320f708c3305c0bf891d Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Thu, 6 Jun 2024 16:12:34 +0200 Subject: [PATCH] capture: subdivide process_events_error cause --- capture/src/v0_endpoint.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/capture/src/v0_endpoint.rs b/capture/src/v0_endpoint.rs index 3849e29..48259b5 100644 --- a/capture/src/v0_endpoint.rs +++ b/capture/src/v0_endpoint.rs @@ -150,7 +150,13 @@ pub async fn event( tracing::debug!(context=?context, events=?events, "decoded request"); if let Err(err) = process_events(state.sink.clone(), &events, &context).await { - report_dropped_events("process_events_error", events.len() as u64); + let cause = match err { // TODO: automate this with a macro + CaptureError::EmptyDistinctId => "empty_distinct_id", + CaptureError::MissingDistinctId => "missing_distinct_id", + CaptureError::MissingEventName => "missing_event_name", + _ => "process_events_error" + }; + report_dropped_events(cause, events.len() as u64); tracing::log::warn!("rejected invalid payload: {}", err); return Err(err); }