oneapm_rpm 1.3.6 → 1.3.7.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/one_apm/agent/agent/start_worker_thread.rb +8 -8
- data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +2 -2
- data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +2 -2
- data/lib/one_apm/agent/database.rb +17 -17
- data/lib/one_apm/agent/database/obfuscation_helpers.rb +13 -13
- data/lib/one_apm/agent/database/obfuscator.rb +5 -5
- data/lib/one_apm/agent/database/postgres_explain_obfuscator.rb +4 -4
- data/lib/one_apm/agent/datastore/metric_helper.rb +12 -12
- data/lib/one_apm/agent/datastore/mongo/command_formatter.rb +6 -6
- data/lib/one_apm/agent/datastore/mongo/metric_translator.rb +6 -6
- data/lib/one_apm/agent/datastore/mongo/obfuscator.rb +2 -2
- data/lib/one_apm/agent/datastore/mongo/statement_formatter.rb +4 -4
- data/lib/one_apm/agent/javascript_instrumentor.rb +22 -22
- data/lib/one_apm/agent/synthetics_monitor.rb +7 -7
- data/lib/one_apm/agent/threading/thread_profile.rb +2 -2
- data/lib/one_apm/collector/collector/http_connection.rb +4 -4
- data/lib/one_apm/collector/collector_service.rb +1 -1
- data/lib/one_apm/collector/commands/thread_profiler_session.rb +4 -4
- data/lib/one_apm/collector/containers/agent_command_router.rb +4 -4
- data/lib/one_apm/collector/containers/custom_event_aggregator.rb +10 -10
- data/lib/one_apm/collector/containers/error_collector.rb +4 -4
- data/lib/one_apm/collector/containers/sql_sampler.rb +2 -2
- data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +36 -36
- data/lib/one_apm/collector/containers/transaction_sampler.rb +4 -4
- data/lib/one_apm/collector/containers/utilization_data.rb +1 -1
- data/lib/one_apm/collector/samplers/delayed_job_sampler.rb +7 -7
- data/lib/one_apm/collector/samplers/vm_sampler.rb +18 -18
- data/lib/one_apm/collector/stats_engine/gc_profiler.rb +6 -6
- data/lib/one_apm/collector/stats_engine/metric_stats.rb +1 -1
- data/lib/one_apm/collector/support/proc_poller.rb +2 -2
- data/lib/one_apm/configuration.rb +2 -2
- data/lib/one_apm/configuration/default_source.rb +2 -2
- data/lib/one_apm/configuration/environment_source.rb +5 -5
- data/lib/one_apm/configuration/high_security_source.rb +7 -7
- data/lib/one_apm/errors/noticed_error.rb +2 -2
- data/lib/one_apm/inst/dispatcher/puma.rb +7 -4
- data/lib/one_apm/inst/framework/grape.rb +9 -9
- data/lib/one_apm/inst/framework/sinatra/transaction_namer.rb +2 -2
- data/lib/one_apm/inst/http_clients/curb.rb +2 -2
- data/lib/one_apm/inst/http_clients/excon.rb +7 -7
- data/lib/one_apm/inst/http_clients/httpclient.rb +2 -2
- data/lib/one_apm/inst/http_clients/typhoeus.rb +2 -2
- data/lib/one_apm/inst/nosql/memcache.rb +5 -5
- data/lib/one_apm/inst/nosql/mongo2.rb +8 -8
- data/lib/one_apm/inst/orm/active_record.rb +2 -2
- data/lib/one_apm/inst/rails3/action_controller.rb +1 -1
- data/lib/one_apm/inst/rails4/action_view_subscriber.rb +2 -2
- data/lib/one_apm/inst/rails4/active_record_subscriber.rb +3 -3
- data/lib/one_apm/inst/support/queue_time.rb +14 -14
- data/lib/one_apm/logger/agent_logger.rb +4 -4
- data/lib/one_apm/metrics/metric_spec.rb +10 -10
- data/lib/one_apm/rack/browser_monitoring.rb +135 -144
- data/lib/one_apm/rack/developer_mode.rb +22 -33
- data/lib/one_apm/rack/developer_mode/helper.rb +1 -1
- data/lib/one_apm/rack/middleware_base.rb +2 -0
- data/lib/one_apm/rack/middleware_helper.rb +21 -0
- data/lib/one_apm/rack/middleware_hooks.rb +10 -8
- data/lib/one_apm/rack/middleware_tracing.rb +47 -44
- data/lib/one_apm/rack/middleware_wrapper.rb +63 -57
- data/lib/one_apm/support/backtrace/backtrace_node.rb +4 -4
- data/lib/one_apm/support/backtrace/backtrace_service.rb +7 -7
- data/lib/one_apm/support/collection_helper.rb +4 -4
- data/lib/one_apm/support/event_buffer/synthetics_event_buffer.rb +2 -2
- data/lib/one_apm/support/json_marshaller.rb +2 -2
- data/lib/one_apm/support/method_tracer.rb +2 -2
- data/lib/one_apm/support/method_tracer/helpers.rb +2 -2
- data/lib/one_apm/support/obfuscator.rb +5 -5
- data/lib/one_apm/support/rules_engine.rb +2 -2
- data/lib/one_apm/support/rules_engine/replacement_rule.rb +4 -4
- data/lib/one_apm/support/rules_engine/segment_terms_rule.rb +8 -8
- data/lib/one_apm/support/supported_versions.rb +9 -13
- data/lib/one_apm/support/vm/rubinius_vm.rb +1 -1
- data/lib/one_apm/transaction.rb +8 -8
- data/lib/one_apm/transaction/class_methods.rb +8 -8
- data/lib/one_apm/transaction/instance_helpers.rb +1 -1
- data/lib/one_apm/transaction/metric_constants.rb +27 -27
- data/lib/one_apm/transaction/sample_buffer/developer_mode_sample_buffer.rb +3 -3
- data/lib/one_apm/transaction/sample_buffer/force_persist_sample_buffer.rb +2 -2
- data/lib/one_apm/transaction/sample_buffer/slowest_sample_buffer.rb +2 -2
- data/lib/one_apm/transaction/sample_buffer/transaction_sample_buffer.rb +3 -3
- data/lib/one_apm/transaction/segment.rb +2 -2
- data/lib/one_apm/transaction/transaction_finish_append.rb +3 -3
- data/lib/one_apm/transaction/transaction_jruby_functions.rb +3 -3
- data/lib/one_apm/transaction/transaction_name.rb +3 -3
- data/lib/one_apm/transaction/transaction_namer.rb +7 -7
- data/lib/one_apm/transaction/transaction_sample_builder.rb +3 -3
- data/lib/one_apm/transaction/transaction_summary.rb +4 -4
- data/lib/one_apm/transaction/transaction_timings.rb +1 -1
- data/lib/one_apm/version.rb +3 -2
- metadata +3 -2
@@ -19,7 +19,7 @@ module OneApm
|
|
19
19
|
module Rack
|
20
20
|
class DeveloperMode < MiddlewareBase
|
21
21
|
|
22
|
-
|
22
|
+
OA_VIEW_PATH = File.expand_path('../developer_mode/views/', __FILE__)
|
23
23
|
|
24
24
|
include OneApm::DeveloperModeHelper
|
25
25
|
|
@@ -33,7 +33,7 @@ module OneApm
|
|
33
33
|
result = inject_profiler(env, status, headers, body)
|
34
34
|
return result if result
|
35
35
|
end
|
36
|
-
return [status,headers,body]
|
36
|
+
return [status, headers, body]
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.profiled?
|
@@ -52,7 +52,7 @@ module OneApm
|
|
52
52
|
@rendered = false
|
53
53
|
case @req.path_info
|
54
54
|
when /assets/
|
55
|
-
::Rack::File.new(
|
55
|
+
::Rack::File.new(OA_VIEW_PATH).call(env)
|
56
56
|
when /index/
|
57
57
|
index
|
58
58
|
when /threads/
|
@@ -93,33 +93,26 @@ module OneApm
|
|
93
93
|
def inject_profiler(env, status, headers, body)
|
94
94
|
# mini profiler is meddling with stuff, we can not cache cause we will get incorrect data
|
95
95
|
# Rack::ETag has already inserted some nonesense in the chain
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
body.each { |fragment| response.write fragment }
|
104
|
-
end
|
105
|
-
body.close if body.respond_to? :close
|
106
|
-
response.finish
|
107
|
-
else
|
108
|
-
nil
|
109
|
-
end
|
96
|
+
source = gather_source(body)
|
97
|
+
close_old_response(body)
|
98
|
+
return nil unless source
|
99
|
+
response_string = get_and_inject_profile(source)
|
100
|
+
return nil unless response_string
|
101
|
+
response = ::Rack::Response.new(response_string, status, headers)
|
102
|
+
response.finish
|
110
103
|
end
|
111
104
|
|
112
|
-
def get_and_inject_profile
|
113
|
-
inject_page!(
|
114
|
-
inject_page!(
|
115
|
-
inject_page!(
|
116
|
-
|
105
|
+
def get_and_inject_profile source
|
106
|
+
inject_page!(source, stylesheets, :postion => :head)
|
107
|
+
inject_page!(source, javascripts(source))
|
108
|
+
inject_page!(source, slide_templates)
|
109
|
+
source
|
117
110
|
end
|
118
111
|
|
119
112
|
def javascripts body
|
120
113
|
script = ""
|
121
114
|
script_files = ["javascript/jquery.min.js", "javascript/layer.js", "javascript/functions.js" ]
|
122
|
-
script_files.shift if body
|
115
|
+
script_files.shift if body =~ /jquery(.min)?/ rescue false
|
123
116
|
script_files.each do |sf|
|
124
117
|
script << "<script src=\"/oneapm/assets/#{sf}\"></script>\r\n"
|
125
118
|
end
|
@@ -134,7 +127,7 @@ module OneApm
|
|
134
127
|
end
|
135
128
|
|
136
129
|
def slide_templates
|
137
|
-
template = read_script_file "#{
|
130
|
+
template = read_script_file "#{OA_VIEW_PATH}/oneapm/slide.tmpl"
|
138
131
|
samples = ""
|
139
132
|
|
140
133
|
duration = current_duration
|
@@ -163,11 +156,7 @@ module OneApm
|
|
163
156
|
end
|
164
157
|
|
165
158
|
def inject_page! body, script, options = {:postion => :body}
|
166
|
-
|
167
|
-
inject!(body, script, options)
|
168
|
-
else
|
169
|
-
body.each { |fragment| inject!(fragment, script, options) }
|
170
|
-
end
|
159
|
+
inject!(body, script, options)
|
171
160
|
end
|
172
161
|
|
173
162
|
def read_script_file file_path
|
@@ -229,10 +218,10 @@ module OneApm
|
|
229
218
|
if explanations
|
230
219
|
@explanation = explanations
|
231
220
|
if !@explanation.blank?
|
232
|
-
if @explanation.first.length < OneApm::
|
221
|
+
if @explanation.first.length < OneApm::OA_MYSQL_EXPLAIN_COLUMNS.length
|
233
222
|
@row_headers = nil
|
234
223
|
else
|
235
|
-
@row_headers = OneApm::
|
224
|
+
@row_headers = OneApm::OA_MYSQL_EXPLAIN_COLUMNS
|
236
225
|
end
|
237
226
|
end
|
238
227
|
end
|
@@ -282,14 +271,14 @@ module OneApm
|
|
282
271
|
# You have to call this with a block - the contents returned from
|
283
272
|
# that block are interpolated into the layout
|
284
273
|
def render_with_layout(view)
|
285
|
-
body = ERB.new(File.read(File.join(
|
274
|
+
body = ERB.new(File.read(File.join(OA_VIEW_PATH, 'oneapm/layout.html.erb')))
|
286
275
|
body.result(Proc.new {}.binding)
|
287
276
|
end
|
288
277
|
|
289
278
|
# you have to pass a binding to this (a proc) so that ERB can have
|
290
279
|
# access to helper functions and local variables
|
291
280
|
def render_without_layout(view, binding)
|
292
|
-
ERB.new(File.read(File.join(
|
281
|
+
ERB.new(File.read(File.join(OA_VIEW_PATH, 'oneapm', view.to_s + '.html.erb')), nil, nil, 'frobnitz').result(binding)
|
293
282
|
end
|
294
283
|
|
295
284
|
def content_tag(tag, contents, opts={})
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'one_apm/rack/middleware_tracing'
|
4
|
+
require 'one_apm/rack/middleware_helper'
|
4
5
|
|
5
6
|
module OneApm
|
6
7
|
module Rack
|
7
8
|
class MiddlewareBase
|
8
9
|
include MiddlewareTracing
|
10
|
+
include OneApm::Rack::MiddlewareHelper
|
9
11
|
|
10
12
|
attr_reader :transaction_options, :category, :target
|
11
13
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module OneApm
|
3
|
+
module Rack
|
4
|
+
module MiddlewareHelper
|
5
|
+
|
6
|
+
def gather_source(response)
|
7
|
+
source = nil
|
8
|
+
response.each {|fragment| source ? (source << fragment.to_s) : (source = fragment.to_s)}
|
9
|
+
source
|
10
|
+
end
|
11
|
+
|
12
|
+
def close_old_response(response)
|
13
|
+
response.close if response.respond_to?(:close)
|
14
|
+
end
|
15
|
+
|
16
|
+
def middleware_ignore?
|
17
|
+
OneApm::Manager.config[:disable_rails_middleware]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -2,16 +2,18 @@
|
|
2
2
|
|
3
3
|
require 'one_apm/rack/middleware_base'
|
4
4
|
|
5
|
-
module OneApm
|
6
|
-
|
5
|
+
module OneApm
|
6
|
+
module Rack
|
7
|
+
class MiddlewareHooks < MiddlewareBase
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def self.needed?
|
10
|
+
!OneApm::Manager.config[:disable_rack_middleware]
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def traced_call(env)
|
14
|
+
@app.call(env)
|
15
|
+
end
|
15
16
|
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -20,64 +20,67 @@ require 'one_apm/inst/transaction_base'
|
|
20
20
|
# The target may be self, in which case the host class should define a
|
21
21
|
# #traced_call method, instead of the usual #call.
|
22
22
|
|
23
|
-
module OneApm
|
24
|
-
module
|
25
|
-
|
23
|
+
module OneApm
|
24
|
+
module Rack
|
25
|
+
module MiddlewareTracing
|
26
|
+
OA_TXN_STARTED_KEY = 'oneapm.transaction_started'.freeze unless defined?(TXN_STARTED_KEY)
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def _oa_has_middleware_tracing
|
29
|
+
true
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def build_transaction_options(env, first_middleware)
|
33
|
+
opts = transaction_options
|
34
|
+
opts = merge_first_middleware_options(opts, env) if first_middleware
|
35
|
+
opts
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
def merge_first_middleware_options(opts, env)
|
39
|
+
opts.merge(
|
40
|
+
:request => ::Rack::Request.new(env),
|
41
|
+
:apdex_start_time => OneApm::Agent::Instrumentation::QueueTime.parse_frontend_timestamp(env)
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def note_transaction_started(env)
|
46
|
+
env[OA_TXN_STARTED_KEY] = true unless env[OA_TXN_STARTED_KEY]
|
47
|
+
end
|
43
48
|
|
44
|
-
def note_transaction_started(env)
|
45
|
-
env[TXN_STARTED_KEY] = true unless env[TXN_STARTED_KEY]
|
46
|
-
end
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
def capture_http_response_code(state, result)
|
51
|
+
if result.is_a?(Array) && state.current_transaction
|
52
|
+
state.current_transaction.http_response_code = result[0]
|
53
|
+
end
|
51
54
|
end
|
52
|
-
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
def call(env)
|
57
|
+
first_middleware = note_transaction_started(env)
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
state = OneApm::TransactionState.tl_get
|
60
|
+
begin
|
61
|
+
options = build_transaction_options(env, first_middleware)
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
+
current_transaction = OneApm::Transaction.start(state, category, options)
|
64
|
+
current_transaction.ignore_frames << options[:transaction_name] if respond_to?(:middleware_ignore?) && middleware_ignore?
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
+
events.notify(:before_call, env) if first_middleware
|
67
|
+
result = (target == self) ? traced_call(env) : target.call(env)
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
+
capture_http_response_code(state, result)
|
70
|
+
events.notify(:after_call, env, result) if first_middleware
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
result
|
73
|
+
rescue Exception => e
|
74
|
+
OneApm::Manager.notice_error(e)
|
75
|
+
raise e
|
76
|
+
ensure
|
77
|
+
OneApm::Transaction.stop(state)
|
78
|
+
end
|
76
79
|
end
|
77
|
-
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
def events
|
82
|
+
OneApm::Manager.agent.events
|
83
|
+
end
|
81
84
|
end
|
82
85
|
end
|
83
86
|
end
|
@@ -7,79 +7,85 @@ require 'one_apm/inst/support/queue_time'
|
|
7
7
|
require 'one_apm/inst/transaction_base'
|
8
8
|
require 'one_apm/rack/middleware_tracing'
|
9
9
|
|
10
|
-
module OneApm
|
11
|
-
|
12
|
-
|
10
|
+
module OneApm
|
11
|
+
module Rack
|
12
|
+
class MiddlewareWrapper
|
13
|
+
include MiddlewareTracing
|
13
14
|
|
14
|
-
|
15
|
+
class MiddlewareClassWrapper
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def initialize(middleware_class)
|
18
|
+
@middleware_class = middleware_class
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def new(*args, &blk)
|
22
|
+
middleware_instance = @middleware_class.new(*args, &blk)
|
23
|
+
MiddlewareWrapper.wrap(middleware_instance)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
+
class << self
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def is_sinatra_app?(target)
|
31
|
+
defined?(::Sinatra::Base) && target.kind_of?(::Sinatra::Base)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def wrap_class(target_class)
|
35
|
+
MiddlewareClassWrapper.new(target_class)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def needs_wrapping?(target)
|
39
|
+
!target.respond_to?(:_oa_has_middleware_tracing) &&
|
40
|
+
!is_sinatra_app?(target)
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
def wrap(target, is_app = false)
|
44
|
+
if needs_wrapping?(target)
|
45
|
+
self.new(target, is_app)
|
46
|
+
else
|
47
|
+
target
|
48
|
+
end
|
47
49
|
end
|
50
|
+
|
48
51
|
end
|
49
52
|
|
50
|
-
|
53
|
+
attr_reader :target, :category, :transaction_options
|
54
|
+
|
55
|
+
def initialize(target, is_app = false)
|
56
|
+
@target = target
|
57
|
+
@is_app = is_app
|
58
|
+
@category = determine_category
|
59
|
+
@target_class_name = determine_class_name
|
60
|
+
@transaction_name = "#{determine_prefix}#{@target_class_name}/call"
|
61
|
+
@transaction_options = {
|
62
|
+
:transaction_name => @transaction_name
|
63
|
+
}
|
64
|
+
end
|
51
65
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@target = target
|
56
|
-
@is_app = is_app
|
57
|
-
@category = determine_category
|
58
|
-
@target_class_name = determine_class_name
|
59
|
-
@transaction_name = "#{determine_prefix}#{@target_class_name}/call"
|
60
|
-
@transaction_options = {
|
61
|
-
:transaction_name => @transaction_name
|
62
|
-
}
|
63
|
-
end
|
66
|
+
def determine_category
|
67
|
+
@is_app ? :rack : :middleware
|
68
|
+
end
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
70
|
+
def determine_prefix
|
71
|
+
OneApm::TransactionNamer.prefix_for_category(nil, @category)
|
72
|
+
end
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
def middleware_ignore?
|
75
|
+
defined?(::Rails) && OneApm::Manager.config[:disable_rails_middleware] && @transaction_name =~ /Middleware/
|
76
|
+
end
|
72
77
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
# In 'normal' usage, the target will be an application instance that
|
79
|
+
# responds to #call. With Rails, however, the target may be a subclass
|
80
|
+
# of Rails::Application that defines a method_missing that proxies #call
|
81
|
+
# to a singleton instance of the the subclass. We need to ensure that we
|
82
|
+
# capture the correct name in both cases.
|
83
|
+
def determine_class_name
|
84
|
+
if @target.is_a?(Class)
|
85
|
+
@target.name
|
86
|
+
else
|
87
|
+
@target.class.name
|
88
|
+
end
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|