Class: NatsWork::ErrorNotifiers::WebhookNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/natswork/error_tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(webhook_url, options = {}) ⇒ WebhookNotifier



306
307
308
309
310
# File 'lib/natswork/error_tracker.rb', line 306

def initialize(webhook_url, options = {})
  @webhook_url = webhook_url
  @http_timeout = options.fetch(:timeout, 5)
  @retry_count = options.fetch(:retries, 2)
end

Instance Method Details

#call(error_info) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/natswork/error_tracker.rb', line 312

def call(error_info)
  payload = {
    error: {
      type: error_info[:type],
      message: error_info[:message],
      fingerprint: error_info[:fingerprint],
      timestamp: error_info[:timestamp].iso8601,
      context: error_info[:context]
    }
  }

  send_webhook(payload)
end