Skip to content

Commit

Permalink
Add metric for tx ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Apr 16, 2024
1 parent 5de3190 commit e8f66dd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/soroban-rpc/internal/ingest/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -309,14 +302,21 @@ 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
}
s.metrics.ingestionDurationMetric.
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
}
Expand Down

0 comments on commit e8f66dd

Please sign in to comment.