feat(tests): integration with Oban and Broadway#1056
Draft
solnic wants to merge 3 commits into
Draft
Conversation
9f7c9b8 to
d18a6d5
Compare
260edad to
ee71a75
Compare
Introduces the mechanism that future commits will use to install per-test telemetry handlers for popular libraries (Oban, Broadway). This commit ships only the infrastructure: option parsing, a unique per-test handler ID, automatic detach on test exit, and a generic __handle_allowance_event__/4 handler that calls allow_sentry_reports/2 in response to the configured event. The internal allowance_handlers/1 dispatch is empty — any atom passed under :allowance currently raises a clear ArgumentError naming the unsupported entry. Oban and Broadway clauses land in follow-up commits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Installs telemetry handlers that capture the test pid at Oban job insert time and route the worker's captured events back to that test on job start. The pairing makes auto-allowance safe under async: true even when multiple tests share an Oban supervisor, because every job is uniquely tied to the test that scheduled it (rather than to whichever telemetry handler happened to fire first). The tag store lives in Sentry.Test.Registry as a public ETS table (:sentry_test_oban_job_tags) alongside the existing scope-allow table. Tags are dropped on :stop/:exception and defensively on test exit so jobs that crash before completion don't leave stale entries behind. Handlers guard on `is_integer(job.id)` so synthetic jobs from inline mode or ad-hoc telemetry simulations (no persisted id) are skipped silently. The :inline / :manual Oban testing modes run jobs in the test pid anyway, so this auto-allowance is a no-op for them — it only adds capability for the production-like worker case from issue #1052. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds Broadway to the :allowance dispatch. The handler subscribes to
[:broadway, :processor, :start] and [:broadway, :batch_processor, :start],
reads the first :sentry_test_owner found in metadata.messages[*].metadata,
and calls allow_sentry_reports/2 for that test pid.
This follows the same shape Broadway documents for Ecto sandbox
testing (metadata: %{ecto_sandbox: self()}) — no wrapper around
Broadway.test_message/3, no hidden state, and async-safe by design
because each message carries its origin test pid. Messages without
:sentry_test_owner are silently skipped.
Integration coverage adds a minimal Broadway pipeline
(PhoenixApp.TestBroadway) and a 3-test broadway_test.exs in
phoenix_app proving: (1) tagged + allowance captures, (2) untagged +
allowance does not, (3) tagged + no allowance does not. async: true
on the describe block to validate cross-test isolation through a
shared pipeline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ee71a75 to
ea7e14f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Streamlines test setup for popular
ObanandBroadwaylibs, so that we can have tests like this: