Module: TraceView::Sinatra::Base
- Defined in:
- lib/traceview/frameworks/sinatra.rb
Constant Summary collapse
- @@rum_xhr_tmpl =
File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_ajax_header.js.erb')
- @@rum_hdr_tmpl =
File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_header.js.erb')
- @@rum_ftr_tmpl =
File.read(File.dirname(__FILE__) + '/rails/helpers/rum/rum_footer.js.erb')
Class Method Summary collapse
Instance Method Summary collapse
- #dispatch_with_traceview ⇒ Object
- #handle_exception_with_traceview(boom) ⇒ Object
- #traceview_rum_footer ⇒ Object (also: #oboe_rum_footer)
- #traceview_rum_header ⇒ Object (also: #oboe_rum_header)
Class Method Details
.included(klass) ⇒ Object
7 8 9 10 |
# File 'lib/traceview/frameworks/sinatra.rb', line 7 def self.included(klass) ::TraceView::Util.method_alias(klass, :dispatch!, ::Sinatra::Base) ::TraceView::Util.method_alias(klass, :handle_exception!, ::Sinatra::Base) end |
Instance Method Details
#dispatch_with_traceview ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/traceview/frameworks/sinatra.rb', line 12 def dispatch_with_traceview if TraceView.tracing? report_kvs = {} report_kvs[:Controller] = self.class report_kvs[:Action] = env['PATH_INFO'] # Fall back to the raw tracing API so we can pass KVs # back on exit (a limitation of the TraceView::API.trace # block method) This removes the need for an info # event to send additonal KVs ::TraceView::API.log_entry('sinatra', {}) begin dispatch_without_traceview ensure ::TraceView::API.log_exit('sinatra', report_kvs) end else dispatch_without_traceview end end |
#handle_exception_with_traceview(boom) ⇒ Object
35 36 37 38 |
# File 'lib/traceview/frameworks/sinatra.rb', line 35 def handle_exception_with_traceview(boom) TraceView::API.log_exception(nil, boom) if TraceView.tracing? handle_exception_without_traceview(boom) end |
#traceview_rum_footer ⇒ Object Also known as:
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/traceview/frameworks/sinatra.rb', line 59 def return unless TraceView::Config.rum_id if TraceView.tracing? # Even though the footer template is named xxxx.erb, there are no ERB tags in it so we'll # skip that step for now return @@rum_ftr_tmpl end rescue StandardError => e TraceView.logger.warn "traceview_rum_footer: #{e.}." return '' end |
#traceview_rum_header ⇒ Object Also known as: oboe_rum_header
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/traceview/frameworks/sinatra.rb', line 44 def traceview_rum_header return unless TraceView::Config.rum_id if TraceView.tracing? if request.xhr? return ERB.new(@@rum_xhr_tmpl).result else return ERB.new(@@rum_hdr_tmpl).result end end rescue StandardError => e TraceView.logger.warn "traceview_rum_header: #{e.}." return '' end |