class HeimdallApm::Reporting

Public Class Methods

new(context) click to toggle source
# File lib/heimdall_apm/reporting.rb, line 3
def initialize(context)
  @context = context
end

Public Instance Methods

call() click to toggle source
# File lib/heimdall_apm/reporting.rb, line 12
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
    @context.logger.debug "Nothing to report"
  end
rescue => e
  @context.logger.error "#{e.message} during reporting to InfluxDB"
end
influx() click to toggle source

TODO: make this configurable

# File lib/heimdall_apm/reporting.rb, line 8
def influx
  @client ||= InfluxDB::Client.new("#{Rails.env}_metrics", time_precision: 'ms', retry: 0)
end