Module: Oboe_metal::Reporter
- Defined in:
- lib/joboe_metal.rb
Class Method Summary collapse
-
.clear_all_traces ⇒ Object
clear_all_traces.
-
.get_all_traces ⇒ Object
get_all_traces.
- .sendReport(evt) ⇒ Object
-
.start ⇒ Object
Initialize the Oboe Context, reporter and report the initialization.
Class Method Details
.clear_all_traces ⇒ Object
clear_all_traces
Truncates the trace output file to zero
89 90 91 |
# File 'lib/joboe_metal.rb', line 89 def self.clear_all_traces Oboe.reporter.reset if Oboe.loaded end |
.get_all_traces ⇒ Object
get_all_traces
Retrieves all traces written to the trace file
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/joboe_metal.rb', line 98 def self.get_all_traces return [] unless Oboe.loaded # Joboe TestReporter returns a Java::ComTracelyticsExtEbson::DefaultDocument # document for traces which doesn't correctly support things like has_key? which # raises an unhandled exception on non-existent key (duh). Here we convert # the Java::ComTracelyticsExtEbson::DefaultDocument doc to a pure array of Ruby # hashes traces = [] Oboe.reporter.getSentEventsAsBsonDocument.to_a.each do |e| t = {} e.each_pair { |k, v| t[k] = v } traces << t end traces end |
.sendReport(evt) ⇒ Object
117 118 119 |
# File 'lib/joboe_metal.rb', line 117 def self.sendReport(evt) evt.report(Oboe.reporter) end |
.start ⇒ Object
Initialize the Oboe Context, reporter and report the initialization
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/joboe_metal.rb', line 50 def self.start return unless Oboe.loaded if ENV.key?('OBOE_GEM_TEST') Oboe.reporter = Java::ComTracelyticsJoboe::TestReporter.new else Oboe.reporter = Java::ComTracelyticsJoboe::ReporterFactory.getInstance.buildUdpReporter end # Import the tracing mode and sample rate settings # from the Java agent (user configured in # /usr/local/tracelytics/javaagent.json when under JRuby) cfg = LayerUtil.getLocalSampleRate(nil, nil) if cfg.hasSampleStartFlag Oboe::Config.tracing_mode = 'always' elsif cfg.hasSampleThroughFlag Oboe::Config.tracing_mode = 'through' else Oboe::Config.tracing_mode = 'never' end Oboe.sample_rate = cfg.sampleRate Oboe::Config.sample_rate = cfg.sampleRate Oboe::Config.sample_source = cfg.sampleRateSource.a # 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 end end |