Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Add feature flag for extended ledger stats log #4017

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ type Config struct {
// IngestDisableStateVerification disables state verification
// `System.verifyState()` when set to `true`.
IngestDisableStateVerification bool
// IngestEnableExtendedLogLedgerStats enables extended ledger stats in
// logging.
IngestEnableExtendedLogLedgerStats bool
// ApplyMigrations will apply pending migrations to the horizon database
// before starting the horizon service
ApplyMigrations bool
Expand Down
7 changes: 7 additions & 0 deletions services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@ func Flags() (*Config, support.ConfigOptions) {
FlagDefault: false,
Usage: "ingestion system runs a verification routing to compare state in local database with history buckets, this can be disabled however it's not recommended",
},
&support.ConfigOption{
Name: "ingest-enable-extended-log-ledger-stats",
ConfigKey: &config.IngestEnableExtendedLogLedgerStats,
OptType: types.Bool,
FlagDefault: false,
Usage: "enables extended ledger stats in the log (ledger entry changes and operations stats)",
},
&support.ConfigOption{
Name: "apply-migrations",
ConfigKey: &config.ApplyMigrations,
Expand Down
26 changes: 15 additions & 11 deletions services/horizon/internal/ingest/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,17 +492,21 @@ func (r resumeState) run(s *system) (transition, error) {
r.addLedgerStatsMetricFromMap(s, "ledger", transactionStatsMap)
r.addProcessorDurationsMetricFromMap(s, transactionDurations)

log.
WithFields(changeStatsMap).
WithFields(transactionStatsMap).
WithFields(logpkg.F{
"sequence": ingestLedger,
"duration": duration,
"state": true,
"ledger": true,
"commit": true,
}).
Info("Processed ledger")
localLog := log.WithFields(logpkg.F{
"sequence": ingestLedger,
"duration": duration,
"state": true,
"ledger": true,
"commit": true,
})

if s.config.EnableExtendedLogLedgerStats {
localLog = localLog.
WithFields(changeStatsMap).
WithFields(transactionStatsMap)
}

localLog.Info("Processed ledger")

s.maybeVerifyState(ingestLedger)

Expand Down
8 changes: 5 additions & 3 deletions services/horizon/internal/ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ type Config struct {
RemoteCaptiveCoreURL string
NetworkPassphrase string

HistorySession db.SessionInterface
HistoryArchiveURL string
DisableStateVerification bool
HistorySession db.SessionInterface
HistoryArchiveURL string

DisableStateVerification bool
EnableExtendedLogLedgerStats bool

MaxReingestRetries int
ReingestRetryBackoffSeconds int
Expand Down
23 changes: 12 additions & 11 deletions services/horizon/internal/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,18 @@ func initIngester(app *App) {
// TODO:
// Use the first archive for now. We don't have a mechanism to
// use multiple archives at the same time currently.
HistoryArchiveURL: app.config.HistoryArchiveURLs[0],
CheckpointFrequency: app.config.CheckpointFrequency,
StellarCoreURL: app.config.StellarCoreURL,
StellarCoreCursor: app.config.CursorName,
CaptiveCoreBinaryPath: app.config.CaptiveCoreBinaryPath,
CaptiveCoreStoragePath: app.config.CaptiveCoreStoragePath,
CaptiveCoreReuseStoragePath: app.config.CaptiveCoreReuseStoragePath,
CaptiveCoreToml: app.config.CaptiveCoreToml,
RemoteCaptiveCoreURL: app.config.RemoteCaptiveCoreURL,
EnableCaptiveCore: app.config.EnableCaptiveCoreIngestion,
DisableStateVerification: app.config.IngestDisableStateVerification,
HistoryArchiveURL: app.config.HistoryArchiveURLs[0],
CheckpointFrequency: app.config.CheckpointFrequency,
StellarCoreURL: app.config.StellarCoreURL,
StellarCoreCursor: app.config.CursorName,
CaptiveCoreBinaryPath: app.config.CaptiveCoreBinaryPath,
CaptiveCoreStoragePath: app.config.CaptiveCoreStoragePath,
CaptiveCoreReuseStoragePath: app.config.CaptiveCoreReuseStoragePath,
CaptiveCoreToml: app.config.CaptiveCoreToml,
RemoteCaptiveCoreURL: app.config.RemoteCaptiveCoreURL,
EnableCaptiveCore: app.config.EnableCaptiveCoreIngestion,
DisableStateVerification: app.config.IngestDisableStateVerification,
EnableExtendedLogLedgerStats: app.config.IngestEnableExtendedLogLedgerStats,
})

if err != nil {
Expand Down