Prevent SQLx warnings from feeding back into SQLite logs (#39592)

## Why

Warnings emitted while querying SQLite or acquiring a connection must not be
written back through the same SQLite log sink.

## What changed

- Disable the `sqlx::query` and `sqlx::pool::acquire` targets for the SQLite
  log filter.
- Keep warnings from other `sqlx` targets so useful diagnostics remain
  available.

## Testing

Extend the log filter test to verify that query and pool-acquisition warnings
are dropped while another `sqlx` warning is retained.

GitOrigin-RevId: cec9d4e07d113de8eccec7445ede0ae68e21886d
This commit is contained in:
Adam Perry @ OpenAI
2026-08-20 05:16:59 +00:00
committed by copyberry
parent e7c0e8eb9f
commit 493e0efb7b
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -55,6 +55,9 @@ pub fn default_filter() -> Targets {
.with_default(LevelFilter::TRACE)
.with_target("hyper_util", LevelFilter::WARN)
.with_target("log", LevelFilter::OFF)
// SQLite warnings must not feed back into the same SQLite log writer.
.with_target("sqlx::query", LevelFilter::OFF)
.with_target("sqlx::pool::acquire", LevelFilter::OFF)
.with_target("codex_rmcp_client", LevelFilter::INFO)
.with_target("codex_otel.log_only", LevelFilter::OFF)
.with_target("codex_otel.trace_safe", LevelFilter::OFF)
@@ -28,6 +28,9 @@ async fn sqlite_sink_filters_noisy_targets_without_dropping_useful_diagnostics()
tracing::trace!(target: "opentelemetry_sdk", "dropped-trace");
tracing::debug!(target: "opentelemetry_sdk", "dropped-debug");
tracing::info!(target: "opentelemetry_sdk", "retained-info");
tracing::warn!(target: "sqlx::query", "dropped-slow-query-warning");
tracing::warn!(target: "sqlx::pool::acquire", "dropped-slow-acquire-warning");
tracing::warn!(target: "sqlx::other", "retained-sqlx-warning");
tracing::debug!(target: "rmcp::transport", "dropped-rmcp-debug");
tracing::info!(target: "rmcp::transport", "retained-rmcp-info");
tracing::debug!(
@@ -87,6 +90,7 @@ async fn sqlite_sink_filters_noisy_targets_without_dropping_useful_diagnostics()
.collect::<Vec<_>>(),
vec![
("INFO", "opentelemetry_sdk", Some("retained-info")),
("WARN", "sqlx::other", Some("retained-sqlx-warning")),
("INFO", "rmcp::transport", Some("retained-rmcp-info")),
(
"INFO",