Class: TingYun::Instrumentation::MiddlewareProxy
- Inherits:
-
Object
- Object
- TingYun::Instrumentation::MiddlewareProxy
show all
- Includes:
- MiddlewareTracing
- Defined in:
- lib/ting_yun/instrumentation/middleware_proxy.rb
Defined Under Namespace
Classes: RackApp
Constant Summary
TingYun::Instrumentation::MiddlewareTracing::CONTENT_TYPE, TingYun::Instrumentation::MiddlewareTracing::TXN_STARTED_KEY
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#_nr_has_middleware_tracing, #build_transaction_options, #call, #capture_http_response_code, #capture_response_content_type, #events, #merge_first_middleware_options, #note_transaction_started, #sinatra_static?
Constructor Details
#initialize(target, is_app = false) ⇒ MiddlewareProxy
Returns a new instance of MiddlewareProxy.
47
48
49
50
51
52
53
54
55
56
|
# 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}/call"
@transaction_options = {
:transaction_name => @transaction_name
}
end
|
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
45
46
47
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 45
def category
@category
end
|
#target ⇒ Object
Returns the value of attribute target.
45
46
47
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 45
def target
@target
end
|
#transaction_options ⇒ Object
Returns the value of attribute transaction_options.
45
46
47
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 45
def transaction_options
@transaction_options
end
|
Class Method Details
.for_class(target_class) ⇒ Object
41
42
43
|
# 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) ⇒ Boolean
22
23
24
|
# 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) ⇒ Boolean
26
27
28
29
|
# 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
|
.wrap(target, is_app = false) ⇒ Object
33
34
35
36
37
38
39
|
# 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
|
Instance Method Details
#class_for_target ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 79
def class_for_target
if @target.is_a?(Class)
@target
else
@target.class
end
end
|
#determine_category ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 59
def determine_category
if @is_app
:rack
else
:middleware
end
end
|
#determine_class_name ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/ting_yun/instrumentation/middleware_proxy.rb', line 71
def determine_class_name
clazz = class_for_target
name = clazz.name
name = clazz.superclass.name if name.nil? || name == ""
name
end
|
#determine_prefix ⇒ Object