@@ -45,7 +45,6 @@ var ErrNotFound = consolidated.ErrNotFound
4545
4646type Consolidator struct {
4747 id principal.Signer
48- environment string
4948 egressTable egress.EgressTable
5049 consolidatedTable consolidated.ConsolidatedTable
5150 spaceStatsTable spacestats.SpaceStatsTable
@@ -61,7 +60,6 @@ type Consolidator struct {
6160
6261func New (
6362 id principal.Signer ,
64- environment string ,
6563 egressTable egress.EgressTable ,
6664 consolidatedTable consolidated.ConsolidatedTable ,
6765 spaceStatsTable spacestats.SpaceStatsTable ,
@@ -91,7 +89,6 @@ func New(
9189
9290 c := & Consolidator {
9391 id : id ,
94- environment : environment ,
9592 egressTable : egressTable ,
9693 consolidatedTable : consolidatedTable ,
9794 spaceStatsTable : spaceStatsTable ,
@@ -145,8 +142,12 @@ func (c *Consolidator) Stop() {
145142func (c * Consolidator ) Consolidate (ctx context.Context ) error {
146143 log .Info ("Starting consolidation cycle" )
147144
148- // Environment attribute for metrics
149- envAttr := attribute .String ("env" , c .environment )
145+ // Track consolidation run duration
146+ startTime := time .Now ()
147+ defer func () {
148+ durationMs := time .Since (startTime ).Milliseconds ()
149+ metrics .ConsolidationRunDuration .Record (ctx , durationMs )
150+ }()
150151
151152 // Get unprocessed records
152153 records , err := c .egressTable .GetUnprocessed (ctx , c .batchSize )
@@ -226,7 +227,7 @@ func (c *Consolidator) Consolidate(ctx context.Context) error {
226227
227228 // Increment consolidated bytes counter for this node
228229 nodeAttr := attribute .String ("node" , record .Node .String ())
229- metrics .ConsolidatedBytesPerNode .Add (ctx , int64 (totalEgress ), metric .WithAttributeSet (attribute .NewSet (nodeAttr , envAttr )))
230+ metrics .ConsolidatedBytesPerNode .Add (ctx , int64 (totalEgress ), metric .WithAttributeSet (attribute .NewSet (nodeAttr )))
230231
231232 bLog .Infof ("Consolidated %d bytes" , totalEgress )
232233 }
@@ -236,7 +237,7 @@ func (c *Consolidator) Consolidate(ctx context.Context) error {
236237 return fmt .Errorf ("marking records as processed: %w" , err )
237238 }
238239
239- metrics .UnprocessedBatches .Add (ctx , int64 (- len (records )), metric . WithAttributeSet ( attribute . NewSet ( envAttr )) )
240+ metrics .UnprocessedBatches .Add (ctx , int64 (- len (records )))
240241
241242 log .Infof ("Consolidation cycle completed. Processed %d records" , len (records ))
242243
0 commit comments