Add metrics in tx-tracker to count destination tx inserted (#1233)

This commit is contained in:
walker-16 2024-03-22 11:30:46 -03:00 committed by GitHub
parent e843100678
commit cc2ca592e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 2 deletions

View File

@ -49,7 +49,6 @@ func Run() {
logger.Info("Starting wormhole-explorer-tx-tracker ...")
// create rpc pool
// TODO: review: RpcProviderSettings
rpcPool, err := newRpcPool(cfg)
if err != nil {
logger.Fatal("Failed to initialize rpc pool: ", zap.Error(err))

View File

@ -176,6 +176,7 @@ func (c *Consumer) processTargetTx(ctx context.Context, msg queue.ConsumerMessag
From: attr.From,
To: attr.To,
Status: attr.Status,
Metrics: c.metrics,
}
err := ProcessTargetTx(ctx, c.logger, c.repository, &p)

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/wormhole-foundation/wormhole-explorer/common/domain"
"github.com/wormhole-foundation/wormhole-explorer/txtracker/internal/metrics"
sdk "github.com/wormhole-foundation/wormhole/sdk/vaa"
"go.uber.org/zap"
)
@ -29,6 +30,7 @@ type ProcessTargetTxParams struct {
From string
To string
Status string
Metrics metrics.Metrics
}
func ProcessTargetTx(
@ -61,7 +63,11 @@ func ProcessTargetTx(
logger.Warn("Transaction should not be updated", zap.String("vaaId", params.VaaId), zap.Error(err))
return nil
}
return repository.UpsertTargetTx(ctx, update)
err = repository.UpsertTargetTx(ctx, update)
if err == nil {
params.Metrics.IncDestinationTxInserted(uint16(params.ChainId))
}
return err
}
func checkTxShouldBeUpdated(ctx context.Context, tx *TargetTxUpdate, repository *Repository) (bool, error) {

View File

@ -17,6 +17,9 @@ func (d *DummyMetrics) IncVaaUnfiltered(chainID uint16) {}
// IncOriginTxInserted is a dummy implementation of IncOriginTxInserted.
func (d *DummyMetrics) IncOriginTxInserted(chainID uint16) {}
// IncDestinationTxInserted is a dummy implementation of IncDestinationTxInserted.
func (d *DummyMetrics) IncDestinationTxInserted(chainID uint16) {}
// IncVaaWithoutTxHash is a dummy implementation of IncVaaWithoutTxHash.
func (d *DummyMetrics) IncVaaWithoutTxHash(chainID uint16) {}

View File

@ -8,6 +8,7 @@ type Metrics interface {
IncOriginTxInserted(chainID uint16)
IncVaaWithoutTxHash(chainID uint16)
IncVaaWithTxHashFixed(chainID uint16)
IncDestinationTxInserted(chainID uint16)
AddVaaProcessedDuration(chainID uint16, duration float64)
IncCallRpcSuccess(chainID uint16, rpc string)
IncCallRpcError(chainID uint16, rpc string)

View File

@ -91,6 +91,12 @@ func (m *PrometheusMetrics) IncOriginTxInserted(chainID uint16) {
m.vaaTxTrackerCount.WithLabelValues(chain, "origin_tx_inserted").Inc()
}
// IncDestinationTxInserted increments the number of inserted destination tx.
func (m *PrometheusMetrics) IncDestinationTxInserted(chainID uint16) {
chain := vaa.ChainID(chainID).String()
m.vaaTxTrackerCount.WithLabelValues(chain, "destination_tx_inserted").Inc()
}
// AddVaaProcessedDuration adds the duration of vaa processing.
func (m *PrometheusMetrics) AddVaaProcessedDuration(chainID uint16, duration float64) {
chain := vaa.ChainID(chainID).String()