From e8f66dd19e9b53d31e4206be32f90f1c76c05cb2 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 16 Apr 2024 16:25:28 -0700 Subject: [PATCH] Add metric for tx ingestion --- cmd/soroban-rpc/internal/ingest/service.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-rpc/internal/ingest/service.go b/cmd/soroban-rpc/internal/ingest/service.go index 057ff702..b2e60c99 100644 --- a/cmd/soroban-rpc/internal/ingest/service.go +++ b/cmd/soroban-rpc/internal/ingest/service.go @@ -266,9 +266,6 @@ func (s *Service) ingest(ctx context.Context, sequence uint32) error { } }() - s.logger.Debugf("Ingesting ledger %d (%d tx): %+v", - sequence, ledgerCloseMeta.CountTransactions(), ledgerCloseMeta.V1) - if err := s.ingestLedgerEntryChanges(ctx, reader, tx, 0); err != nil { return err } @@ -287,10 +284,6 @@ func (s *Service) ingest(ctx context.Context, sequence uint32) error { return err } - if err := tx.TransactionHandler().InsertTransactions(ledgerCloseMeta); err != nil { - return err - } - if err := s.ingestLedgerCloseMeta(tx, ledgerCloseMeta); err != nil { return err } @@ -309,7 +302,6 @@ func (s *Service) ingest(ctx context.Context, sequence uint32) error { func (s *Service) ingestLedgerCloseMeta(tx db.WriteTx, ledgerCloseMeta xdr.LedgerCloseMeta) error { startTime := time.Now() - if err := tx.LedgerWriter().InsertLedger(ledgerCloseMeta); err != nil { return err } @@ -317,6 +309,14 @@ func (s *Service) ingestLedgerCloseMeta(tx db.WriteTx, ledgerCloseMeta xdr.Ledge With(prometheus.Labels{"type": "ledger_close_meta"}). Observe(time.Since(startTime).Seconds()) + startTime = time.Now() + if err := tx.TransactionHandler().InsertTransactions(ledgerCloseMeta); err != nil { + return err + } + s.metrics.ingestionDurationMetric. + With(prometheus.Labels{"type": "transactions"}). + Observe(time.Since(startTime).Seconds()) + if err := s.eventStore.IngestEvents(ledgerCloseMeta); err != nil { return err }