Class: ScoutApm::ErrorService::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/error_service/notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Notifier

Returns a new instance of Notifier.



7
8
9
10
# File 'lib/scout_apm/error_service/notifier.rb', line 7

def initialize(context)
  @context = context
  @reporter = ScoutApm::Reporter.new(context, :errors)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/scout_apm/error_service/notifier.rb', line 4

def context
  @context
end

#reporterObject (readonly)

Returns the value of attribute reporter.



5
6
7
# File 'lib/scout_apm/error_service/notifier.rb', line 5

def reporter
  @reporter
end

Instance Method Details

#shipObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/scout_apm/error_service/notifier.rb', line 12

def ship
  error_records = context.error_buffer.get_and_reset_error_records
  if error_records.any?
    payload = ScoutApm::ErrorService::Payload.new(context, error_records)
    reporter.report(
      payload.serialize,
      default_headers.merge("X-Error-Count" => error_records.length.to_s)
    )
  end
end