Skip to content

fix(instrumentation): demote per-call and setup logs to debug#95

Merged
sohil-kshirsagar merged 1 commit intomainfrom
sohil/fix/demote-noisy-instrumentation-logs
Apr 21, 2026
Merged

fix(instrumentation): demote per-call and setup logs to debug#95
sohil-kshirsagar merged 1 commit intomainfrom
sohil/fix/demote-noisy-instrumentation-logs

Conversation

@sohil-kshirsagar
Copy link
Copy Markdown
Contributor

@sohil-kshirsagar sohil-kshirsagar commented Apr 21, 2026

Demote per-call and one-time-setup instrumentation logs from info to debug, so customers initializing with TuskDrift.initialize(env=...) and no logger overrides don't see internal SDK chatter in their application output.

Why

A customer reported seeing [TuskDrift] [PATCHED_CONNECT] psycopg2.connect() called / mode: ... / app_ready: ... / RECORD mode: Connected to database successfully spam on every DB connection. The SDK's default log level is info (drift/core/logger.py), and these lines were emitted as logger.info(...) instead of logger.debug(...). Every psycopg2 connect produced 4 INFO lines; every Django request produced 2.

The convention was already correct in drift/instrumentation/redis/instrumentation.py and the sync paths in drift/instrumentation/psycopg/instrumentation.py (both use debug) — this PR makes the rest of the instrumentations match.

Guardrail

Added a ## Logging Levels section to .cursor/BUGBOT.md covering:

  1. Per-call lines inside patched function bodies must be debug.
  2. Startup "X instrumented" lines must be debug (matching the established convention) — and never include the patched function's repr.
  3. info is reserved for events a customer benefits from seeing once per process (e.g. "App marked as ready", circuit breaker transitions).
  4. Sibling instrumentations (e.g. psycopg2/psycopg3) must match levels — this bug was caused by the split between them.
  5. Raw header dicts, query args, and connection arguments shouldn't be logged at info even once.

What stays at info

Genuine one-time-per-process events where a customer is likely to want visibility: "App marked as ready", Rust-core enable/disable at startup, circuit breaker state transitions, time-travel activation.

Customers initializing with the default logger were seeing internal SDK
chatter on every psycopg2/psycopg3 connect and every Django request, plus
one-time setup noise at process startup. All of these should have been
debug-level; the convention was already established in the redis and
psycopg3-sync paths.

Also adds logging-level rules to .cursor/BUGBOT.md to prevent this
class of issue on future instrumentations.
@tusk-dev
Copy link
Copy Markdown
Contributor

tusk-dev Bot commented Apr 21, 2026

Tip

New to Tusk? Learn more here.

Code Review

Tusk Review: No issues found


Unit Tests

PR identified as a refactor

View output

View check history

Commit Unit Tests Created (UTC)
70f6ada PR identified as a refactor · Output Apr 21, 2026 8:58PM

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

@sohil-kshirsagar sohil-kshirsagar merged commit f25d71f into main Apr 21, 2026
28 checks passed
@sohil-kshirsagar sohil-kshirsagar deleted the sohil/fix/demote-noisy-instrumentation-logs branch April 21, 2026 21:04
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.

2 participants