@@ -337,27 +337,29 @@ async fn process_batch(
337337 }
338338
339339 // Process trace aggregations and update trace statistics
340- let trace_aggregations = TraceAggregation :: from_spans ( & spans, & span_usage_vec) ;
341- if !trace_aggregations. is_empty ( ) {
342- // Upsert trace statistics in PostgreSQL
343- match upsert_trace_statistics_batch ( & db. pool , & trace_aggregations) . await {
344- Ok ( updated_traces) => {
345- // Convert to ClickHouse traces and upsert
346- let ch_traces: Vec < CHTrace > = updated_traces
347- . iter ( )
348- . map ( |trace| CHTrace :: from_db_trace ( trace) )
349- . collect ( ) ;
350-
351- if let Err ( e) = upsert_traces_batch ( clickhouse. clone ( ) , & ch_traces) . await {
352- log:: error!(
353- "Failed to upsert {} traces to ClickHouse: {:?}" ,
354- ch_traces. len( ) ,
355- e
356- ) ;
340+ if is_feature_enabled ( Feature :: AggregateTraces ) {
341+ let trace_aggregations = TraceAggregation :: from_spans ( & spans, & span_usage_vec) ;
342+ if !trace_aggregations. is_empty ( ) {
343+ // Upsert trace statistics in PostgreSQL
344+ match upsert_trace_statistics_batch ( & db. pool , & trace_aggregations) . await {
345+ Ok ( updated_traces) => {
346+ // Convert to ClickHouse traces and upsert
347+ let ch_traces: Vec < CHTrace > = updated_traces
348+ . iter ( )
349+ . map ( |trace| CHTrace :: from_db_trace ( trace) )
350+ . collect ( ) ;
351+
352+ if let Err ( e) = upsert_traces_batch ( clickhouse. clone ( ) , & ch_traces) . await {
353+ log:: error!(
354+ "Failed to upsert {} traces to ClickHouse: {:?}" ,
355+ ch_traces. len( ) ,
356+ e
357+ ) ;
358+ }
359+ }
360+ Err ( e) => {
361+ log:: error!( "Failed to upsert trace statistics to PostgreSQL: {:?}" , e) ;
357362 }
358- }
359- Err ( e) => {
360- log:: error!( "Failed to upsert trace statistics to PostgreSQL: {:?}" , e) ;
361363 }
362364 }
363365 }
0 commit comments