From f60ecf2df2c99be4b9cd77a8892cb6a02e2514a2 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 9 Apr 2024 17:45:08 +0200 Subject: [PATCH] Improve startup logging Log version and commit right after starting and add more detailed logging around in-memory storage initialization. --- cmd/soroban-rpc/internal/daemon/daemon.go | 38 ++++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-rpc/internal/daemon/daemon.go b/cmd/soroban-rpc/internal/daemon/daemon.go index 9e21f97a..c2c224de 100644 --- a/cmd/soroban-rpc/internal/daemon/daemon.go +++ b/cmd/soroban-rpc/internal/daemon/daemon.go @@ -34,10 +34,11 @@ import ( ) const ( - prometheusNamespace = "soroban_rpc" - maxLedgerEntryWriteBatchSize = 150 - defaultReadTimeout = 5 * time.Second - defaultShutdownGracePeriod = 10 * time.Second + prometheusNamespace = "soroban_rpc" + maxLedgerEntryWriteBatchSize = 150 + defaultReadTimeout = 5 * time.Second + defaultShutdownGracePeriod = 10 * time.Second + inMemoryInitializationLedgerLogPeriod = 1_000_000 ) type Daemon struct { @@ -137,6 +138,11 @@ func MustNew(cfg *config.Config) *Daemon { logger.UseJSONFormatter() } + logger.WithFields(supportlog.F{ + "version": config.Version, + "commit": config.CommitHash, + }).Info("starting Soroban RPC") + core, err := newCaptiveCore(cfg, logger) if err != nil { logger.WithError(err).Fatal("could not create captive core") @@ -196,7 +202,20 @@ func MustNew(cfg *config.Config) *Daemon { // NOTE: We could optimize this to avoid unnecessary ingestion calls // (the range of txmetads can be larger than the store retention windows) // but it's probably not worth the pain. + var initialSeq uint32 + var currentSeq uint32 err = db.NewLedgerReader(dbConn).StreamAllLedgers(readTxMetaCtx, func(txmeta xdr.LedgerCloseMeta) error { + currentSeq = txmeta.LedgerSequence() + if initialSeq == 0 { + initialSeq = currentSeq + logger.WithFields(supportlog.F{ + "seq": currentSeq, + }).Info("initializing in-memory store") + } else if (currentSeq-initialSeq)%inMemoryInitializationLedgerLogPeriod == 0 { + logger.WithFields(supportlog.F{ + "seq": currentSeq, + }).Debug("still initializing in-memory store") + } if err := eventStore.IngestEvents(txmeta); err != nil { logger.WithError(err).Fatal("could not initialize event memory store") } @@ -205,6 +224,11 @@ func MustNew(cfg *config.Config) *Daemon { } return nil }) + if currentSeq != 0 { + logger.WithFields(supportlog.F{ + "seq": currentSeq, + }).Info("finished initializing in-memory store") + } if err != nil { logger.WithError(err).Fatal("could not obtain txmeta cache from the database") } @@ -285,10 +309,8 @@ func MustNew(cfg *config.Config) *Daemon { func (d *Daemon) Run() { d.logger.WithFields(supportlog.F{ - "version": config.Version, - "commit": config.CommitHash, - "addr": d.server.Addr, - }).Info("starting Soroban JSON RPC server") + "addr": d.server.Addr, + }).Info("starting HTTP server") panicGroup := util.UnrecoverablePanicGroup.Log(d.logger) panicGroup.Go(func() {