Class: Sentry::Rails::LogSubscribers::ActionMailerSubscriber
- Inherits:
-
Sentry::Rails::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Sentry::Rails::LogSubscriber
- Sentry::Rails::LogSubscribers::ActionMailerSubscriber
- Defined in:
- lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb
Overview
LogSubscriber for ActionMailer events that captures email delivery and processing events using Sentry's structured logging system.
This subscriber captures deliver.action_mailer and process.action_mailer events and formats them with relevant email information while respecting PII settings.
Constant Summary
Constants inherited from Sentry::Rails::LogSubscriber
Sentry::Rails::LogSubscriber::ORIGIN
Instance Method Summary collapse
-
#deliver(event) ⇒ Object
Handle deliver.action_mailer events.
-
#process(event) ⇒ Object
Handle process.action_mailer events.
Methods inherited from Sentry::Rails::LogSubscriber
Instance Method Details
#deliver(event) ⇒ Object
Handle deliver.action_mailer events
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb', line 24 def deliver(event) return unless Sentry.initialized? payload = event.payload mailer = payload[:mailer] attributes = { mailer: mailer, duration_ms: duration_ms(event), perform_deliveries: payload[:perform_deliveries] } attributes[:delivery_method] = payload[:delivery_method] if payload[:delivery_method] attributes[:date] = payload[:date].to_s if payload[:date] if Sentry.configuration.data_collection.user_info && payload[:message_id] attributes[:message_id] = payload[:message_id] end = "Email delivered via #{mailer}" # Log the structured event log_structured_event( message: , level: :info, attributes: attributes ) end |
#process(event) ⇒ Object
Handle process.action_mailer events
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb', line 57 def process(event) return unless Sentry.initialized? payload = event.payload mailer = payload[:mailer] action = payload[:action] duration = duration_ms(event) attributes = { mailer: mailer, action: action, duration_ms: duration } if payload[:params].is_a?(Hash) params = Sentry.configuration.data_collection.url_query_params.filter(payload[:params]) attributes[:params] = params unless params.empty? end = "#{mailer}##{action}" log_structured_event( message: , level: :info, attributes: attributes ) end |