class Oboe::Reporter

Public Class Methods

clear_all_traces() click to toggle source

clear_all_traces

Truncates the trace output file to zero

# File lib/oboe_metal.rb, line 48
def self.clear_all_traces
  File.truncate($trace_file, 0)
end
get_all_traces() click to toggle source

get_all_traces

Retrieves all traces written to the trace file

# File lib/oboe_metal.rb, line 57
def self.get_all_traces
  io = File.open($trace_file, 'r')
  contents = io.readlines(nil)

  return contents if contents.empty?

  s = StringIO.new(contents[0])

  traces = []

  until s.eof?
    if ::BSON.respond_to? :read_bson_document
      traces << BSON.read_bson_document(s)
    else
      traces << BSON::Document.from_bson(s)
    end
  end

  traces
end
sendReport(evt) click to toggle source
# File lib/oboe_metal.rb, line 39
def self.sendReport(evt)
  Oboe.reporter.sendReport(evt)
end
start() click to toggle source

Initialize the Oboe Context, reporter and report the initialization

# File lib/oboe_metal.rb, line 15
def self.start
  return unless Oboe.loaded

  begin
    Oboe_metal::Context.init

    if ENV.key?('OBOE_GEM_TEST')
      Oboe.reporter = Oboe::FileReporter.new('/tmp/trace_output.bson')
    else
      Oboe.reporter = Oboe::UdpReporter.new(Oboe::Config[:reporter_host], Oboe::Config[:reporter_port])
    end

    # Only report __Init from here if we are not instrumenting a framework.
    # Otherwise, frameworks will handle reporting __Init after full initialization
    unless defined?(::Rails) || defined?(::Sinatra) || defined?(::Padrino) || defined?(::Grape)
      Oboe::API.report_init unless ENV.key?('OBOE_GEM_TEST')
    end

  rescue => e
    $stderr.puts e.message
    raise
  end
end