@@ -136,11 +136,15 @@ func AddCDCBatchTablesForFlow(
136136 if enabled , err := internal .PeerDBMetricsRecordAggregatesEnabled (ctx , nil ); err == nil && enabled {
137137 recordAggregateMetrics = true
138138 }
139+ var syncedTablesCount int64
139140 tableNameOperations := make (map [string ][3 ]opWithValue , len (tableNameRowsMapping ))
140141 for destinationTableName , rowCounts := range tableNameRowsMapping {
141142 inserts := rowCounts .InsertCount .Load ()
142143 updates := rowCounts .UpdateCount .Load ()
143144 deletes := rowCounts .DeleteCount .Load ()
145+ if inserts + updates + deletes > 0 {
146+ syncedTablesCount ++
147+ }
144148 if recordAggregateMetrics {
145149 tableNameOperations [destinationTableName ] = [3 ]opWithValue {
146150 {op : otel_metrics .RecordOperationTypeInsert , count : inserts },
@@ -199,6 +203,9 @@ func AddCDCBatchTablesForFlow(
199203 return fmt .Errorf ("error while committing transaction for inserting and updating statistics: %w" , err )
200204 }
201205
206+ otelManager .Metrics .SyncedTablesPerBatchGauge .Record (ctx , syncedTablesCount , metric .WithAttributeSet (attribute .NewSet (
207+ attribute .Int64 (otel_metrics .BatchIdKey , batchID ))))
208+
202209 for destinationTableName , operations := range tableNameOperations {
203210 for _ , opAndCount := range operations {
204211 otelManager .Metrics .RecordsSyncedPerTableCounter .Add (ctx , int64 (opAndCount .count ), metric .WithAttributeSet (attribute .NewSet (
0 commit comments