Class: Cybertrain::ErrorReporter::SentrySender
- Defined in:
- cybertrain/error_reporter/sentry.rb
Overview
Sends each event to the Sentry (or GlitchTip) project of Config#sentry_dsn. Installed by requiring this file.
Instance Method Summary collapse
-
#deliver_event(event) ⇒ Boolean
Sends one event, unless the sample rate leaves it out; true when Sentry accepted it (a 2xx answer).
-
#initialize ⇒ SentrySender
constructor
A new instance of SentrySender.
-
#sender_name ⇒ String
The line this sender comes from (Application#validate_boot asks).
-
#sends? ⇒ Boolean
Whether a DSN is set.
Constructor Details
#initialize ⇒ SentrySender
Returns a new instance of SentrySender.
44 45 46 47 48 49 50 |
# File 'cybertrain/error_reporter/sentry.rb', line 44 def initialize # The DSN last parsed, by its text: parsed again only when the # setting changes (a test points it at a receiver). Read and written # on the delivery thread only. @dsn_text = "" @dsn = SentryDsn.new("", "", "", "") end |
Instance Method Details
#deliver_event(event) ⇒ Boolean
Sends one event, unless the sample rate leaves it out; true when Sentry accepted it (a 2xx answer). Never raises: a failure is logged at warn and answers false.
72 73 74 75 76 77 78 79 80 |
# File 'cybertrain/error_reporter/sentry.rb', line 72 def deliver_event(event) text = Cybertrain.config.sentry_dsn.to_s return false if text.empty? rate = Cybertrain.config.error_sample_rate.to_f return false if rate < 1.0 && !SentrySender.sampled?(rate, SentrySender.sample_draw) post_event(text, event) end |
#sender_name ⇒ String
The line this sender comes from (Application#validate_boot asks).
62 63 64 |
# File 'cybertrain/error_reporter/sentry.rb', line 62 def sender_name "sentry" end |
#sends? ⇒ Boolean
Whether a DSN is set.
55 56 57 |
# File 'cybertrain/error_reporter/sentry.rb', line 55 def sends? !Cybertrain.config.sentry_dsn.to_s.empty? end |