module Oboe::Sinatra::Base

Public Class Methods

included(klass) click to toggle source
# File lib/oboe/frameworks/sinatra.rb, line 7
def self.included(klass)
  ::Oboe::Util.method_alias(klass, :dispatch!,         ::Sinatra::Base)
  ::Oboe::Util.method_alias(klass, :handle_exception!, ::Sinatra::Base)
end

Public Instance Methods

dispatch_with_oboe() click to toggle source
# File lib/oboe/frameworks/sinatra.rb, line 12
def dispatch_with_oboe
  if Oboe.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 Oboe::API.trace
    # block method) This removes the need for an info
    # event to send additonal KVs
    ::Oboe::API.log_entry('sinatra', {})

    begin
      dispatch_without_oboe
    ensure
      ::Oboe::API.log_exit('sinatra', report_kvs)
    end
  else
    dispatch_without_oboe
  end
end
handle_exception_with_oboe(boom) click to toggle source
# File lib/oboe/frameworks/sinatra.rb, line 35
def handle_exception_with_oboe(boom)
  Oboe::API.log_exception(nil, boom) if Oboe.tracing?
  handle_exception_without_oboe(boom)
end
oboe_rum_header() click to toggle source
# File lib/oboe/frameworks/sinatra.rb, line 44
def oboe_rum_header
  return unless Oboe::Config.rum_id
  if Oboe.tracing?
    if request.xhr?
      return ERB.new(@@rum_xhr_tmpl).result
    else
      return ERB.new(@@rum_hdr_tmpl).result
    end
  end
rescue StandardError => e
  Oboe.logger.warn "oboe_rum_header: #{e.message}."
  return ''
end