diff --git a/skills/sentry-python-sdk/SKILL.md b/skills/sentry-python-sdk/SKILL.md index 69534c06..65d97f1b 100644 --- a/skills/sentry-python-sdk/SKILL.md +++ b/skills/sentry-python-sdk/SKILL.md @@ -333,6 +333,7 @@ If a frontend exists without Sentry, suggest the matching skill: | Django exceptions not captured | Ensure `sentry_sdk.init()` is at the **top** of `settings.py` before other imports | | Flask exceptions not captured | Init must happen **before** `app = Flask(__name__)` | | FastAPI exceptions not captured | Init before `app = FastAPI()`; both `StarletteIntegration` and `FastApiIntegration` auto-enabled | +| ASGI chained exceptions suppressed | By default, Sentry's ASGI middleware strips exception chains (`raise exc from None`). To preserve chained exceptions, set `_experiments={"suppress_asgi_chained_exceptions": False}` in `sentry_sdk.init()` | | Celery task errors not captured | Must call `sentry_sdk.init()` in the **worker process** via `celeryd_init` signal | | Sanic init not working | Init must be inside `@app.listener("before_server_start")`, not module level | | uWSGI not capturing | Add `--enable-threads --py-call-uwsgi-fork-hooks` to uWSGI command | diff --git a/skills/sentry-python-sdk/references/logging.md b/skills/sentry-python-sdk/references/logging.md index e0957b5b..19c82024 100644 --- a/skills/sentry-python-sdk/references/logging.md +++ b/skills/sentry-python-sdk/references/logging.md @@ -159,13 +159,35 @@ sentry_sdk.init(dsn="...", enable_logs=True, before_send_log=before_log) ### Suppress noisy loggers +Events/breadcrumbs and Sentry Logs have **separate** ignore lists. `ignore_logger()` only suppresses breadcrumbs and error events — it does **not** affect Sentry Logs. This means framework loggers silenced for events (e.g. `django.server`) can still be captured as Sentry Logs. + ```python -from sentry_sdk.integrations.logging import ignore_logger +from sentry_sdk.integrations.logging import ( + ignore_logger, + ignore_logger_for_sentry_logs, + unignore_logger, + unignore_logger_for_sentry_logs, +) +# Suppress breadcrumbs and error events only (Sentry Logs still captured) ignore_logger("a.spammy.logger") ignore_logger("boto3.*") # glob patterns supported + +# Suppress Sentry Logs only (breadcrumbs and error events still captured) +ignore_logger_for_sentry_logs("a.noisy.logger") + +# Reverse a previous ignore +unignore_logger("a.spammy.logger") +unignore_logger_for_sentry_logs("a.noisy.logger") ``` +| Helper | Affects | +|--------|---------| +| `ignore_logger(name)` | Breadcrumbs + error events only | +| `ignore_logger_for_sentry_logs(name)` | Sentry Logs only | +| `unignore_logger(name)` | Reverses `ignore_logger()` | +| `unignore_logger_for_sentry_logs(name)` | Reverses `ignore_logger_for_sentry_logs()` | + ## Decision Table | Goal | Tool | @@ -176,6 +198,9 @@ ignore_logger("boto3.*") # glob patterns supported | Breadcrumbs for error context | `LoggingIntegration(level=logging.INFO)` (default) | | Auto-create error events from log calls | `LoggingIntegration(event_level=logging.ERROR)` (default) | | Drop/modify a log before sending | `before_send_log` callback | +| Suppress a logger from breadcrumbs/events only | `ignore_logger(name)` | +| Suppress a logger from Sentry Logs only | `ignore_logger_for_sentry_logs(name)` | +| Re-enable a previously ignored logger | `unignore_logger(name)` / `unignore_logger_for_sentry_logs(name)` | ## Automatically Added Attributes @@ -200,3 +225,5 @@ Every log record receives these automatically: | Logger's own level filters out records | SDK respects the logger's configured level — set it to `logging.INFO` or lower | | Too many log records hitting quota | Use `before_send_log` to filter by severity or attribute | | Loguru not auto-activating | Verify `loguru` is installed; or add `LoguruIntegration()` explicitly | +| `ignore_logger()` still sending Sentry Logs | Expected — `ignore_logger()` only suppresses breadcrumbs/events; use `ignore_logger_for_sentry_logs()` to suppress Sentry Logs | +| Framework logger (e.g. `django.server`) not appearing in Sentry Logs | It may be in the default Sentry Logs ignore list; call `unignore_logger_for_sentry_logs("django.server")` |