Skip to content

Commit c5a451e

Browse files
committed
Update CHANGELOG
1 parent 46172ec commit c5a451e

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,71 @@
66
- Support for Rails ActiveSupport log subscribers ([#2690](https://github.com/getsentry/sentry-ruby/pull/2690))
77
- Support for defining custom Rails log subscribers that work with Sentry Structured Logging ([#2689](https://github.com/getsentry/sentry-ruby/pull/2689))
88

9+
Rails applications can now define custom log subscribers that integrate with Sentry's structured logging system. The feature includes built-in subscribers for ActionController, ActiveRecord, ActiveJob, and ActionMailer events, with automatic parameter filtering that respects Rails' `config.filter_parameters` configuration.
10+
11+
To enable structured logging with Rails log subscribers:
12+
13+
```ruby
14+
Sentry.init do |config|
15+
# ... your setup ...
16+
17+
# Make sure structured logging is enabled
18+
config.enable_logs = true
19+
20+
# Enable default Rails log subscribers (ActionController and ActiveRecord)
21+
config.rails.structured_logging.enabled = true
22+
end
23+
```
24+
25+
To configure all subscribers:
26+
27+
```ruby
28+
Sentry.init do |config|
29+
# ... your setup ...
30+
31+
# Make sure structured logging is enabled
32+
config.enable_logs = true
33+
34+
# Enable Rails log subscribers
35+
config.rails.structured_logging.enabled = true
36+
37+
# Add ActionMailer and ActiveJob subscribers
38+
config.rails.structured_logging.subscribers.update(
39+
action_mailer: Sentry::Rails::LogSubscribers::ActionMailerSubscriber,
40+
active_job: Sentry::Rails::LogSubscribers::ActiveJobSubscriber
41+
)
42+
end
43+
```
44+
45+
You can also define custom log subscribers by extending the base class:
46+
47+
```ruby
48+
class MyCustomSubscriber < Sentry::Rails::LogSubscriber
49+
attach_to :my_component
50+
51+
def my_event(event)
52+
log_structured_event(
53+
message: "Custom event occurred",
54+
level: :info,
55+
attributes: { duration_ms: event.duration }
56+
)
57+
end
58+
end
59+
60+
Sentry.init do |config|
61+
# ... your setup ...
62+
63+
# Make sure structured logging is enabled
64+
config.enable_logs = true
65+
66+
# Enable Rails log subscribers
67+
config.rails.structured_logging.enabled = true
68+
69+
# Add custom subscriber
70+
config.rails.structured_logging.subscribers[:my_component] = MyCustomSubscriber
71+
end
72+
```
73+
974
### Internal
1075

1176
- Factor out do_request in HTTP transport ([#2662](https://github.com/getsentry/sentry-ruby/pull/2662))

0 commit comments

Comments
 (0)