Migrate to ActiveSupport::Notifications - #16
Conversation
Using Rails.logger and Rails.errors directly is a tricky thing to manage. Would rather not try. Rails.errors is only from Rails >= 7, so if we don't depend on it we can support older Rails apps easily.
- Added Webhukhs::BaseHandler#to_s. - Replaced handler.class.name usage in receive event payloads with handler.to_s. - Updated initializer and README examples to check payload[:severity] == :error. - Removed the redundant payload.fetch(:severity, :error) in the Rails.error example. - Removed the reviewed error_context absence test.
|
This is a breaking change. So before merging this... maybe @julik has a take on this? :-) |
There was a problem hiding this comment.
Pull request overview
Refactors Webhukhs observability to emit a single ActiveSupport::Notifications event (webhukhs.event) with structured payloads, replacing direct logging/error-reporting from within the gem and updating docs/tests accordingly.
Changes:
- Introduces
Webhukhs.instrumentand replaces logging /Rails.error.reportcalls with structuredwebhukhs.eventinstrumentation. - Updates test suite helpers and assertions to validate emitted notification payloads instead of captured logs/error reports.
- Updates documentation/changelog and adjusts CI/lint configuration related to docs and mutation testing.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
lib/webhukhs.rb |
Adds Webhukhs.instrument and requires active_support/notifications. |
lib/webhukhs/controllers/receive_webhooks_controller.rb |
Emits webhukhs.event for receive-path errors instead of direct error reporting. |
lib/webhukhs/jobs/processing_job.rb |
Emits processing lifecycle/error/discard events instead of logging/reporting. |
lib/webhukhs/base_handler.rb |
Emits duplicate-delivery event; adjusts persisted handler name usage. |
lib/webhukhs/models/received_webhook.rb |
Clarifies ensure_id comment regarding UUID assignment. |
lib/webhukhs/templates/webhukhs.rb |
Adds notification subscriber example (currently active code in template). |
README.md |
Updates install/setup steps and documents notification-based observability. |
CHANGELOG.md |
Documents the notifications migration and removal of config.error_context. |
test/test_helper.rb |
Replaces log-capture helper with captured_webhukhs_events notification capture. |
test/webhukhs_test.rb |
Updates controller/processing assertions to validate notification payloads. |
test/processing_job_test.rb |
Replaces log/error-report assertions with notification assertions for job behavior. |
test/base_handler_test.rb |
Updates duplicate-delivery test to assert notification payload. |
.yard-lint.yml |
Disables Documentation/UndocumentedObjects and normalizes quoting. |
.github/workflows/mutant.yml |
Limits mutation tests workflow to pull_request events only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Documentation/UndocumentedObjects: | ||
| Description: 'Checks for classes, modules, and methods without documentation.' | ||
| Enabled: true | ||
| Description: "Checks for classes, modules, and methods without documentation." | ||
| Enabled: false |
There was a problem hiding this comment.
I'm mainly interested in yard tags for methods, so I can convert those into types. Object description is not that important.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
11d0446 to
183ca89
Compare
| arguments: job.arguments.map(&:inspect) | ||
| }, severity: :error) | ||
| discard_on ActiveJob::DeserializationError, InvalidWebhookArgument do |_job, error| | ||
| Webhukhs.instrument(operation: :process, outcome: :discarded, severity: :error, error: error) |
There was a problem hiding this comment.
I should probably include "job" related attributes?
fixes #15
Refactors Webhukhs observability to emit a single ActiveSupport::Notifications event, webhukhs.event, instead of logging/reporting errors directly from the gem.
Event Payload Schema
Features: