Storage Backend Configuration Validation#
Jaeger validates storage backend configurations at two levels: structural selection (exactly one backend must be configured per slot) and backend-specific field constraints (enforced by each backend's own Validate() method). This two-phase design ensures invalid settings are caught before any storage factory or network connection is created.
Configuration Shape#
The root type is storageconfig.Config, defined in cmd/internal/storageconfig/config.go. It holds two maps:
TraceBackends map[string]TraceBackendโ one entry per named trace storage instanceMetricBackends map[string]MetricBackendโ one entry per named metric storage instance
TraceBackend supports: memory, badger, grpc, cassandra, elasticsearch, opensearch, and clickhouse. MetricBackend supports: prometheus, elasticsearch, opensearch, and clickhouse.
Each backend type is populated with defaults during Unmarshal (via confmap.Unmarshaler) before user values are overlaid โ for example, ClickHouse seeds from clickhouse.DefaultConfiguration() and Cassandra from cascfg.DefaultConfiguration().
Validation Flow#
Top-level Config.Validate()#
Config.Validate() iterates both backend maps and calls TraceBackend.Validate() and MetricBackend.Validate() for each entry, returning an error naming the offending backend.
TraceBackend.Validate() and MetricBackend.Validate()#
Both methods apply the same selection rule: exactly one backend type may be non-nil :
- Zero configured backends โ
"empty configuration"error - Multiple configured backends โ
"multiple backend types found"error
TraceBackend.Validate() additionally delegates to the selected backend's own Validate(). Currently this is wired only for memory โ cfg.Memory.Validate() is called explicitly so that an invalid max_traces is caught here rather than inside the store constructor . MetricBackend.Validate() checks selection only; it does not yet delegate to backend-specific validators.
Backend-Specific Validate() Methods#
Each backend config type owns its own field-level validation:
| Backend | Config file | Key checks |
|---|---|---|
| Memory | internal/storage/v2/memory/config.go | MaxTraces > 0, govalidator.ValidateStruct |
| Badger | internal/storage/v1/badger/config.go | govalidator.ValidateStruct |
| ClickHouse | internal/storage/v2/clickhouse/config.go | Addresses required; Protocol must be native or http; TTL non-negative and whole seconds; DefaultSearchDepth/MaxSearchDepth > 0; AttributeMetadataCacheTTL/AttributeMetadataCacheMaxSize โฅ 0 |
| Elasticsearch / OpenSearch | internal/storage/elasticsearch/config/config.go | Servers required/URL format; version support check; at most one auth method; rejects deprecated/unwired keys (sniffing.use_https, disable_health_check, bulk_processing.max_actions, etc.); rotation config; write_mode, poison_pill_handling, log_level enums |
| Prometheus | internal/config/promcfg/config.go | ServerURL required; latency_unit must be "ms" or "s" |
| Cassandra | internal/storage/cassandra/config/config.go | TTL durations, CompactionWindow via govalidator.ValidateStruct (see Cassandra Integration) |
Where Validation Is Invoked#
jaegerstorage extension (primary path)#
jaegerstorage.Config embeds storageconfig.Config and implements confmap.Validator by delegating to Config.Validate(). Additionally, storageExt.Start() explicitly loops over both backend maps and calls Validate() on each entry at extension startup, before any factory is lazily created โ ensuring errors surface immediately on startup rather than when the first request arrives.
Factories are then created on demand via CreateTraceStorageFactory() in cmd/internal/storageconfig/factory.go, which dispatches to the appropriate NewFactory() (e.g., clickhouse.NewFactory, memory.NewFactory) only after validation has already passed.
Remote-storage path#
cmd/remote-storage loads config via LoadConfigFile(), which calls confmap.Validate(cfg) to walk the config tree . The app's own Config.Validate() also checks single-backend constraints.
Notable Design Details#
ClickHouse factory does not self-validate. clickhouse.NewFactory() does not call cfg.Validate() before opening the connection. It relies on upstream validation having already run. If a ClickHouse config reaches NewFactory without going through the shared validation path, invalid fields (e.g., empty Addresses) would surface as a connection error rather than a config error.
TraceBackend.Validate() only explicitly chains to Memory.Validate(). Per the comment in the source, this was added to ensure the memory backend's constraints (e.g., max_traces) are enforced by both the confmap.Validate path (used by the collector extension) and the Viper path (used by remote-storage) . Other backends (ClickHouse, Badger, Cassandra, ES) are only validated via their own Validate() when the framework's config-tree walk reaches them, or when invoked directly.
Deprecated ES settings are hard errors. The Elasticsearch validator rejects previously-supported but now no-op keys (e.g., sniffing.use_https, disable_health_check) with actionable error messages pointing to the relevant PR .