class TingYun::Instrumentation::MiddlewareProxy

Attributes

category[R]
target[R]
transaction_options[R]

Public Class Methods

for_class(target_class) click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 41
def self.for_class(target_class)
  RackApp.new(target_class)
end
is_sinatra_app?(target) click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 22
def self.is_sinatra_app?(target)
  defined?(::Sinatra::Base) && target.kind_of?(::Sinatra::Base)
end
needs_wrapping?(target) click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 26
def self.needs_wrapping?(target)
  !target.respond_to?(:_nr_has_middleware_tracing) &&
  !is_sinatra_app?(target)
end
new(target, is_app=false) click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 47
def initialize(target, is_app=false)
  @target            = target
  @is_app            = is_app
  @category          = determine_category
  @target_class_name = determine_class_name
  @transaction_name  = "#{determine_prefix}#{@target_class_name}"
  @transaction_options  = {
      :transaction_name => @transaction_name,
      :method => "call"
  }
end
wrap(target, is_app=false) click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 33
def self.wrap(target, is_app=false)
  if needs_wrapping?(target)
    self.new(target, is_app)
  else
    target
  end
end

Public Instance Methods

class_for_target() click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 80
def class_for_target
  if @target.is_a?(Class)
    @target
  else
    @target.class
  end
end
determine_category() click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 60
def determine_category
  if @is_app
    :rack
  else
    :middleware
  end
end
determine_class_name() click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 72
def determine_class_name
  clazz = class_for_target

  name = clazz.name
  name = clazz.superclass.name if name.nil? || name == ""
  name
end
determine_prefix() click to toggle source
# File lib/ting_yun/instrumentation/middleware_proxy.rb, line 68
def determine_prefix
  TingYun::Instrumentation::Support::TransactionNamer.prefix_for_category(nil,@category)
end