@@ -478,14 +478,12 @@ def _process_results(
478478 """
479479 last_seen_timestamp_precise = 0.0
480480 last_seen_id = ""
481- row_count = 0
482481
483482 # First pass: parse rows and build attribute dicts
484483 parsed_rows : list [tuple [str , Timestamp , dict [str , GetTraceResponse .Item .Attribute ]]] = []
485484
486- with sentry_sdk .start_span (op = "function" , description = "add_attributes" ) as span :
485+ with sentry_sdk .start_span (op = "function" , description = "add_attributes" ):
487486 for row in data :
488- row_count += 1
489487 id = row .pop ("id" )
490488 ts = row .pop ("timestamp" )
491489 arrays = row .pop ("attributes_array" , "{}" ) or "{}"
@@ -529,12 +527,10 @@ def add_attribute(key: str, value: Any) -> None:
529527
530528 parsed_rows .append ((id , timestamp , attributes ))
531529
532- span .set_data ("rows_processed" , row_count )
533-
534530 # Second pass: sort attributes and assemble items
535531 items : list [GetTraceResponse .Item ] = []
536532
537- with sentry_sdk .start_span (op = "function" , description = "sort_attributes" ) as span :
533+ with sentry_sdk .start_span (op = "function" , description = "sort_attributes" ):
538534 for id , timestamp , attributes in parsed_rows :
539535 item = GetTraceResponse .Item (
540536 id = id ,
@@ -546,7 +542,9 @@ def add_attribute(key: str, value: Any) -> None:
546542 )
547543 items .append (item )
548544
549- span .set_data ("rows_sorted" , len (parsed_rows ))
545+ current_span = sentry_sdk .get_current_span ()
546+ if current_span is not None :
547+ current_span .set_data ("rows_processed" , len (parsed_rows ))
550548
551549 return ProcessedResults (
552550 items = items ,
0 commit comments