Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/ref_backend/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def build_app(settings: Settings, ref_config: Config, database: Database) -> Fas
if settings.SENTRY_DSN and settings.ENVIRONMENT != "local":
sentry_sdk.init(
dsn=str(settings.SENTRY_DSN),
release=settings.GIT_COMMIT,
enable_tracing=True,
)

Expand Down
20 changes: 20 additions & 0 deletions backend/tests/test_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from ref_backend import builder
from ref_backend.api import deps
from ref_backend.testing import test_ref_config, test_settings


def test_sentry_release_is_the_git_commit(monkeypatch):
calls = []
monkeypatch.setattr(builder.sentry_sdk, "init", lambda **kwargs: calls.append(kwargs))
settings = test_settings().model_copy(
update={
"SENTRY_DSN": "https://key@sentry.example.com/1",
"ENVIRONMENT": "staging",
"GIT_COMMIT": "e145da768b1725ce708150597a565df09c923dc3",
}
)
config = test_ref_config()

builder.build_app(settings, config, deps._get_database_dependency(settings, config))

assert calls[0]["release"] == "e145da768b1725ce708150597a565df09c923dc3"
1 change: 1 addition & 0 deletions changelog/140.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Backend errors reported to Sentry now carry the release they came from.
Loading