Class: TraceView::Reporter
- Inherits:
-
Object
- Object
- TraceView::Reporter
- Defined in:
- lib/oboe_metal.rb
Class Method Summary collapse
-
.clear_all_traces ⇒ Object
clear_all_traces.
-
.get_all_traces ⇒ Object
get_all_traces.
-
.sendReport(evt) ⇒ Object
sendReport.
-
.start ⇒ Object
(also: restart)
start.
Class Method Details
.clear_all_traces ⇒ Object
clear_all_traces
Truncates the trace output file to zero
59 60 61 |
# File 'lib/oboe_metal.rb', line 59 def clear_all_traces File.truncate(TRACE_FILE, 0) end |
.get_all_traces ⇒ Object
get_all_traces
Retrieves all traces written to the trace file
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/oboe_metal.rb', line 68 def get_all_traces io = File.open(TRACE_FILE, 'r') contents = io.readlines(nil) return contents if contents.empty? traces = [] # # We use Gem.loaded_spec because older versions of the bson # gem didn't even have a version embedded in the gem. If the # gem isn't in the bundle, it should rightfully error out # anyways. # if Gem.loaded_specs['bson'].version.to_s < '4.0' s = StringIO.new(contents[0]) until s.eof? traces << if ::BSON.respond_to? :read_bson_document BSON.read_bson_document(s) else BSON::Document.from_bson(s) end end else bbb = BSON::ByteBuffer.new(contents[0]) until bbb.length == 0 traces << Hash.from_bson(bbb) end end traces end |
.sendReport(evt) ⇒ Object
sendReport
Send the report for the given event
50 51 52 |
# File 'lib/oboe_metal.rb', line 50 def sendReport(evt) TraceView.reporter.sendReport(evt) end |
.start ⇒ Object Also known as: restart
start
Start the TraceView Reporter
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oboe_metal.rb', line 20 def start return unless TraceView.loaded begin Oboe_metal::Context.init if ENV.key?('TRACEVIEW_GEM_TEST') TraceView.reporter = TraceView::FileReporter.new(TRACE_FILE) else TraceView.reporter = TraceView::UdpReporter.new(TraceView::Config[:reporter_host], TraceView::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) TraceView::API.report_init end rescue => e $stderr.puts e. raise end end |