@@ -80,6 +80,12 @@ func (c *Committer) Start(ctx context.Context) {
8080}
8181
8282func (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+
8389 latestCommittedBlockNumber , err := c .storage .MainStorage .GetMaxBlockNumber (c .rpc .GetChainID ())
8490 log .Info ().Msgf ("Committer found this max block number in main storage: %s" , latestCommittedBlockNumber .String ())
8591 if err != nil {
@@ -117,7 +123,11 @@ func (c *Committer) getSequentialBlockDataToCommit(ctx context.Context) ([]commo
117123 return nil , nil
118124 }
119125
126+ startTime := time .Now ()
120127 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+
121131 if err != nil {
122132 return nil , fmt .Errorf ("error fetching blocks to commit: %v" , err )
123133 }
@@ -168,20 +178,29 @@ func (c *Committer) commit(ctx context.Context, blockData []common.BlockData) er
168178 }
169179 log .Debug ().Msgf ("Committing %d blocks" , len (blockNumbers ))
170180
181+ mainStorageStart := time .Now ()
171182 if err := c .storage .MainStorage .InsertBlockData (blockData ); err != nil {
172183 log .Error ().Err (err ).Msgf ("Failed to commit blocks: %v" , blockNumbers )
173184 return fmt .Errorf ("error saving data to main storage: %v" , err )
174185 }
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 ())
175188
189+ publishStart := time .Now ()
176190 go func () {
177191 if err := c .publisher .PublishBlockData (blockData ); err != nil {
178192 log .Error ().Err (err ).Msg ("Failed to publish block data to kafka" )
179193 }
194+ log .Debug ().Str ("metric" , "publish_duration" ).Msgf ("Publisher.PublishBlockData duration: %f" , time .Since (publishStart ).Seconds ())
195+ metrics .PublishDuration .Observe (time .Since (publishStart ).Seconds ())
180196 }()
181197
198+ stagingDeleteStart := time .Now ()
182199 if err := c .storage .StagingStorage .DeleteStagingData (blockData ); err != nil {
183200 return fmt .Errorf ("error deleting data from staging storage: %v" , err )
184201 }
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 ())
185204
186205 // Find highest block number from committed blocks
187206 highestBlock := blockData [0 ].Block
0 commit comments