Refactor log DB into LogWriter interface#19234
Merged
Merged
Conversation
Collaborator
|
There are a lot of new abstractions there. Can we introduce a single trait LogWriter that implements tracing_subscriber::Layer and flush and make LogDb layer implement that? |
pakrym-oai
approved these changes
Apr 24, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Why
This prepares feedback log capture for a future remote app-server hook sink without changing the current local SQLite upload path. The important boundary is now intentionally small: a log sink is a tracing
Layerthat can also flush entries it has accepted.That keeps the existing SQLite implementation simple while giving the upcoming gRPC sink a place to fit beside it. SQLite and gRPC have different worker/write semantics, so this PR avoids introducing a shared buffered-sink abstraction and instead lets each
LogWriterown the buffering mechanics it needs.What Changed
LogSinkQueueConfigwith the existing local defaults: queue capacity512, batch size128, and flush interval2s.LogDbLayer::start_with_config(...)while preservingLogDbLayer::start(...)andlog_db::start(...)defaults.LogWritertrait as the minimal shared interface:tracing_subscriber::Layerplusflush().LogDbLayerimplementLogWriter.LogDbLayer; it still creates oneLogEntryper tracing event before queueing it for SQLite.try_send.Behavior Notes
This does not change the SQLite schema, retention behavior,
/feedback/upload, or Sentry upload behavior. Normal log events still drop when the queue is full; explicitflush()still waits for queue capacity and receiver processing before returning.Verification
cargo test -p codex-state log_dbcargo test -p codex-statejust fix -p codex-stateThe added tests cover configured batch-size flushing, configured interval flushing, queue-full drops, and the flush barrier semantics.