Skip to content

feat(sentry): add Sentry error tracking to the Django services - #3007

Merged
vpetersson merged 3 commits into
masterfrom
feat/sentry-sdk
Jun 7, 2026
Merged

feat(sentry): add Sentry error tracking to the Django services#3007
vpetersson merged 3 commits into
masterfrom
feat/sentry-sdk

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Not associated with an issue — adds crash reporting so fleet-wide errors surface in Sentry instead of only in device logs.

Description

Adds sentry-sdk (2.61.1) and initialises it in the shared Django settings module, so anthias-server, anthias-celery, and anthias-viewer all report crashes (each service loads this module at boot via DJANGO_SETTINGS_MODULE + django.setup()).

  • SENTRY_DSN env override — operators can point crash reporting at their own Sentry project, or set it to an empty string to disable sending entirely (verified: empty DSN → no transport, events dropped).
  • environment= mirrors the ENVIRONMENT env var (production default), so dev/CI events are filterable in Sentry.
  • release= comes from pyproject.toml's [project].version via the existing get_anthias_release() helper (handles the uv sync --no-install-project image layout).
  • PII is gated on the existing analytics_opt_out knob in anthias.conf — the same one that gates GA telemetry. Opted-out devices still report crashes, just without request headers / IPs / user data.

The dependency is added to the server and viewer groups, plus the mypy group (that CI job imports settings through the django-stubs plugin).

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

Adds sentry-sdk to the server and viewer dependency groups (plus the
mypy group, since that CI job imports settings) and initialises it in
the shared Django settings module, so anthias-server, anthias-celery,
and the viewer all report crashes.

- The DSN can be overridden via the SENTRY_DSN env var (pointing at
  an operator's own Sentry project), or set to an empty string to
  disable crash reporting entirely.
- environment= mirrors the ENVIRONMENT env var (production default)
  so dev/CI events are filterable in Sentry.
- release= comes from pyproject.toml's [project].version via the
  existing get_anthias_release() helper.
- send_default_pii is gated on the existing analytics_opt_out knob in
  anthias.conf — opted-out devices still report crashes, but without
  request headers / IPs / user data.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson
vpetersson requested a review from a team as a code owner June 7, 2026 05:09
@vpetersson vpetersson self-assigned this Jun 7, 2026
@vpetersson
vpetersson requested a review from Copilot June 7, 2026 05:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Sentry crash reporting across Anthias’ Django-based services by introducing sentry-sdk as a dependency and initializing it in the shared Django settings module loaded by anthias-server, anthias-celery, and anthias-viewer.

Changes:

  • Add sentry-sdk==2.61.1 to the relevant dependency groups (server/viewer/mypy/test via includes) and lockfile.
  • Initialize sentry_sdk in anthias_server.django_project.settings with DSN/env overrides, environment tagging, release tagging, and conditional PII enrichment based on analytics_opt_out.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
uv.lock Locks sentry-sdk==2.61.1 and includes it in the appropriate dependency groups.
src/anthias_server/django_project/settings.py Initializes Sentry early during Django settings import with environment/release/PII configuration.
pyproject.toml Adds sentry-sdk==2.61.1 to dependency groups used by runtime services and mypy CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/anthias_server/django_project/settings.py Outdated
vpetersson and others added 2 commits June 7, 2026 05:18
The unit suite is built to run with no external network dependencies
(conftest.py force-mocks Redis for the same reason), and exceptions
raised on purpose by failing tests must not land in the production
Sentry project. Default the DSN to empty under ENVIRONMENT=test or
pytest (reusing the existing argv detector, moved up from the
DATABASES section); an explicit SENTRY_DSN still wins so the
integration stack can opt in deliberately.

Addresses the Copilot review comment on the hardcoded default DSN.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Asserts the client has no DSN, builds no transport, and drops
capture calls when running under pytest, so a future settings.py
refactor can't silently re-enable sending from test runs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

@vpetersson
vpetersson merged commit e211ec8 into master Jun 7, 2026
10 checks passed
@vpetersson vpetersson mentioned this pull request Jun 7, 2026
5 tasks
vpetersson added a commit that referenced this pull request Jun 7, 2026
- CalVer (YYYY.0M.MICRO); still June 2026, micro 1 -> 2
- Ships the Qt 6 video audio fix (#3001) — PulseAudio in the viewer
  container; videos were silent on pi4-64/pi5/x86/arm64 since the
  QtMultimedia migration
- Adds the arm64/Qt6 pi3-64 board and the Rock Pi 4 fleet (#2985)
- Page-load watchdog so a stalled fetch can't freeze the display
  (#3003), Sentry error tracking for the Django services (#3007)
- Redis data persisted to the mounted volume so device identity
  survives recreation (#2983); unpinner also rolls OS + supervisor
  updates (#2984)
- Streamed backup downloads (#3005), 12-hour AM/PM asset times
  (#3002), BuildKit frontend via mirror.gcr.io (#3008)

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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