Commit 8c55fee
Add support for ActiveSupport::EventReporter (#1481)
* Add Appsignal::Integrations::ActiveSupportEventReporter
Rails 8.1 adds ActiveSupport::EventReporter, an interface for
reporting structured events. To catch these, report them as info-level
logs in the rails_events category through the newly added
Appsignal::Integrations::ActiveSupportEventReporter.
* Update .changesets/report-events-from-rails-8-1-s-activesupport--eventreporter-as-logs.md
Co-authored-by: Tom de Bruijn <[email protected]>
* Update spec/lib/appsignal/hooks/active_support_event_reporter_spec.rb
Co-authored-by: Tom de Bruijn <[email protected]>
* Update spec/lib/appsignal/hooks/active_support_event_reporter_spec.rb
Co-authored-by: Tom de Bruijn <[email protected]>
* Add enable_active_support_event_reporter config
Add a configuration option to allow users to opt out of the
ActiveSupport::EventReporter integration. The option is enabled by
default and can be disabled via
APPSIGNAL_ENABLE_ACTIVE_SUPPORT_EVENT_REPORTER or
enable_active_support_event_reporter.
* Rename enable_active_support_event_reporter config option
Renames the configuration option from
`enable_active_support_event_reporter` to
`enable_active_support_event_log_reporter` to better reflect its
purpose of reporting events as logs.
Changes:
- Updated config default and BOOLEAN_OPTIONS mapping
- Updated environment variable name to
APPSIGNAL_ENABLE_ACTIVE_SUPPORT_EVENT_LOG_REPORTER
- Updated YARD documentation
- Updated all test fixtures and specs
* Format active_support_event_reporter and tests
* Fix ActiveSupport EventReporter hook for non-Rails apps
The ActiveSupportEventReporterHook was attempting to call
Rails.event.subscribe even in non-Rails environments where Rails
is not defined, causing a NameError that would be logged as an
error during hook installation. This caused test failures when
running the grape gemfile suite.
The fix adds a check for Rails being defined in the
dependencies_present? method, ensuring the hook only attempts to
install in Rails applications where Rails.event is available.
This prevents the hook from trying to install in applications that
use ActiveSupport (like Grape) but don't have Rails defined.
* Update type signatures for new config option
Add enable_active_support_event_log_reporter config option to both
RBI and RBS type signature files.
* Add enable_active_support_event_log_reporter to tests
Add enable_active_support_event_log_reporter configuration option
to the diagnose integration test expectations.
* Fix rubocop line length issues in diagnose spec
Break long regex patterns onto separate lines to fix Layout/LineLength
rubocop offenses.
* Fix ActiveSupport EventReporter hook test for non-Rails apps
Update the test to properly handle the case where ActiveSupport is
loaded without Rails. The test now correctly mocks the event reporter
and its subscribers array to verify the hook installation works in
non-Rails environments.
* Use DependencyHelper for test conditional consistency
Replace the ad-hoc `defined?(::Rails)` check with
`DependencyHelper.rails8_1_present?` to ensure the #install test
block only runs in appropriate Rails 8.1+ environments. This fixes
test failures in JRuby with the no_dependencies gemfile where Rails
may not be properly defined.
* Fix diagnose spec JSON error pattern for JRuby
Update the regex patterns in the diagnose spec to handle JRuby's JSON
parse error messages. JRuby returns "unexpected token at 'invalid..."
with the full invalid content in the quote, while MRI Ruby returns
"unexpected token at 'invalid'" with just the first token.
Changed the pattern from matching a closing quote after 'invalid' to
just matching the word 'invalid', making it compatible with both MRI
Ruby and JRuby error message formats.
---------
Co-authored-by: Tom de Bruijn <[email protected]>1 parent 4c69a0a commit 8c55fee
File tree
13 files changed
+181
-5
lines changed- .changesets
- lib/appsignal
- hooks
- integrations
- sig
- spec
- integration
- lib/appsignal
- cli
- hooks
- integrations
- support/helpers
13 files changed
+181
-5
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
| 188 | + | |
| 189 | + | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
| |||
802 | 805 | | |
803 | 806 | | |
804 | 807 | | |
| 808 | + | |
| 809 | + | |
805 | 810 | | |
806 | 811 | | |
807 | 812 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1209 | 1213 | | |
1210 | 1214 | | |
1211 | 1215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1126 | 1129 | | |
1127 | 1130 | | |
1128 | 1131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
494 | | - | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
495 | 498 | | |
496 | 499 | | |
497 | 500 | | |
498 | | - | |
499 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
500 | 506 | | |
501 | 507 | | |
502 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
| 723 | + | |
723 | 724 | | |
724 | 725 | | |
725 | 726 | | |
| |||
792 | 793 | | |
793 | 794 | | |
794 | 795 | | |
| 796 | + | |
795 | 797 | | |
796 | 798 | | |
797 | 799 | | |
| |||
926 | 928 | | |
927 | 929 | | |
928 | 930 | | |
| 931 | + | |
929 | 932 | | |
930 | 933 | | |
931 | 934 | | |
| |||
0 commit comments