Skip to content

feat(sentry): stamp the release with the build hash and tag balena deploys - #3025

Merged
vpetersson merged 2 commits into
masterfrom
feat/sentry-release-hash-balena
Jun 7, 2026
Merged

feat(sentry): stamp the release with the build hash and tag balena deploys#3025
vpetersson merged 2 commits into
masterfrom
feat/sentry-release-hash-balena

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Issues Fixed

Closes the audit gap found after the balena deploy: every post-deploy event still reported release: 2026.6.2 (pyproject carries the last tagged version), so old- and new-code events could only be told apart by which tags they carried.

Description

  • Release = CalVer + build hashGIT_SHORT_HASH is already baked into every image by tools/image_builder (it's the same hash the docker tag uses), so the Sentry release becomes e.g. 2026.6.2+be63202, pinning each event to the exact build. + is semver build-metadata syntax; Sentry handles it natively. Host/dev runs without the env fall back to the bare CalVer.
  • balena: true|false tag — via the same is_balena_app() helper the reboot/shutdown tasks use. Balena and plain compose installs differ operationally (supervisor-managed restarts, no depends_on conditions), so triage knows which playbook applies.

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

…ploys

- The CalVer alone proved ambiguous: a balena OTA deploy from master
  ships new code while pyproject still carries the last tagged
  version, so pre- and post-deploy events were indistinguishable in
  the 2026.6.2 audit
- Postfix the release with GIT_SHORT_HASH (already baked into every
  image by tools/image_builder) as semver build metadata:
  2026.6.2+abc1234
- Tag events balena=true/false via the same is_balena_app() helper
  the reboot/shutdown tasks use, so triage knows which operational
  playbook applies
- Add tests for the release stamping and the tag wiring

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 17:01
@vpetersson vpetersson self-assigned this Jun 7, 2026
@vpetersson
vpetersson requested a review from Copilot June 7, 2026 17:01

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

Improves Sentry event attribution for Anthias deployments by stamping each event with a build-unique release identifier and tagging whether the instance is running under balena, closing the ambiguity where multiple post-deploy builds reported the same CalVer-only release.

Changes:

  • Add get_sentry_release() to compose a Sentry release as CalVer+GIT_SHORT_HASH (or None if unknown), and wire it into sentry_sdk.init(...).
  • Add a balena: true|false Sentry tag derived from is_balena_app().
  • Add unit tests covering get_sentry_release() behavior and a guard around how the balena tag is derived.

Reviewed changes

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

File Description
tests/test_sentry.py Adds regression tests for release stamping and a guard for the balena deployment tag.
src/anthias_server/django_project/settings.py Implements build-hash Sentry release stamping and sets a balena Sentry tag via the shared helper.

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

Comment thread tests/test_sentry.py Outdated
- Importing anthias_common.utils into Django settings dragged
  sh/requests/redis into every settings load and crashed django-stubs'
  mypy plugin in CI's slim environment
- Inline the BALENA env check as is_balena_deploy() and pin it
  against the canonical is_balena_app() helper in a test so the two
  can't drift (also replaces the brittle source-text assertion —
  Copilot)

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

sonarqubecloud Bot commented Jun 7, 2026

Copy link
Copy Markdown

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@vpetersson
vpetersson merged commit eb1baa6 into master Jun 7, 2026
10 checks passed
vpetersson added a commit that referenced this pull request Jun 9, 2026
- CalVer (YYYY.0M.MICRO); still June 2026, micro 2 -> 3
- Gives Sentry a real release boundary: every build since 2026.6.2
  reported the same base version (only the +git-hash differed), so
  resolved-in-next-release never stuck and fixed issues kept
  reopening on the next event. A version bump lets the deployed
  fixes actually clear from the board.
- Ships the crash/noise fixes merged since 2026.6.2: SQLite WAL +
  busy timeout (#3015), celery migration-gate (#3016) and
  asset-probe soft limits (#3017), transient-redis/CancelledError
  Sentry filtering + redis healthcheck (#3018/#3028), GitHub
  update-check log level (#3019), webview respawn on D-Bus death at
  setup and mid-play (#3020/#3031), resilient static-file scan
  (#3026), Wayland-socket wait (#3030), and Sentry release/board
  triage tags (#3021/#3025)

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