Class: Sapience::ErrorHandler::Sentry
- Inherits:
-
Sapience::ErrorHandler
- Object
- Sapience::ErrorHandler
- Sapience::ErrorHandler::Sentry
- Defined in:
- lib/sapience/error_handler/sentry.rb
Constant Summary collapse
- VALIDATION_MESSAGE =
"DSN is not valid, please add appender with :dsn key or set SENTRY_DSN"
- URI_REGEXP =
URI::DEFAULT_PARSER.regexp[:ABS_URI]
Instance Method Summary collapse
-
#capture(options = {}) ⇒ Object
Capture, process and not reraise any exceptions from the given block.
-
#capture!(options = {}) ⇒ Object
Capture, process and reraise any exceptions from the given block.
- #capture_exception(exception, payload = {}) ⇒ Object
- #capture_message(message, payload = {}) ⇒ Object
- #configure_sentry ⇒ Object
- #configured? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Sentry
constructor
level: [:trace | :debug | :info | :warn | :error | :fatal] Override the log level for this appender.
- #tags_context(options = {}) ⇒ Object (also: #tags=)
- #user_context(options = {}) ⇒ Object
- #valid? ⇒ Boolean
Methods included from Descendants
Constructor Details
#initialize(opts = {}) ⇒ Sentry
level: [:trace | :debug | :info | :warn | :error | :fatal]
Override the log level for this appender.
Default: Sapience.config.default_level
dsn: [String]
Url to configure Sentry-Raven.
Default: nil
26 27 28 29 30 31 32 33 34 |
# File 'lib/sapience/error_handler/sentry.rb', line 26 def initialize(opts = {}) fail ArgumentError, "Options should be a Hash" unless opts.is_a?(Hash) = opts.dup [:level] ||= :error @sentry_logger_level = [:level] @sentry_dsn = .delete(:dsn) @configured = false end |
Instance Method Details
#capture(options = {}) ⇒ Object
Capture, process and not reraise any exceptions from the given block.
94 95 96 97 98 99 100 101 102 |
# File 'lib/sapience/error_handler/sentry.rb', line 94 def capture( = {}) fail ArgumentError unless block_given? begin yield rescue StandardError => e capture_type(e, ) end end |
#capture!(options = {}) ⇒ Object
Capture, process and reraise any exceptions from the given block.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/sapience/error_handler/sentry.rb', line 77 def capture!( = {}) fail ArgumentError unless block_given? begin yield rescue StandardError => e capture_type(e, ) raise end end |
#capture_exception(exception, payload = {}) ⇒ Object
40 41 42 |
# File 'lib/sapience/error_handler/sentry.rb', line 40 def capture_exception(exception, payload = {}) capture_type(exception, payload) end |
#capture_message(message, payload = {}) ⇒ Object
44 45 46 |
# File 'lib/sapience/error_handler/sentry.rb', line 44 def (, payload = {}) capture_type(, payload) end |
#configure_sentry ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/sapience/error_handler/sentry.rb', line 61 def configure_sentry return if configured? Raven.configure do |config| config.server = sentry_dsn config. = { environment: Sapience.environment } config.logger = sentry_logger end @configured = true end |
#configured? ⇒ Boolean
57 58 59 |
# File 'lib/sapience/error_handler/sentry.rb', line 57 def configured? @configured == true end |
#tags_context(options = {}) ⇒ Object Also known as:
52 53 54 |
# File 'lib/sapience/error_handler/sentry.rb', line 52 def ( = {}) Raven.() end |
#user_context(options = {}) ⇒ Object
48 49 50 |
# File 'lib/sapience/error_handler/sentry.rb', line 48 def user_context( = {}) Raven.user_context() end |
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/sapience/error_handler/sentry.rb', line 36 def valid? sentry_dsn =~ URI_REGEXP end |