newrelic_rpm 3.9.0.229 → 3.9.1.236
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +4 -1
- data/CHANGELOG +73 -0
- data/install.rb +2 -2
- data/lib/new_relic/agent/agent.rb +8 -1
- data/lib/new_relic/agent/browser_token.rb +10 -7
- data/lib/new_relic/agent/configuration/default_source.rb +8 -1
- data/lib/new_relic/agent/configuration/high_security_source.rb +56 -0
- data/lib/new_relic/agent/configuration/manager.rb +35 -28
- data/lib/new_relic/agent/cross_app_monitor.rb +23 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +34 -26
- data/lib/new_relic/agent/database.rb +7 -6
- data/lib/new_relic/agent/instrumentation/active_record.rb +18 -18
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +18 -15
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +7 -4
- data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +9 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +6 -4
- data/lib/new_relic/agent/javascript_instrumentor.rb +9 -1
- data/lib/new_relic/agent/new_relic_service.rb +7 -0
- data/lib/new_relic/agent/obfuscator.rb +3 -2
- data/lib/new_relic/agent/request_sampler.rb +17 -1
- data/lib/new_relic/agent/sql_sampler.rb +10 -6
- data/lib/new_relic/agent/traced_method_stack.rb +0 -12
- data/lib/new_relic/agent/transaction.rb +98 -10
- data/lib/new_relic/agent/transaction_sampler.rb +10 -3
- data/lib/new_relic/agent/transaction_state.rb +2 -12
- data/lib/new_relic/control/frameworks/sinatra.rb +0 -3
- data/lib/new_relic/control/instance_methods.rb +5 -0
- data/lib/new_relic/json_wrapper.rb +7 -1
- data/lib/new_relic/rack/browser_monitoring.rb +25 -4
- data/lib/new_relic/version.rb +1 -1
- data/newrelic_rpm.gemspec +0 -1
- data/test/agent_helper.rb +76 -0
- data/test/fixtures/cross_agent_tests/cat_map.json +299 -0
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +16 -0
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +30 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +17 -17
- data/test/multiverse/suites/agent_only/testing_app.rb +10 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/high_security/Envfile +3 -0
- data/test/multiverse/suites/high_security/config/newrelic.yml +27 -0
- data/test/multiverse/suites/high_security/high_security_test.rb +64 -0
- data/test/multiverse/suites/rails/action_controller_live_rum_test.rb +39 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +3 -1
- data/test/multiverse/suites/rails/parameter_capture_test.rb +0 -20
- data/test/new_relic/agent/agent/connect_test.rb +5 -10
- data/test/new_relic/agent/agent_test.rb +11 -0
- data/test/new_relic/agent/browser_token_test.rb +10 -6
- data/test/new_relic/agent/configuration/default_source_test.rb +6 -0
- data/test/new_relic/agent/configuration/high_security_source_test.rb +83 -0
- data/test/new_relic/agent/configuration/manager_test.rb +7 -2
- data/test/new_relic/agent/cross_app_monitor_test.rb +17 -1
- data/test/new_relic/agent/cross_app_tracing_test.rb +11 -10
- data/test/new_relic/agent/hostname_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +22 -0
- data/test/new_relic/agent/instrumentation/middleware_tracing_test.rb +37 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -2
- data/test/new_relic/agent/javascript_instrumentor_test.rb +42 -0
- data/test/new_relic/agent/memcache_instrumentation_test.rb +11 -5
- data/test/new_relic/agent/request_sampler_test.rb +9 -0
- data/test/new_relic/agent/sql_sampler_test.rb +46 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -0
- data/test/new_relic/agent/transaction_sampler_test.rb +64 -4
- data/test/new_relic/agent/transaction_state_test.rb +0 -75
- data/test/new_relic/agent/transaction_test.rb +142 -0
- data/test/new_relic/control/instance_methods_test.rb +24 -4
- data/test/new_relic/fake_collector.rb +6 -13
- data/test/new_relic/fake_external_server.rb +14 -1
- data/test/new_relic/http_client_test_cases.rb +69 -21
- data/test/new_relic/json_wrapper_test.rb +10 -5
- data/test/performance/suites/rack_middleware.rb +2 -1
- data/test/performance/suites/rum_autoinsertion.rb +17 -3
- data/test/script/path_hash.rb +49 -0
- data/test/test_helper.rb +0 -10
- metadata +12 -52
- metadata.gz.sig +0 -0
@@ -48,8 +48,8 @@ module NewRelic
|
|
48
48
|
Obfuscator.instance.set_sql_obfuscator(type, &block)
|
49
49
|
end
|
50
50
|
|
51
|
-
def record_sql_method
|
52
|
-
case Agent.config[
|
51
|
+
def record_sql_method(config_section=:transaction_tracer)
|
52
|
+
case Agent.config["#{config_section}.record_sql".to_sym].to_s
|
53
53
|
when 'off'
|
54
54
|
:off
|
55
55
|
when 'none'
|
@@ -65,12 +65,13 @@ module NewRelic
|
|
65
65
|
|
66
66
|
RECORD_FOR = [:raw, :obfuscated].freeze
|
67
67
|
|
68
|
-
def should_record_sql?
|
69
|
-
RECORD_FOR.include?(record_sql_method)
|
68
|
+
def should_record_sql?(config_section=:transaction_tracer)
|
69
|
+
RECORD_FOR.include?(record_sql_method(config_section))
|
70
70
|
end
|
71
71
|
|
72
|
-
def should_collect_explain_plans?
|
73
|
-
should_record_sql? &&
|
72
|
+
def should_collect_explain_plans?(config_section=:transaction_tracer)
|
73
|
+
should_record_sql?(config_section) &&
|
74
|
+
Agent.config["#{config_section}.explain_enabled".to_sym]
|
74
75
|
end
|
75
76
|
|
76
77
|
def get_connection(config, &connector)
|
@@ -16,6 +16,21 @@ module NewRelic
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.insert_instrumentation
|
20
|
+
::ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
21
|
+
include ::NewRelic::Agent::Instrumentation::ActiveRecord
|
22
|
+
end
|
23
|
+
|
24
|
+
::ActiveRecord::Base.class_eval do
|
25
|
+
class << self
|
26
|
+
add_method_tracer(:find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql',
|
27
|
+
:metric => false)
|
28
|
+
add_method_tracer(:transaction, 'ActiveRecord/#{self.name}/transaction',
|
29
|
+
:metric => false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
19
34
|
def self.included(instrumented_class)
|
20
35
|
instrumented_class.class_eval do
|
21
36
|
unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
|
@@ -89,26 +104,11 @@ DependencyDetection.defer do
|
|
89
104
|
|
90
105
|
executes do
|
91
106
|
if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
|
92
|
-
|
93
|
-
insert_instrumentation
|
107
|
+
ActiveSupport.on_load(:active_record) do
|
108
|
+
::NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
|
94
109
|
end
|
95
110
|
else
|
96
|
-
insert_instrumentation
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def insert_instrumentation
|
101
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
|
102
|
-
include ::NewRelic::Agent::Instrumentation::ActiveRecord
|
103
|
-
end
|
104
|
-
|
105
|
-
ActiveRecord::Base.class_eval do
|
106
|
-
class << self
|
107
|
-
add_method_tracer(:find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql',
|
108
|
-
:metric => false)
|
109
|
-
add_method_tracer(:transaction, 'ActiveRecord/#{self.name}/transaction',
|
110
|
-
:metric => false)
|
111
|
-
end
|
111
|
+
::NewRelic::Agent::Instrumentation::ActiveRecord.insert_instrumentation
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -108,7 +108,7 @@ DependencyDetection.defer do
|
|
108
108
|
def perform_with_newrelic(&blk)
|
109
109
|
return perform_without_newrelic if
|
110
110
|
self.requests.first &&
|
111
|
-
self.requests.first.respond_to?(
|
111
|
+
self.requests.first.respond_to?(:_nr_serial) &&
|
112
112
|
self.requests.first._nr_serial
|
113
113
|
|
114
114
|
trace_execution_scoped("External/Multiple/Curb::Multi/perform") do
|
@@ -122,24 +122,26 @@ DependencyDetection.defer do
|
|
122
122
|
|
123
123
|
# Instrument the specified +request+ (a Curl::Easy object) and set up cross-application
|
124
124
|
# tracing if it's enabled.
|
125
|
-
def hook_pending_request(
|
126
|
-
wrapped_request, wrapped_response = wrap_request(
|
127
|
-
|
125
|
+
def hook_pending_request(request) #THREAD_LOCAL_ACCESS
|
126
|
+
wrapped_request, wrapped_response = wrap_request(request)
|
127
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
128
|
+
t0 = Time.now
|
129
|
+
segment = NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
|
128
130
|
|
129
131
|
unless request._nr_instrumented
|
130
|
-
install_header_callback(
|
131
|
-
install_completion_callback(
|
132
|
+
install_header_callback(request, wrapped_response)
|
133
|
+
install_completion_callback(request, t0, segment, wrapped_request, wrapped_response)
|
132
134
|
request._nr_instrumented = true
|
133
135
|
end
|
134
136
|
rescue => err
|
135
|
-
NewRelic::Agent.logger.error(
|
137
|
+
NewRelic::Agent.logger.error("Untrapped exception", err)
|
136
138
|
end
|
137
139
|
|
138
140
|
|
139
141
|
# Create request and response adapter objects for the specified +request+
|
140
|
-
def wrap_request(
|
141
|
-
return NewRelic::Agent::HTTPClients::CurbRequest.new(
|
142
|
-
NewRelic::Agent::HTTPClients::CurbResponse.new(
|
142
|
+
def wrap_request(request)
|
143
|
+
return NewRelic::Agent::HTTPClients::CurbRequest.new(request),
|
144
|
+
NewRelic::Agent::HTTPClients::CurbResponse.new(request)
|
143
145
|
end
|
144
146
|
|
145
147
|
|
@@ -161,22 +163,23 @@ DependencyDetection.defer do
|
|
161
163
|
end
|
162
164
|
|
163
165
|
# Install a callback that will finish the trace.
|
164
|
-
def install_completion_callback(
|
166
|
+
def install_completion_callback(request, t0, segment, wrapped_request, wrapped_response) #THREAD_LOCAL_ACCESS
|
165
167
|
original_callback = request.on_complete
|
166
168
|
request._nr_original_on_complete = original_callback
|
167
169
|
request.on_complete do |finished_request|
|
168
170
|
begin
|
169
|
-
NewRelic::Agent::
|
171
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
172
|
+
NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
|
170
173
|
ensure
|
171
174
|
# Make sure the existing completion callback is run, and restore the
|
172
175
|
# on_complete callback to how it was before.
|
173
|
-
original_callback.call(
|
174
|
-
remove_instrumentation_callbacks(
|
176
|
+
original_callback.call(finished_request) if original_callback
|
177
|
+
remove_instrumentation_callbacks(request)
|
175
178
|
end
|
176
179
|
end
|
177
180
|
end
|
178
181
|
|
179
|
-
def remove_instrumentation_callbacks(
|
182
|
+
def remove_instrumentation_callbacks(request)
|
180
183
|
request.on_complete(&request._nr_original_on_complete)
|
181
184
|
request.on_header(&request._nr_original_on_header)
|
182
185
|
request._nr_instrumented = false
|
@@ -18,7 +18,7 @@ module ::Excon
|
|
18
18
|
orig_response = nil
|
19
19
|
resolved_params = newrelic_resolved_request_params(params)
|
20
20
|
wrapped_request = ::NewRelic::Agent::HTTPClients::ExconHTTPRequest.new(resolved_params)
|
21
|
-
::NewRelic::Agent::CrossAppTracing.
|
21
|
+
::NewRelic::Agent::CrossAppTracing.tl_trace_http_request(wrapped_request) do
|
22
22
|
orig_response = request_without_newrelic_trace(resolved_params, &block)
|
23
23
|
::NewRelic::Agent::HTTPClients::ExconHTTPResponse.new(orig_response)
|
24
24
|
end
|
@@ -11,7 +11,7 @@ module ::Excon
|
|
11
11
|
@stack = stack
|
12
12
|
end
|
13
13
|
|
14
|
-
def request_call(datum)
|
14
|
+
def request_call(datum) #THREAD_LOCAL_ACCESS
|
15
15
|
begin
|
16
16
|
# Only instrument this request if we haven't already done so, because
|
17
17
|
# we can get request_call multiple times for requests marked as
|
@@ -19,7 +19,9 @@ module ::Excon
|
|
19
19
|
# accompanying response_call/error_call.
|
20
20
|
if datum[:connection] && !datum[:connection].instance_variable_get(TRACE_DATA_IVAR)
|
21
21
|
wrapped_request = ::NewRelic::Agent::HTTPClients::ExconHTTPRequest.new(datum)
|
22
|
-
|
22
|
+
state = ::NewRelic::Agent::TransactionState.tl_get
|
23
|
+
t0 = Time.now
|
24
|
+
segment = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
|
23
25
|
datum[:connection].instance_variable_set(TRACE_DATA_IVAR, [t0, segment, wrapped_request])
|
24
26
|
end
|
25
27
|
rescue => e
|
@@ -38,7 +40,7 @@ module ::Excon
|
|
38
40
|
@stack.error_call(datum)
|
39
41
|
end
|
40
42
|
|
41
|
-
def finish_trace(datum)
|
43
|
+
def finish_trace(datum) #THREAD_LOCAL_ACCESS
|
42
44
|
trace_data = datum[:connection] && datum[:connection].instance_variable_get(TRACE_DATA_IVAR)
|
43
45
|
if trace_data
|
44
46
|
datum[:connection].instance_variable_set(TRACE_DATA_IVAR, nil)
|
@@ -46,7 +48,8 @@ module ::Excon
|
|
46
48
|
if datum[:response]
|
47
49
|
wrapped_response = ::NewRelic::Agent::HTTPClients::ExconHTTPResponse.new(datum[:response])
|
48
50
|
end
|
49
|
-
::NewRelic::Agent::
|
51
|
+
state = ::NewRelic::Agent::TransactionState.tl_get
|
52
|
+
::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
@@ -30,7 +30,7 @@ DependencyDetection.defer do
|
|
30
30
|
wrapped_request = NewRelic::Agent::HTTPClients::HTTPClientRequest.new(req)
|
31
31
|
|
32
32
|
response = nil
|
33
|
-
::NewRelic::Agent::CrossAppTracing.
|
33
|
+
::NewRelic::Agent::CrossAppTracing.tl_trace_http_request(wrapped_request) do
|
34
34
|
do_get_block_without_newrelic(req, proxy, conn, &block)
|
35
35
|
response = conn.pop
|
36
36
|
conn.push response
|
@@ -16,8 +16,10 @@ module NewRelic
|
|
16
16
|
module_function
|
17
17
|
def instrument_methods(the_class, method_names)
|
18
18
|
method_names.each do |method_name|
|
19
|
-
next unless the_class.method_defined? method_name.to_sym
|
19
|
+
next unless the_class.method_defined?(method_name.to_sym) || the_class.private_method_defined?(method_name.to_sym)
|
20
|
+
visibility = "private" unless the_class.method_defined?(method_name.to_sym)
|
20
21
|
the_class.class_eval <<-EOD
|
22
|
+
#{visibility}
|
21
23
|
def #{method_name}_with_newrelic_trace(*args, &block)
|
22
24
|
metrics = ["Memcache/#{method_name}",
|
23
25
|
(NewRelic::Agent::Transaction.recording_web_transaction? ? 'Memcache/allWeb' : 'Memcache/allOther')]
|
@@ -64,7 +66,12 @@ DependencyDetection.defer do
|
|
64
66
|
::NewRelic::Agent.logger.info 'Installing MemCache instrumentation'
|
65
67
|
end
|
66
68
|
if defined? ::Memcached
|
67
|
-
|
69
|
+
if ::Memcached::VERSION >= '1.8.0'
|
70
|
+
commands -= %w[get get_multi]
|
71
|
+
commands += %w[single_get multi_get single_cas multi_cas]
|
72
|
+
else
|
73
|
+
commands << 'cas'
|
74
|
+
end
|
68
75
|
NewRelic::Agent::Instrumentation::Memcache.instrument_methods(::Memcached,
|
69
76
|
commands)
|
70
77
|
::NewRelic::Agent.logger.info 'Installing Memcached instrumentation'
|
@@ -20,7 +20,7 @@ DependencyDetection.defer do
|
|
20
20
|
def request_with_newrelic_trace(request, *args, &block)
|
21
21
|
wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
|
22
22
|
|
23
|
-
NewRelic::Agent::CrossAppTracing.
|
23
|
+
NewRelic::Agent::CrossAppTracing.tl_trace_http_request( wrapped_request ) do
|
24
24
|
# RUBY-1244 Disable further tracing in request to avoid double
|
25
25
|
# counting if connection wasn't started (which calls request again).
|
26
26
|
NewRelic::Agent.disable_all_tracing do
|
@@ -60,13 +60,15 @@ module NewRelic::Agent::Instrumentation::TyphoeusTracing
|
|
60
60
|
request.respond_to?(:hydra) && request.hydra
|
61
61
|
end
|
62
62
|
|
63
|
-
def self.trace(request)
|
64
|
-
|
63
|
+
def self.trace(request)
|
64
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
65
|
+
if state.is_execution_traced? && !request_is_hydra_enabled?(request)
|
65
66
|
wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
|
66
|
-
t0
|
67
|
+
t0 = Time.now
|
68
|
+
segment = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
|
67
69
|
callback = Proc.new do
|
68
70
|
wrapped_response = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(request.response)
|
69
|
-
::NewRelic::Agent::CrossAppTracing.finish_trace(t0, segment, wrapped_request, wrapped_response)
|
71
|
+
::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
|
70
72
|
end
|
71
73
|
request.on_complete.unshift(callback)
|
72
74
|
end
|
@@ -143,11 +143,14 @@ module NewRelic
|
|
143
143
|
TRANSACTION_NAME_KEY => obfuscator.obfuscate(timings.transaction_name_or_unknown),
|
144
144
|
QUEUE_TIME_KEY => timings.queue_time_in_millis,
|
145
145
|
APPLICATION_TIME_KEY => timings.app_time_in_millis,
|
146
|
-
TT_GUID_KEY => state.request_guid_to_include,
|
147
146
|
AGENT_TOKEN_KEY => state.request_token,
|
148
147
|
AGENT_KEY => NewRelic::Agent.config[:js_agent_file]
|
149
148
|
}
|
150
149
|
|
150
|
+
if include_guid?(state, timings)
|
151
|
+
data[TT_GUID_KEY] = state.request_guid
|
152
|
+
end
|
153
|
+
|
151
154
|
add_ssl_for_http(data)
|
152
155
|
add_user_attributes(data, state.current_transaction)
|
153
156
|
|
@@ -169,6 +172,11 @@ module NewRelic
|
|
169
172
|
data[USER_ATTRIBUTES_KEY] = obfuscator.obfuscate(json)
|
170
173
|
end
|
171
174
|
|
175
|
+
def include_guid?(state, timings)
|
176
|
+
state.current_transaction &&
|
177
|
+
state.current_transaction.include_guid?(state, timings.app_time_in_seconds)
|
178
|
+
end
|
179
|
+
|
172
180
|
# Still support deprecated capture_attributes.page_view_events for
|
173
181
|
# clients that use it. Could potentially be removed if we don't have
|
174
182
|
# anymore users with it set according to zeitgeist.
|
@@ -491,6 +491,13 @@ module NewRelic
|
|
491
491
|
class PrubyMarshaller < Marshaller
|
492
492
|
def initialize
|
493
493
|
::NewRelic::Agent.logger.debug 'Using Pruby marshaller'
|
494
|
+
warn_for_pruby_deprecation
|
495
|
+
end
|
496
|
+
|
497
|
+
def warn_for_pruby_deprecation
|
498
|
+
if !NewRelic::LanguageSupport.stdlib_json_usable? && !defined?(::JSON)
|
499
|
+
NewRelic::Agent.logger.warn("Upcoming versions of the Ruby agent running on Ruby 1.8.7 will require the 'json' gem. To avoid interuption in reporting, please update your Gemfile. See http://docs.newrelic.com/docs/ruby/ruby-1.8.7-support for more information.")
|
500
|
+
end
|
494
501
|
end
|
495
502
|
|
496
503
|
def dump(ruby, opts={})
|
@@ -11,6 +11,7 @@ module NewRelic
|
|
11
11
|
attr_reader :key_bytes
|
12
12
|
|
13
13
|
EMPTY_KEY_BYTES = [0]
|
14
|
+
PACK_FORMAT = 'm'
|
14
15
|
|
15
16
|
# RUM uses a shortened key, so just trim it up front
|
16
17
|
def initialize(key, length=nil)
|
@@ -23,11 +24,11 @@ module NewRelic
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def obfuscate(text)
|
26
|
-
[ encode(text) ].pack(
|
27
|
+
[ encode(text) ].pack(PACK_FORMAT).gsub(/\n/, '')
|
27
28
|
end
|
28
29
|
|
29
30
|
def deobfuscate(text)
|
30
|
-
encode(text.unpack(
|
31
|
+
encode(text.unpack(PACK_FORMAT).first )
|
31
32
|
end
|
32
33
|
|
33
34
|
def encode(text)
|
@@ -22,6 +22,11 @@ class NewRelic::Agent::RequestSampler
|
|
22
22
|
DURATION_KEY = 'duration'
|
23
23
|
GUID_KEY = 'nr.guid'
|
24
24
|
REFERRING_TRANSACTION_GUID_KEY = 'nr.referringTransactionGuid'
|
25
|
+
CAT_TRIP_ID_KEY = 'nr.tripId'
|
26
|
+
CAT_PATH_HASH_KEY = 'nr.pathHash'
|
27
|
+
CAT_REFERRING_PATH_HASH_KEY = 'nr.referringPathHash'
|
28
|
+
CAT_ALTERNATE_PATH_HASHES_KEY = 'nr.alternatePathHashes'
|
29
|
+
APDEX_PERF_ZONE_KEY = 'nr.apdexPerfZone'
|
25
30
|
|
26
31
|
def initialize( event_listener )
|
27
32
|
super()
|
@@ -176,11 +181,22 @@ class NewRelic::Agent::RequestSampler
|
|
176
181
|
DURATION_KEY => float(payload[:duration]),
|
177
182
|
TYPE_KEY => SAMPLE_TYPE,
|
178
183
|
})
|
179
|
-
optionally_append(GUID_KEY,
|
184
|
+
optionally_append(GUID_KEY, :guid, sample, payload)
|
180
185
|
optionally_append(REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
|
186
|
+
optionally_append(CAT_TRIP_ID_KEY, :cat_trip_id, sample, payload)
|
187
|
+
optionally_append(CAT_PATH_HASH_KEY, :cat_path_hash, sample, payload)
|
188
|
+
optionally_append(CAT_REFERRING_PATH_HASH_KEY, :cat_referring_path_hash, sample, payload)
|
189
|
+
optionally_append(APDEX_PERF_ZONE_KEY, :apdex_perf_zone, sample, payload)
|
190
|
+
append_cat_alternate_path_hashes(sample, payload)
|
181
191
|
sample
|
182
192
|
end
|
183
193
|
|
194
|
+
def append_cat_alternate_path_hashes(sample, payload)
|
195
|
+
if payload.include?(:cat_alternate_path_hashes)
|
196
|
+
sample[CAT_ALTERNATE_PATH_HASHES_KEY] = payload[:cat_alternate_path_hashes].sort.join(',')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
184
200
|
def optionally_append(sample_key, payload_key, sample, payload)
|
185
201
|
if payload.include?(payload_key)
|
186
202
|
sample[sample_key] = string(payload[payload_key])
|
@@ -50,12 +50,13 @@ module NewRelic
|
|
50
50
|
|
51
51
|
def enabled?
|
52
52
|
Agent.config[:'slow_sql.enabled'] &&
|
53
|
-
|
54
|
-
|
55
|
-
Agent.config[:'transaction_tracer.enabled']
|
53
|
+
Agent.config[:'transaction_tracer.enabled'] &&
|
54
|
+
NewRelic::Agent::Database.should_record_sql?(:slow_sql)
|
56
55
|
end
|
57
56
|
|
58
57
|
def on_start_transaction(state, start_time, uri=nil)
|
58
|
+
return unless enabled?
|
59
|
+
|
59
60
|
state.sql_sampler_transaction_data = TransactionSqlData.new
|
60
61
|
|
61
62
|
if state.transaction_sample_builder
|
@@ -73,13 +74,15 @@ module NewRelic
|
|
73
74
|
|
74
75
|
# This is called when we are done with the transaction.
|
75
76
|
def on_finishing_transaction(state, name, time=Time.now)
|
77
|
+
return unless enabled?
|
78
|
+
|
76
79
|
data = state.sql_sampler_transaction_data
|
77
|
-
data
|
80
|
+
return unless data
|
78
81
|
|
82
|
+
data.set_transaction_name(name)
|
79
83
|
if data.sql_data.size > 0
|
80
84
|
@samples_lock.synchronize do
|
81
85
|
::NewRelic::Agent.logger.debug "Harvesting #{data.sql_data.size} slow transaction sql statement(s)"
|
82
|
-
#FIXME get tx name and uri
|
83
86
|
harvest_slow_sql data
|
84
87
|
end
|
85
88
|
end
|
@@ -145,7 +148,8 @@ module NewRelic
|
|
145
148
|
end
|
146
149
|
|
147
150
|
def harvest!
|
148
|
-
return []
|
151
|
+
return [] unless enabled?
|
152
|
+
|
149
153
|
result = []
|
150
154
|
@samples_lock.synchronize do
|
151
155
|
result = @sql_traces.values
|