@@ -12,12 +12,14 @@ import (
1212 ethtypes "github.com/ethereum/go-ethereum/core/types"
1313 "github.com/ethereum/go-ethereum/rpc"
1414 "github.com/storacha/filecoin-services/go/evmerrors"
15- "github.com/storacha/piri/pkg/pdp/types "
15+ "go.opentelemetry.io/otel/attribute "
1616 "go.uber.org/multierr"
1717 "golang.org/x/xerrors"
1818 "gorm.io/gorm"
1919 "gorm.io/gorm/clause"
2020
21+ "github.com/storacha/piri/pkg/pdp/types"
22+
2123 "github.com/storacha/piri/pkg/pdp/promise"
2224 "github.com/storacha/piri/pkg/pdp/scheduler"
2325 "github.com/storacha/piri/pkg/pdp/service/models"
@@ -85,12 +87,20 @@ func (s *SenderETH) Send(ctx context.Context, fromAddress common.Address, tx *et
8587 if dataErr .ErrorData () != nil {
8688 if parsedErr , failure := evmerrors .ParseRevert (dataErr .ErrorData ().(string )); failure == nil {
8789 log .Errorw ("parsed contract revert during gas estimation" , "error" , parsedErr )
90+ // NB(forrest): ErrorSelector returns the contract error code as hex,
91+ // selector values are finite and bounded, so adding it to the counter keeps
92+ // cardinality low while giving actionable diagnostics
93+ MessageEstimateGasFailureCounter .Inc (ctx , attribute .String ("selector" ,
94+ parsedErr .ErrorSelector ()), attribute .String ("method" , reason ))
8895 return common.Hash {}, types .NewError (types .KindInvalidInput , parsedErr .Error ())
8996 } else {
9097 log .Warnw ("failed to parse revert during gas estimation" , "parse_error" , failure , "original_error" , err )
9198 }
9299 }
93100 }
101+ // NB(forrest): otherwise we consider the selector unknown
102+ MessageEstimateGasFailureCounter .Inc (ctx , attribute .String ("selector" , "unknown" ),
103+ attribute .String ("method" , reason ))
94104 return common.Hash {}, fmt .Errorf ("failed to estimate gas: %w" , err )
95105 }
96106 if gasLimit == 0 {
@@ -360,6 +370,7 @@ func (s *SendTaskETH) Do(taskID scheduler.TaskID) (done bool, err error) {
360370 var sendError string
361371 if err != nil {
362372 sendError = err .Error ()
373+ MessageSendFailureCounter .Inc (ctx , attribute .String ("method" , dbTx .SendReason ))
363374 }
364375
365376 err = s .db .Model (& models.MessageSendsEth {}).
0 commit comments