@@ -9,12 +9,17 @@ import (
99 rpccoretypes "github.com/cometbft/cometbft/rpc/core/types"
1010 comettypes "github.com/cometbft/cometbft/types"
1111 nodetypes "github.com/initia-labs/opinit-bots/node/types"
12+ "github.com/initia-labs/opinit-bots/sentry_integration"
1213 "github.com/initia-labs/opinit-bots/types"
1314 "github.com/pkg/errors"
1415)
1516
1617// handleBeginBlock handles the begin block.
1718func (n * Node ) handleBeginBlock (ctx types.Context , blockID []byte , protoBlock * prototypes.Block , latestHeight int64 ) error {
19+ span , ctx := sentry_integration .StartSentrySpan (ctx , "handleBeginBlock" , "Handles the begin block" )
20+ defer span .Finish ()
21+ span .SetTag ("height" , fmt .Sprintf ("%d" , latestHeight ))
22+
1823 if n .beginBlockHandler != nil {
1924 return n .beginBlockHandler (ctx , nodetypes.BeginBlockArgs {
2025 BlockID : blockID ,
@@ -27,6 +32,10 @@ func (n *Node) handleBeginBlock(ctx types.Context, blockID []byte, protoBlock *p
2732
2833// handleBlockTxs handles the block transactions.
2934func (n * Node ) handleBlockTxs (ctx types.Context , block * rpccoretypes.ResultBlock , blockResult * rpccoretypes.ResultBlockResults , latestHeight int64 ) error {
35+ span , ctx := sentry_integration .StartSentrySpan (ctx , "handleBlockTxs" , "Handles the block transactions" )
36+ defer span .Finish ()
37+ span .SetTag ("height" , fmt .Sprintf ("%d" , latestHeight ))
38+
3039 if len (block .Block .Txs ) != len (blockResult .TxsResults ) {
3140 return fmt .Errorf ("mismatch in transactions and results count: %d vs %d" , len (block .Block .Txs ), len (blockResult .TxsResults ))
3241 }
@@ -55,6 +64,10 @@ func (n *Node) handleBlockTxs(ctx types.Context, block *rpccoretypes.ResultBlock
5564
5665// handleFinalizeBlock handles the finalize block.
5766func (n * Node ) handleFinalizeBlock (ctx types.Context , blockHeight int64 , blockTime time.Time , blockResult * rpccoretypes.ResultBlockResults , latestHeight int64 ) error {
67+ span , ctx := sentry_integration .StartSentrySpan (ctx , "handleFinalizeBlock" , "Handles the finalize block" )
68+ defer span .Finish ()
69+ span .SetTag ("height" , fmt .Sprintf ("%d" , latestHeight ))
70+
5871 return n .handleEvents (ctx , blockHeight , blockTime , blockResult .FinalizeBlockEvents , latestHeight , nil , 0 )
5972}
6073
@@ -73,6 +86,10 @@ func (n *Node) handleEvents(ctx types.Context, blockHeight int64, blockTime time
7386
7487// handleEndBlock handles the end block.
7588func (n * Node ) handleEndBlock (ctx types.Context , blockID []byte , protoBlock * prototypes.Block , latestHeight int64 ) error {
89+ span , ctx := sentry_integration .StartSentrySpan (ctx , "handleEndBlock" , "Handles the end block" )
90+ defer span .Finish ()
91+ span .SetTag ("height" , fmt .Sprintf ("%d" , latestHeight ))
92+
7693 if n .endBlockHandler != nil {
7794 return n .endBlockHandler (ctx , nodetypes.EndBlockArgs {
7895 BlockID : blockID ,
@@ -84,8 +101,13 @@ func (n *Node) handleEndBlock(ctx types.Context, blockID []byte, protoBlock *pro
84101}
85102
86103// handleRawBlock handles the raw block bytes.
87- func (n * Node ) handleRawBlock (ctx types.Context , blockHeight int64 , latestHeight int64 , blockBytes []byte ) error {
104+ func (n * Node ) handleRawBlock (parentCtx types.Context , blockHeight int64 , latestHeight int64 , blockBytes []byte ) error {
88105 if n .rawBlockHandler != nil {
106+ transactions , ctx := sentry_integration .StartSentryTransaction (parentCtx , "handleRawBlock" , "Handles the raw block bytes" )
107+ defer transactions .Finish ()
108+ transactions .SetTag ("height" , fmt .Sprintf ("%d" , blockHeight ))
109+ transactions .SetTag ("latest_height" , fmt .Sprintf ("%d" , latestHeight ))
110+
89111 return n .rawBlockHandler (ctx , nodetypes.RawBlockArgs {
90112 BlockHeight : blockHeight ,
91113 LatestHeight : latestHeight ,
0 commit comments