feat(ingest): add STORE_MIN_SEVERITY second-tier severity gate#77
Merged
feat(ingest): add STORE_MIN_SEVERITY second-tier severity gate#77
Conversation
Adds a second log-severity threshold that runs at the persist boundary inside the async ingest pipeline. Logs above INGEST_MIN_SEVERITY but below STORE_MIN_SEVERITY are dropped from the BatchCreateAll write but still flow through LogCallback so in-memory enrichers (vectordb, GraphRAG Drain template mining, span/trace correlation) keep seeing them. Use case: keep SQLite small while letting in-memory anomaly detection benefit from the verbose stream. Example: INGEST_MIN_SEVERITY=DEBUG STORE_MIN_SEVERITY=WARN Default behavior is unchanged — empty STORE_MIN_SEVERITY means "use the ingest threshold", so the gate is a no-op out of the box. Setting the store threshold ≤ ingest threshold is also a no-op (logged as warning). Implementation - internal/config/config.go: add StoreMinSeverity field + STORE_MIN_SEVERITY env - internal/ingest/pipeline.go: storeMinSeverity field, SetStoreMinSeverity setter, filter inside process() that splits b.Logs into persisted vs callback-only, atomic StoreFiltered counter, exposed via PipelineStats - internal/ingest/otlp.go: export ParseSeverity wrapper for main.go wiring - main.go: parse both thresholds, only enable the gate when store > ingest, warn on misconfig - CLAUDE.md: document both thresholds with use-case examples Tests - TestPipeline_StoreMinSeverity_DropsBelowThresholdFromPersist: WARN gate drops INFO from persist but INFO still reaches LogCallback; StoreFiltered=1 - TestPipeline_StoreMinSeverity_Disabled_PersistsAllLogs: legacy path unchanged when SetStoreMinSeverity not called Verification - go vet ./... clean - go build ./... clean - go test -race -timeout 180s ./... — 518 passed in 28 packages (+2 new) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds a second log-severity threshold (
STORE_MIN_SEVERITY) that runs at the persist boundary inside the async ingest pipeline. Logs aboveINGEST_MIN_SEVERITYbut belowSTORE_MIN_SEVERITYare dropped from theBatchCreateAllwrite — but they still flow throughLogCallback, so vectordb indexing, GraphRAG Drain template mining, and span/trace correlation keep seeing them.Use case
DEBUG → reaches receiver, fires
LogCallback, NOT persisted.WARN/ERROR → reaches receiver, fires
LogCallback, persisted normally.Backwards compatibility
Default (
STORE_MIN_SEVERITY="") means "use the same threshold asINGEST_MIN_SEVERITY" — the gate is a no-op out of the box. SettingSTORE_MIN_SEVERITY ≤ INGEST_MIN_SEVERITYis also a no-op (logged as a warning at startup since the receiver has already filtered).Implementation
internal/config/config.goStoreMinSeverityfield +STORE_MIN_SEVERITYenvinternal/ingest/pipeline.gostoreMinSeverityfield,SetStoreMinSeveritysetter, filter insideprocess()that splitsb.Logsinto persisted vs callback-only, atomicStoreFilteredcounter exposed viaPipelineStatsinternal/ingest/otlp.goParseSeveritywrapper somain.gocan translate the env valuemain.gostore > ingest; warn on misconfigCLAUDE.mdObservability
Pipeline.Stats().StoreFiltered(int64) — count of logs dropped from persist by the store gate. Available via the existing pipeline stats accessor.Test plan
TestPipeline_StoreMinSeverity_DropsBelowThresholdFromPersist— WARN gate drops INFO from persist; INFO still reachesLogCallback;StoreFiltered=1TestPipeline_StoreMinSeverity_Disabled_PersistsAllLogs— legacy path unchanged whenSetStoreMinSeveritynot calledgo vet ./...cleango build ./...cleango test -race -timeout 180s ./...— 518 passed in 28 packages (+2 new)🤖 Generated with Claude Code