From 3e4ec2b7c3ef4948791a9485f776e6667241c5c1 Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Wed, 25 Nov 2026 10:01:44 -0800 Subject: [PATCH] fix(agent-hint): Count logs as on with capture_sentry_logs=True A log integration with capture_sentry_logs=True sends logs without enable_logs, so the setup hint said logs were off for a setup that sends them. --- sentry_sdk/_agent_hint.py | 8 +++++++- tests/test_agent_hint.py | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/_agent_hint.py b/sentry_sdk/_agent_hint.py index 96d1ab3c18..d43dc34fc6 100644 --- a/sentry_sdk/_agent_hint.py +++ b/sentry_sdk/_agent_hint.py @@ -144,7 +144,13 @@ def _setup_in_progress(init_file: str) -> bool: def _logs_on(client: "BaseClient") -> bool: options = client.options - return bool(options["enable_logs"] or options["_experiments"].get("enable_logs")) + if options["enable_logs"] or options["_experiments"].get("enable_logs"): + return True + # A log integration with capture_sentry_logs=True sends logs without enable_logs. + return any( + getattr(client.integrations.get(name), "capture_sentry_logs", None) is True + for name in ("logging", "loguru") + ) def register_coding_agent_hint_exit_hook() -> None: diff --git a/tests/test_agent_hint.py b/tests/test_agent_hint.py index aba88d0ce2..76b960ae76 100644 --- a/tests/test_agent_hint.py +++ b/tests/test_agent_hint.py @@ -8,6 +8,7 @@ import sentry_sdk import sentry_sdk._agent_hint +import sentry_sdk.integrations.logging from sentry_sdk._agent_hint import CODING_AGENT_ENV_VARS, SETUP_CHECKLIST_PATH AGENT_HINT_DSN = "https://public@sentry.example.com/1" @@ -68,6 +69,11 @@ def run(env, init_args="", before_run=None, inits=1): "enable_logs=True", "Sentry will get errors from this app but not the request trace around them. The checklist shows what to change.", ), + ( + {"CLAUDECODE": "1"}, + "integrations=[sentry_sdk.integrations.logging.LoggingIntegration(capture_sentry_logs=True)]", + "Sentry will get errors from this app but not the request trace around them. The checklist shows what to change.", + ), ( {"CLAUDECODE": "1"}, "traces_sample_rate=0.1",