Accept keyword options in Sentry.add_logger_handler/1#4146
Accept keyword options in Sentry.add_logger_handler/1#4146
Conversation
Let callers pass handler config overrides (e.g. :discard_threshold, :sync_threshold) through to Sentry.LoggerHandler without having to update the handler config out-of-band via :logger after the fact. The :id option is still accepted to override the handler id; any other option is merged into the handler's config map over the existing defaults. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR refactors What's Working Well
Issues FoundNo critical or important issues remain. Suggestions (Nice to Have)
File: The describe block is named Issue ConformanceNo linked issue; previous review noted this. The PR description remains clear and the tests provide sufficient acceptance criteria. No new concern here. Previous Review StatusAll issues from iteration 1 were addressed:
Review iteration: 2 | 2026-04-21 |
Revise the API so add_logger_handler/1's original atom-id contract is preserved: id is the first optional positional arg, and a keyword list of handler-config overrides is the second optional arg. Callers passing a bare atom keep working unchanged. Also address review feedback: - Add a @type handler_opts so the opts shape is documented in the spec - Expose default_handler_id/0 so external callers don't have to hard-code :electric_sentry_handler - Rewrite the test's async: false comment to explain the VM-global :logger state (not just handler-id isolation) - Reference default_handler_id/0 from the default-id test instead of duplicating the atom Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4146 +/- ##
=======================================
Coverage 89.20% 89.20%
=======================================
Files 25 25
Lines 2520 2520
Branches 636 641 +5
=======================================
Hits 2248 2248
Misses 270 270
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Electric.Telemetry.Sentry.add_logger_handler/1now accepts a keyword list of options instead of just an id:idis merged into theSentry.LoggerHandlerconfig map, so downstream apps can tune handler settings like:discard_thresholdand:sync_thresholdat install time instead of calling:logger.update_handler_config/3after the facttest/electric/telemetry/sentry_test.exscovering the default config, merged overrides, and override-wins semanticsMotivates/enables stratovolt#1473 and is used to fix https://github.com/electric-sql/stratovolt/issues/1458, where
cloud-sync-serviceneeds to cap theSentry.LoggerHandlermailbox via:discard_thresholdto avoid blocking log calls or unbounded mailbox growth under error bursts. Once this lands, that PR can collapse into a single call:Test plan
MIX_TARGET=application mix test test/electric/telemetry/(15 tests, 0 failures)MIX_TARGET=application mix compile --warnings-as-errors🤖 Generated with Claude Code