@@ -80,6 +80,12 @@ func (c *Committer) Start(ctx context.Context) {
80
80
}
81
81
82
82
func (c * Committer ) getBlockNumbersToCommit () ([]* big.Int , error ) {
83
+ startTime := time .Now ()
84
+ defer func () {
85
+ log .Debug ().Str ("metric" , "get_block_numbers_to_commit_duration" ).Msgf ("getBlockNumbersToCommit duration: %f" , time .Since (startTime ).Seconds ())
86
+ metrics .GetBlockNumbersToCommitDuration .Observe (time .Since (startTime ).Seconds ())
87
+ }()
88
+
83
89
latestCommittedBlockNumber , err := c .storage .MainStorage .GetMaxBlockNumber (c .rpc .GetChainID ())
84
90
log .Info ().Msgf ("Committer found this max block number in main storage: %s" , latestCommittedBlockNumber .String ())
85
91
if err != nil {
@@ -117,7 +123,11 @@ func (c *Committer) getSequentialBlockDataToCommit(ctx context.Context) ([]commo
117
123
return nil , nil
118
124
}
119
125
126
+ startTime := time .Now ()
120
127
blocksData , err := c .storage .StagingStorage .GetStagingData (storage.QueryFilter {BlockNumbers : blocksToCommit , ChainId : c .rpc .GetChainID ()})
128
+ log .Debug ().Str ("metric" , "get_staging_data_duration" ).Msgf ("StagingStorage.GetStagingData duration: %f" , time .Since (startTime ).Seconds ())
129
+ metrics .GetStagingDataDuration .Observe (time .Since (startTime ).Seconds ())
130
+
121
131
if err != nil {
122
132
return nil , fmt .Errorf ("error fetching blocks to commit: %v" , err )
123
133
}
@@ -168,20 +178,29 @@ func (c *Committer) commit(ctx context.Context, blockData []common.BlockData) er
168
178
}
169
179
log .Debug ().Msgf ("Committing %d blocks" , len (blockNumbers ))
170
180
181
+ mainStorageStart := time .Now ()
171
182
if err := c .storage .MainStorage .InsertBlockData (blockData ); err != nil {
172
183
log .Error ().Err (err ).Msgf ("Failed to commit blocks: %v" , blockNumbers )
173
184
return fmt .Errorf ("error saving data to main storage: %v" , err )
174
185
}
186
+ log .Debug ().Str ("metric" , "main_storage_insert_duration" ).Msgf ("MainStorage.InsertBlockData duration: %f" , time .Since (mainStorageStart ).Seconds ())
187
+ metrics .MainStorageInsertDuration .Observe (time .Since (mainStorageStart ).Seconds ())
175
188
189
+ publishStart := time .Now ()
176
190
go func () {
177
191
if err := c .publisher .PublishBlockData (blockData ); err != nil {
178
192
log .Error ().Err (err ).Msg ("Failed to publish block data to kafka" )
179
193
}
194
+ log .Debug ().Str ("metric" , "publish_duration" ).Msgf ("Publisher.PublishBlockData duration: %f" , time .Since (publishStart ).Seconds ())
195
+ metrics .PublishDuration .Observe (time .Since (publishStart ).Seconds ())
180
196
}()
181
197
198
+ stagingDeleteStart := time .Now ()
182
199
if err := c .storage .StagingStorage .DeleteStagingData (blockData ); err != nil {
183
200
return fmt .Errorf ("error deleting data from staging storage: %v" , err )
184
201
}
202
+ log .Debug ().Str ("metric" , "staging_delete_duration" ).Msgf ("StagingStorage.DeleteStagingData duration: %f" , time .Since (stagingDeleteStart ).Seconds ())
203
+ metrics .StagingDeleteDuration .Observe (time .Since (stagingDeleteStart ).Seconds ())
185
204
186
205
// Find highest block number from committed blocks
187
206
highestBlock := blockData [0 ].Block
0 commit comments