module TraceView::Sinatra::Base

Public Class Methods

included(klass) click to toggle source
# 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

Public Instance Methods

dispatch_with_traceview() click to toggle source
# 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) click to toggle source
# 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
oboe_rum_header()
traceview_rum_header() click to toggle source
# 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.message}."
  return ''
end
Also aliased as: oboe_rum_header