| 93 | } |
| 94 | |
| 95 | func (cfg *Config) RegisterFlagsAndApplyDefaults(prefix string, f *flag.FlagSet) { |
| 96 | cfg.Ring.RegisterFlagsAndApplyDefaults(prefix, f) |
| 97 | cfg.PartitionRing.RegisterFlags(prefix, f) |
| 98 | |
| 99 | // Set defaults for new fields |
| 100 | cfg.CompleteBlockTimeout = defaultCompleteBlockTimeout |
| 101 | cfg.QueryBlockConcurrency = 10 |
| 102 | cfg.CompleteBlockConcurrency = 2 |
| 103 | cfg.Metrics.TimeOverlapCutoff = 0.2 |
| 104 | |
| 105 | // Set defaults for timing configuration (based on ingester defaults) |
| 106 | cfg.InstanceFlushPeriod = 5 * time.Second |
| 107 | cfg.InstanceCleanupPeriod = 5 * time.Minute |
| 108 | cfg.MaxTraceLive = 30 * time.Second |
| 109 | cfg.MaxTraceIdle = 5 * time.Second |
| 110 | cfg.MaxLiveTracesBytes = 250_000_000 // 250MB |
| 111 | cfg.MaxBlockDuration = 30 * time.Second |
| 112 | cfg.MaxBlockBytes = 50 * 1024 * 1024 |
| 113 | cfg.BlockReclaimGrace = 2 * time.Minute |
| 114 | |
| 115 | cfg.CommitInterval = 5 * time.Second |
| 116 | cfg.ConsumeFromKafka = true |
| 117 | |
| 118 | // Readiness config - default to disabled (backward compatible) |
| 119 | cfg.ReadinessTargetLag = 0 |
| 120 | cfg.ReadinessMaxWait = 30 * time.Minute |
| 121 | |
| 122 | cfg.FailOnHighLag = true |
| 123 | |
| 124 | cfg.RemoveOwnerOnShutdown = true |
| 125 | |
| 126 | cfg.initialBackoff = defaultInitialBackoff |
| 127 | cfg.maxBackoff = defaultMaxBackoff |
| 128 | |
| 129 | // Register flags for existing fields |
| 130 | f.DurationVar(&cfg.CompleteBlockTimeout, prefix+".complete-block-timeout", cfg.CompleteBlockTimeout, "Duration to keep blocks in the live store after they have been flushed.") |
| 131 | f.UintVar(&cfg.QueryBlockConcurrency, prefix+".concurrent-blocks", cfg.QueryBlockConcurrency, "Number of concurrent blocks to query for metrics.") |
| 132 | f.Float64Var(&cfg.Metrics.TimeOverlapCutoff, prefix+".metrics.time-overlap-cutoff", cfg.Metrics.TimeOverlapCutoff, "Time overlap cutoff ratio for metrics queries (0.0-1.0).") |
| 133 | f.DurationVar(&cfg.ReadinessTargetLag, prefix+".readiness-target-lag", cfg.ReadinessTargetLag, "Target lag threshold before live-store is ready. 0 disables waiting (backward compatible).") |
| 134 | f.DurationVar(&cfg.ReadinessMaxWait, prefix+".readiness-max-wait", cfg.ReadinessMaxWait, "Maximum time to wait for catching up at startup. Only used if readiness-target-lag > 0.") |
| 135 | f.BoolVar(&cfg.RemoveOwnerOnShutdown, prefix+".remove-owner-on-shutdown", cfg.RemoveOwnerOnShutdown, "Remove partition owner from the ring on shutdown.") |
| 136 | |
| 137 | cfg.WAL.RegisterFlags(f) // WAL config has no flags, only defaults |
| 138 | f.StringVar(&cfg.WAL.Filepath, prefix+".wal.path", "/var/tempo/live-store/traces", "Path at which store WAL blocks.") |
| 139 | f.StringVar(&cfg.ShutdownMarkerDir, prefix+".shutdown_marker_dir", "/var/tempo/live-store/shutdown-marker", "Path to the shutdown marker directory.") |
| 140 | } |
| 141 | |
| 142 | func (cfg *Config) Validate() error { |
| 143 | if cfg.CompleteBlockTimeout <= 0 { |