diff --git a/contrib/opbot/botmd/botmd.go b/contrib/opbot/botmd/botmd.go index e23444f05e..32ce34bfae 100644 --- a/contrib/opbot/botmd/botmd.go +++ b/contrib/opbot/botmd/botmd.go @@ -11,11 +11,13 @@ import ( "github.com/synapsecns/sanguine/core/dbcommon" "github.com/synapsecns/sanguine/core/metrics" "github.com/synapsecns/sanguine/core/metrics/instrumentation/slackertrace" + experimentalLogger "github.com/synapsecns/sanguine/core/metrics/logger" signerConfig "github.com/synapsecns/sanguine/ethergo/signer/config" "github.com/synapsecns/sanguine/ethergo/signer/signer" "github.com/synapsecns/sanguine/ethergo/submitter" cctpSql "github.com/synapsecns/sanguine/services/cctp-relayer/db/sql" omnirpcClient "github.com/synapsecns/sanguine/services/omnirpc/client" + "github.com/uptrace/opentelemetry-go-extra/otelzap" "golang.org/x/sync/errgroup" ) @@ -30,15 +32,20 @@ type Bot struct { signer signer.Signer submitter submitter.TransactionSubmitter screener screenerClient.ScreenerClient + logger experimentalLogger.ExperimentalLogger } // NewBot creates a new bot server. func NewBot(handler metrics.Handler, cfg config.Config) *Bot { server := slacker.NewClient(cfg.SlackBotToken, cfg.SlackAppToken) + + sugaredLogger := otelzap.New(experimentalLogger.MakeZapLogger()).Sugar() + bot := Bot{ handler: handler, cfg: cfg, server: server, + logger: experimentalLogger.MakeWrappedSugaredLogger(sugaredLogger), } // you should be able to run opbot even without signoz. diff --git a/contrib/opbot/botmd/commands.go b/contrib/opbot/botmd/commands.go index 0e81aa948c..8c91c4d98c 100644 --- a/contrib/opbot/botmd/commands.go +++ b/contrib/opbot/botmd/commands.go @@ -82,6 +82,7 @@ func (b *Bot) traceCommand() *slacker.CommandDefinition { // search for the transaction res, err := b.signozClient.SearchTraces(ctx.Context(), signoz.Last3Hr, searchMap) if err != nil { + b.logger.Errorf(ctx.Context(), "error searching for the transaction: %v", err) _, err := ctx.Response().Reply("error searching for the transaction") if err != nil { log.Println(err) @@ -290,6 +291,7 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition { } } if err != nil { + b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err) _, err := ctx.Response().Reply("error fetching quote request") if err != nil { log.Println(err) @@ -338,19 +340,23 @@ func (b *Bot) rfqRefund() *slacker.CommandDefinition { err = retry.WithBackoff( ctx.Context(), func(ctx context.Context) error { - txHash, err = relClient.GetTxHashByNonce(ctx, &relapi.GetTxByNonceRequest{ - ChainID: rawRequest.OriginChainID, - Nonce: nonce, - }) + txHash, err = relClient.GetTxHashByNonce( + ctx, + &relapi.GetTxByNonceRequest{ + ChainID: rawRequest.OriginChainID, + Nonce: nonce, + }) if err != nil { + b.logger.Errorf(ctx, "error fetching quote request: %v", err) return fmt.Errorf("error fetching quote request: %w", err) } return nil }, - retry.WithMaxAttempts(3), - retry.WithMaxAttemptTime(15*time.Second), + retry.WithMaxAttempts(5), + retry.WithMaxAttemptTime(30*time.Second), ) if err != nil { + b.logger.Errorf(ctx.Context(), "error fetching quote request: %v", err) _, err := ctx.Response().Reply(fmt.Sprintf("error fetching explorer link to refund, but nonce is %d", nonce)) log.Printf("error fetching quote request: %v\n", err) return diff --git a/contrib/opbot/go.mod b/contrib/opbot/go.mod index e251c320ce..71ec290d1a 100644 --- a/contrib/opbot/go.mod +++ b/contrib/opbot/go.mod @@ -28,6 +28,7 @@ require ( github.com/synapsecns/sanguine/services/cctp-relayer v0.0.0-00010101000000-000000000000 github.com/synapsecns/sanguine/services/omnirpc v0.0.0-00010101000000-000000000000 github.com/synapsecns/sanguine/services/rfq v0.0.0-00010101000000-000000000000 + github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.1 github.com/urfave/cli/v2 v2.27.2 golang.org/x/sync v0.8.0 gopkg.in/yaml.v2 v2.4.0 @@ -240,7 +241,6 @@ require ( github.com/uptrace/opentelemetry-go-extra/otelgorm v0.3.1 // indirect github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.1 // indirect github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.1 // indirect - github.com/uptrace/opentelemetry-go-extra/otelzap v0.3.1 // indirect github.com/valyala/fastjson v1.6.4 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect