Skip to content

feat(ingest): add STORE_MIN_SEVERITY second-tier severity gate#77

Merged
aksOps merged 1 commit intomainfrom
feat/store-min-severity
May 3, 2026
Merged

feat(ingest): add STORE_MIN_SEVERITY second-tier severity gate#77
aksOps merged 1 commit intomainfrom
feat/store-min-severity

Conversation

@aksOps
Copy link
Copy Markdown
Contributor

@aksOps aksOps commented May 3, 2026

Summary

Adds a second log-severity threshold (STORE_MIN_SEVERITY) 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 they still flow through LogCallback, so vectordb indexing, GraphRAG Drain template mining, and span/trace correlation keep seeing them.

Use case

"I want DEBUG/INFO logs to enrich my in-memory anomaly detection but I don't want them bloating SQLite."

INGEST_MIN_SEVERITY=DEBUG STORE_MIN_SEVERITY=WARN

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 as INGEST_MIN_SEVERITY" — the gate is a no-op out of the box. Setting STORE_MIN_SEVERITY ≤ INGEST_MIN_SEVERITY is also a no-op (logged as a warning at startup since the receiver has already filtered).

Implementation

File Change
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 so main.go can translate the env value
main.go Parse both thresholds; only enable the gate when store > ingest; warn on misconfig
CLAUDE.md Document both thresholds with the use-case example

Observability

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 reaches LogCallback; StoreFiltered=1
  • TestPipeline_StoreMinSeverity_Disabled_PersistsAllLogs — legacy path unchanged when SetStoreMinSeverity not called
  • go vet ./... clean
  • go build ./... clean
  • go test -race -timeout 180s ./... — 518 passed in 28 packages (+2 new)
  • CI green
  • SonarCloud Quality Gate green

🤖 Generated with Claude Code

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>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

@aksOps aksOps merged commit e4631a4 into main May 3, 2026
17 checks passed
@aksOps aksOps deleted the feat/store-min-severity branch May 3, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant