@@ -90,6 +90,15 @@ type Aggregator struct {
9090func NewAggregator (aggregatorConfig config.AggregatorConfig ) (* Aggregator , error ) {
9191 newBatchChan := make (chan * servicemanager.ContractAlignedLayerServiceManagerNewBatchV3 )
9292
93+ logger := aggregatorConfig .BaseConfig .Logger
94+
95+ // Metrics
96+ reg := prometheus .NewRegistry ()
97+ aggregatorMetrics := metrics .NewMetrics (aggregatorConfig .Aggregator .MetricsIpPortAddress , reg , logger )
98+
99+ // Telemetry
100+ aggregatorTelemetry := NewTelemetry (aggregatorConfig .Aggregator .TelemetryIpPortAddress , logger )
101+
93102 avsReader , err := chainio .NewAvsReaderFromConfig (aggregatorConfig .BaseConfig , aggregatorConfig .EcdsaConfig )
94103 if err != nil {
95104 return nil , err
@@ -100,7 +109,7 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
100109 return nil , err
101110 }
102111
103- avsWriter , err := chainio .NewAvsWriterFromConfig (aggregatorConfig .BaseConfig , aggregatorConfig .EcdsaConfig )
112+ avsWriter , err := chainio .NewAvsWriterFromConfig (aggregatorConfig .BaseConfig , aggregatorConfig .EcdsaConfig , aggregatorMetrics )
104113 if err != nil {
105114 return nil , err
106115 }
@@ -121,7 +130,6 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
121130
122131 aggregatorPrivateKey := aggregatorConfig .EcdsaConfig .PrivateKey
123132
124- logger := aggregatorConfig .BaseConfig .Logger
125133 clients , err := sdkclients .BuildAll (chainioConfig , aggregatorPrivateKey , logger )
126134 if err != nil {
127135 logger .Errorf ("Cannot create sdk clients" , "err" , err )
@@ -147,13 +155,6 @@ func NewAggregator(aggregatorConfig config.AggregatorConfig) (*Aggregator, error
147155 avsRegistryService := avsregistry .NewAvsRegistryServiceChainCaller (avsReader .ChainReader , operatorPubkeysService , logger )
148156 blsAggregationService := blsagg .NewBlsAggregatorService (avsRegistryService , hashFunction , logger )
149157
150- // Metrics
151- reg := prometheus .NewRegistry ()
152- aggregatorMetrics := metrics .NewMetrics (aggregatorConfig .Aggregator .MetricsIpPortAddress , reg , logger )
153-
154- // Telemetry
155- aggregatorTelemetry := NewTelemetry (aggregatorConfig .Aggregator .TelemetryIpPortAddress , logger )
156-
157158 nextBatchIndex := uint32 (0 )
158159
159160 aggregator := Aggregator {
0 commit comments