@@ -372,36 +372,41 @@ impl UsageCounter {
372
372
373
373
if did_exceed_document_threshold || did_exceed_byte_threshold {
374
374
let mut calls = Vec :: new ( ) ;
375
- let component_path: ComponentPath = stats
376
- . database_egress_rows
377
- . clone ( )
378
- . into_iter ( )
379
- . next ( )
380
- . map ( |( ( cp, _) , _) | cp)
381
- . expect ( "Expected at least one database egress row since thresholds were exceeded" ) ;
382
-
383
- for ( ( cp, table_name) , egress_rows) in stats. database_egress_rows . into_iter ( ) {
384
- let egress = stats
385
- . database_egress_size
386
- . get ( & ( cp, table_name. clone ( ) ) )
387
- . copied ( )
388
- . unwrap_or ( 0 ) ;
389
-
390
- calls. push ( InsightReadLimitCall {
391
- table_name,
392
- bytes_read : egress,
393
- documents_read : egress_rows,
375
+ let component_path: Option < ComponentPath > =
376
+ match stats. database_egress_rows . first_key_value ( ) {
377
+ Some ( ( ( component_path, _) , _) ) => Some ( component_path. clone ( ) ) ,
378
+ None => {
379
+ tracing:: error!(
380
+ "Failed to find component path despite thresholds being exceeded"
381
+ ) ;
382
+ None
383
+ } ,
384
+ } ;
385
+
386
+ if let Some ( component_path) = component_path {
387
+ for ( ( cp, table_name) , egress_rows) in stats. database_egress_rows . into_iter ( ) {
388
+ let egress = stats
389
+ . database_egress_size
390
+ . get ( & ( cp, table_name. clone ( ) ) )
391
+ . copied ( )
392
+ . unwrap_or ( 0 ) ;
393
+
394
+ calls. push ( InsightReadLimitCall {
395
+ table_name,
396
+ bytes_read : egress,
397
+ documents_read : egress_rows,
398
+ } ) ;
399
+ }
400
+
401
+ usage_metrics. push ( UsageEvent :: InsightReadLimit {
402
+ id : execution_id. to_string ( ) ,
403
+ request_id : request_id. to_string ( ) ,
404
+ udf_id : udf_id. clone ( ) ,
405
+ component_path : component_path. serialize ( ) ,
406
+ calls,
407
+ success,
394
408
} ) ;
395
409
}
396
-
397
- usage_metrics. push ( UsageEvent :: InsightReadLimit {
398
- id : execution_id. to_string ( ) ,
399
- request_id : request_id. to_string ( ) ,
400
- udf_id : udf_id. clone ( ) ,
401
- component_path : component_path. serialize ( ) ,
402
- calls,
403
- success,
404
- } ) ;
405
410
}
406
411
407
412
for ( ( component_path, table_name) , ingress_size) in stats. vector_ingress_size {
0 commit comments