Class: HeimdallApm::Reporting

Inherits:
Object
  • Object
show all
Defined in:
lib/heimdall_apm/reporting.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Reporting

Returns a new instance of Reporting.



3
4
5
# File 'lib/heimdall_apm/reporting.rb', line 3

def initialize(context)
  @context = context
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/heimdall_apm/reporting.rb', line 11

def call
  span = @context.vault.retrieve_and_delete_previous_span
  if span && !span.points_collection.empty?
    influx.write_points(span.points_collection.to_a)
  else
    HeimdallApm.logger.debug "Nothing to report"
  end
rescue => e
  HeimdallApm.logger.error "#{e.message} during reporting to InfluxDB"
end

#influxObject



7
8
9
# File 'lib/heimdall_apm/reporting.rb', line 7

def influx
  @client ||= InfluxDB::Client.new("#{Rails.env}_metrics", time_precision: 'ms', retry: 0)
end