newrelic_rpm 3.4.1 → 3.4.2.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +7 -0
- data/ReleaseNotes.md +638 -0
- data/lib/new_relic/agent/agent.rb +44 -56
- data/lib/new_relic/agent/beacon_configuration.rb +1 -1
- data/lib/new_relic/agent/browser_monitoring.rb +80 -42
- data/lib/new_relic/agent/configuration/defaults.rb +75 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +42 -0
- data/lib/new_relic/agent/configuration/manager.rb +100 -0
- data/lib/new_relic/agent/configuration/server_source.rb +24 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +61 -0
- data/lib/new_relic/agent/configuration.rb +48 -0
- data/lib/new_relic/agent/error_collector.rb +10 -14
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -5
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +20 -4
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +2 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +1 -1
- data/lib/new_relic/agent/new_relic_service.rb +18 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -5
- data/lib/new_relic/agent/sql_sampler.rb +11 -35
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -2
- data/lib/new_relic/agent/transaction_info.rb +24 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -3
- data/lib/new_relic/agent/transaction_sampler.rb +9 -16
- data/lib/new_relic/agent.rb +4 -1
- data/lib/new_relic/collection_helper.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +5 -3
- data/lib/new_relic/control/class_methods.rb +2 -3
- data/lib/new_relic/control/frameworks/rails.rb +8 -8
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/instance_methods.rb +26 -32
- data/lib/new_relic/control/logging_methods.rb +5 -23
- data/lib/new_relic/control/server_methods.rb +11 -18
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/language_support.rb +8 -0
- data/lib/new_relic/noticed_error.rb +1 -1
- data/lib/new_relic/rack/browser_monitoring.rb +18 -6
- data/lib/new_relic/version.rb +2 -2
- data/newrelic.yml +0 -4
- data/newrelic_rpm.gemspec +16 -6
- data/test/config/newrelic.yml +3 -2
- data/test/new_relic/agent/agent/connect_test.rb +88 -83
- data/test/new_relic/agent/agent/start_test.rb +75 -80
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +18 -18
- data/test/new_relic/agent/beacon_configuration_test.rb +13 -11
- data/test/new_relic/agent/browser_monitoring_test.rb +69 -14
- data/test/new_relic/agent/configuration/environment_source_test.rb +58 -0
- data/test/new_relic/agent/configuration/manager_test.rb +120 -0
- data/test/new_relic/agent/configuration/server_source_test.rb +28 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +56 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +63 -50
- data/test/new_relic/agent/error_collector_test.rb +10 -12
- data/test/new_relic/agent/new_relic_service_test.rb +11 -3
- data/test/new_relic/agent/pipe_channel_manager_test.rb +19 -16
- data/test/new_relic/agent/rpm_agent_test.rb +21 -19
- data/test/new_relic/agent/sql_sampler_test.rb +55 -56
- data/test/new_relic/agent/transaction_info_test.rb +45 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +48 -44
- data/test/new_relic/agent_test.rb +68 -41
- data/test/new_relic/collection_helper_test.rb +7 -8
- data/test/new_relic/command/deployments_test.rb +12 -1
- data/test/new_relic/control/frameworks/rails_test.rb +26 -0
- data/test/new_relic/control/logging_methods_test.rb +77 -52
- data/test/new_relic/control_test.rb +103 -126
- data/test/new_relic/local_environment_test.rb +4 -6
- data/test/new_relic/rack/browser_monitoring_test.rb +4 -4
- data/test/new_relic/rack/developer_mode_test.rb +13 -7
- data/test/new_relic/transaction_sample_test.rb +8 -2
- data/test/script/build_test_gem.sh +9 -3
- data/test/script/ci.sh +13 -3
- data/test/test_helper.rb +9 -2
- data/ui/helpers/developer_mode_helper.rb +2 -7
- metadata +26 -11
- data/lib/new_relic/control/configuration.rb +0 -206
- data/test/new_relic/control/configuration_test.rb +0 -77
@@ -32,7 +32,7 @@ module NewRelic
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
def memcache_key_snippet(method_name)
|
35
|
-
return "" unless NewRelic::
|
35
|
+
return "" unless NewRelic::Agent.config[:capture_memcache_keys]
|
36
36
|
"NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil"
|
37
37
|
end
|
38
38
|
end
|
@@ -44,7 +44,7 @@ DependencyDetection.defer do
|
|
44
44
|
@name = :memcache
|
45
45
|
|
46
46
|
depends_on do
|
47
|
-
!NewRelic::
|
47
|
+
!NewRelic::Agent.config[:disable_memcache_instrumentation]
|
48
48
|
end
|
49
49
|
|
50
50
|
depends_on do
|
@@ -320,7 +320,7 @@ module NewRelic
|
|
320
320
|
# the apdex should be recorded as a failure regardless of duration.
|
321
321
|
def self.update_apdex(stat, duration, failed)
|
322
322
|
duration = duration.to_f
|
323
|
-
apdex_t =
|
323
|
+
apdex_t = Agent.config[:apdex_t]
|
324
324
|
case
|
325
325
|
when failed
|
326
326
|
stat.record_apdex_f
|
@@ -2,7 +2,7 @@ DependencyDetection.defer do
|
|
2
2
|
@name = :rails21_view
|
3
3
|
|
4
4
|
depends_on do
|
5
|
-
!NewRelic::
|
5
|
+
!NewRelic::Agent.config[:disable_view_instrumentation] &&
|
6
6
|
defined?(ActionController) && defined?(ActionController::Base) && defined?(ActionView::PartialTemplate) && defined?(ActionView::Template) &&
|
7
7
|
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.1\./ # Rails 2.1 &&
|
8
8
|
end
|
@@ -26,7 +26,7 @@ DependencyDetection.defer do
|
|
26
26
|
@name = :old_rails_view
|
27
27
|
|
28
28
|
depends_on do
|
29
|
-
!NewRelic::
|
29
|
+
!NewRelic::Agent.config[:disable_view_instrumentation] &&
|
30
30
|
defined?(ActionController) && defined?(ActionController::Base) &&
|
31
31
|
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
|
32
32
|
end
|
@@ -47,7 +47,7 @@ DependencyDetection.defer do
|
|
47
47
|
@name = :rails23_view
|
48
48
|
|
49
49
|
depends_on do
|
50
|
-
!NewRelic::
|
50
|
+
!NewRelic::Agent.config[:disable_view_instrumentation] &&
|
51
51
|
defined?(ActionView) && defined?(ActionView::Template) && defined?(ActionView::RenderablePartial) &&
|
52
52
|
defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
|
53
53
|
end
|
@@ -96,7 +96,7 @@ DependencyDetection.defer do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
depends_on do
|
99
|
-
!NewRelic::
|
99
|
+
!NewRelic::Agent.config[:disable_view_instrumentation]
|
100
100
|
end
|
101
101
|
|
102
102
|
executes do
|
@@ -135,7 +135,7 @@ DependencyDetection.defer do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
depends_on do
|
138
|
-
!NewRelic::
|
138
|
+
!NewRelic::Agent.config[:disable_view_instrumentation]
|
139
139
|
end
|
140
140
|
|
141
141
|
executes do
|
@@ -2,7 +2,7 @@ DependencyDetection.defer do
|
|
2
2
|
@name = :resque
|
3
3
|
|
4
4
|
depends_on do
|
5
|
-
defined?(::Resque::Job) && !NewRelic::
|
5
|
+
defined?(::Resque::Job) && !NewRelic::Agent.config[:disable_resque] &&
|
6
6
|
!NewRelic::LanguageSupport.using_version?('1.9.1')
|
7
7
|
end
|
8
8
|
|
@@ -497,7 +497,7 @@ module NewRelic
|
|
497
497
|
# from when they were added, or else other tracers that were added to the same method
|
498
498
|
# may get removed as well.
|
499
499
|
def remove_method_tracer(method_name, metric_name_code) # :nodoc:
|
500
|
-
return unless
|
500
|
+
return unless Agent.config[:agent_enabled]
|
501
501
|
if method_defined? "#{_traced_method_name(method_name, metric_name_code)}"
|
502
502
|
alias_method method_name, "#{_untraced_method_name(method_name, metric_name_code)}"
|
503
503
|
undef_method "#{_traced_method_name(method_name, metric_name_code)}"
|
@@ -17,10 +17,10 @@ module NewRelic
|
|
17
17
|
attr_reader :collector
|
18
18
|
attr_accessor :agent_id
|
19
19
|
|
20
|
-
def initialize(license_key=
|
21
|
-
@license_key = license_key
|
20
|
+
def initialize(license_key=nil, collector=control.server)
|
21
|
+
@license_key = license_key || Agent.config[:license_key]
|
22
22
|
@collector = collector
|
23
|
-
@request_timeout =
|
23
|
+
@request_timeout = Agent.config[:timeout]
|
24
24
|
end
|
25
25
|
|
26
26
|
def connect(settings={})
|
@@ -119,11 +119,9 @@ module NewRelic
|
|
119
119
|
# big payloads get all the compression possible, to stay under
|
120
120
|
# the 2,000,000 byte post threshold
|
121
121
|
def compress_data(object)
|
122
|
-
dump =
|
122
|
+
dump = marshal_data(object)
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
return [dump, 'identity'] if dump_size < (64*1024)
|
124
|
+
return [dump, 'identity'] if dump.size < (64*1024)
|
127
125
|
|
128
126
|
compressed_dump = Zlib::Deflate.deflate(dump, Zlib::DEFAULT_COMPRESSION)
|
129
127
|
|
@@ -133,11 +131,20 @@ module NewRelic
|
|
133
131
|
[compressed_dump, 'deflate']
|
134
132
|
end
|
135
133
|
|
134
|
+
def marshal_data(data)
|
135
|
+
NewRelic::LanguageSupport.with_cautious_gc do
|
136
|
+
Marshal.dump(data)
|
137
|
+
end
|
138
|
+
rescue => e
|
139
|
+
log.debug("#{e.class.name} : #{e.message} when marshalling #{object}")
|
140
|
+
raise
|
141
|
+
end
|
142
|
+
|
136
143
|
# Raises a PostTooBigException if the post_string is longer
|
137
144
|
# than the limit configured in the control object
|
138
145
|
def check_post_size(post_string)
|
139
146
|
# TODO: define this as a config option on the server side
|
140
|
-
return if post_string.size <
|
147
|
+
return if post_string.size < Agent.config[:post_size_limit]
|
141
148
|
log.warn "Tried to send too much data: #{post_string.size} bytes"
|
142
149
|
raise PostTooBigException
|
143
150
|
end
|
@@ -200,7 +207,9 @@ module NewRelic
|
|
200
207
|
# so we can handle it in nonlocally
|
201
208
|
def check_for_exception(response)
|
202
209
|
dump = decompress_response(response)
|
203
|
-
value =
|
210
|
+
value = NewRelic::LanguageSupport.with_cautious_gc do
|
211
|
+
Marshal.load(dump)
|
212
|
+
end
|
204
213
|
raise value if value.is_a? Exception
|
205
214
|
value
|
206
215
|
end
|
@@ -41,7 +41,10 @@ module NewRelic
|
|
41
41
|
|
42
42
|
def write(data)
|
43
43
|
@out.close unless @out.closed?
|
44
|
-
@in <<
|
44
|
+
@in << NewRelic::LanguageSupport.with_cautious_gc do
|
45
|
+
Marshal.dump(data)
|
46
|
+
end
|
47
|
+
@in << "\n\n"
|
45
48
|
end
|
46
49
|
|
47
50
|
def read
|
@@ -137,11 +140,7 @@ module NewRelic
|
|
137
140
|
end
|
138
141
|
|
139
142
|
def unmarshal(data)
|
140
|
-
|
141
|
-
NewRelic::LanguageSupport.with_disabled_gc do
|
142
|
-
Marshal.load(data)
|
143
|
-
end
|
144
|
-
else
|
143
|
+
NewRelic::LanguageSupport.with_cautious_gc do
|
145
144
|
Marshal.load(data)
|
146
145
|
end
|
147
146
|
rescue StandardError => e
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
class DelayedJobSampler < NewRelic::Agent::Sampler
|
15
15
|
def initialize
|
16
16
|
super :delayed_job_queue
|
17
|
-
raise Unsupported, "DJ instrumentation disabled" if
|
17
|
+
raise Unsupported, "DJ instrumentation disabled" if Agent.config[:disable_dj]
|
18
18
|
raise Unsupported, "No DJ worker present" unless NewRelic::DelayedJobInjection.worker_name
|
19
19
|
end
|
20
20
|
|
@@ -33,9 +33,6 @@ module NewRelic
|
|
33
33
|
local_env.dispatcher_instance_id
|
34
34
|
end
|
35
35
|
|
36
|
-
def queued_jobs
|
37
|
-
Delayed::Job.count(:conditions => ['run_at < ? and failed_at is NULL', Time.now])
|
38
|
-
end
|
39
36
|
def failed_jobs
|
40
37
|
Delayed::Job.count(:conditions => 'failed_at is not NULL')
|
41
38
|
end
|
@@ -62,7 +59,7 @@ module NewRelic
|
|
62
59
|
|
63
60
|
def record_queue_length_across_dimension(column)
|
64
61
|
all_count = 0
|
65
|
-
Delayed::Job.count(:group => column).each do | column_val, count |
|
62
|
+
Delayed::Job.count(:group => column, :conditions => ['run_at < ? and failed_at is NULL', Time.now]).each do | column_val, count |
|
66
63
|
all_count += count
|
67
64
|
record stats_engine.get_stats("Workers/DelayedJob/queue_length/#{column == 'queue' ? 'name' : column}/#{column_val}", false), count
|
68
65
|
end
|
@@ -27,38 +27,18 @@ module NewRelic
|
|
27
27
|
# any 'honest-to-god'-multithreaded system
|
28
28
|
@samples_lock = Mutex.new
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def configure!
|
32
|
-
@explain_threshold = config.
|
33
|
-
@explain_enabled = config.
|
34
|
-
@stack_trace_threshold = config.
|
35
|
-
|
36
|
-
if config.fetch('enabled', true) &&
|
37
|
-
NewRelic::Control.instance['transaction_tracer'] &&
|
38
|
-
NewRelic::Control.instance['transaction_tracer'].fetch('enabled',
|
39
|
-
true) &&
|
40
|
-
NewRelic::Control.instance.fetch('collect_traces', true)
|
32
|
+
@explain_threshold = Agent.config[:'slow_sql.explain_threshold']
|
33
|
+
@explain_enabled = Agent.config[:'sloq_sql.explain_enabled']
|
34
|
+
@stack_trace_threshold = Agent.config[:'slow_sql.stack_trace_threshold']
|
35
|
+
if Agent.config[:'slow_sql.enabled']
|
41
36
|
enable
|
42
37
|
else
|
43
38
|
disable
|
44
39
|
end
|
45
40
|
end
|
46
|
-
|
47
|
-
def config
|
48
|
-
self.class.config
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.config
|
52
|
-
control = NewRelic::Control.instance
|
53
|
-
txn_config = control.fetch('transaction_tracer', {})
|
54
41
|
|
55
|
-
if txn_config.fetch('enabled', true) && control.has_slow_sql_config?
|
56
|
-
txn_config['enabled'] = control['slow_sql']['enabled']
|
57
|
-
end
|
58
|
-
|
59
|
-
txn_config
|
60
|
-
end
|
61
|
-
|
62
42
|
# Enable the sql sampler - this also registers it with
|
63
43
|
# the statistics engine.
|
64
44
|
def enable
|
@@ -152,7 +132,7 @@ module NewRelic
|
|
152
132
|
@samples_lock.synchronize do
|
153
133
|
result = @sql_traces.values
|
154
134
|
@sql_traces = {}
|
155
|
-
end
|
135
|
+
end
|
156
136
|
slowest = result.sort{|a,b| b.max_call_time <=> a.max_call_time}[0,10]
|
157
137
|
slowest.each {|trace| trace.prepare_to_send }
|
158
138
|
slowest
|
@@ -243,24 +223,20 @@ module NewRelic
|
|
243
223
|
|
244
224
|
record_data_point slow_sql.duration
|
245
225
|
end
|
246
|
-
|
226
|
+
|
247
227
|
def prepare_to_send
|
248
228
|
params[:explain_plan] = @slow_sql.explain if need_to_explain?
|
249
229
|
@sql = @slow_sql.obfuscate if need_to_obfuscate?
|
250
230
|
end
|
251
|
-
|
252
|
-
def agent_config
|
253
|
-
NewRelic::Agent::SqlSampler.config
|
254
|
-
end
|
255
|
-
|
231
|
+
|
256
232
|
def need_to_obfuscate?
|
257
|
-
|
233
|
+
Agent.config[:'slow_sql.record_sql'].to_s == 'obfuscated'
|
258
234
|
end
|
259
235
|
|
260
236
|
def need_to_explain?
|
261
|
-
|
237
|
+
Agent.config[:'slow_sql.explain_enabled']
|
262
238
|
end
|
263
|
-
|
239
|
+
|
264
240
|
def to_json(*a)
|
265
241
|
[@path, @url, @sql_id, @sql, @database_metric_name, @call_count, @total_call_time, @min_call_time, @max_call_time, @params].to_json(*a)
|
266
242
|
end
|
@@ -46,6 +46,7 @@ module Agent
|
|
46
46
|
# TransactionSample::Segment at the end of transaction execution
|
47
47
|
def push_scope(metric, time = Time.now.to_f, deduct_call_time_from_parent = true)
|
48
48
|
stack = scope_stack
|
49
|
+
stack.empty? ? GCProfiler.init : GCProfiler.capture
|
49
50
|
@transaction_sampler.notice_push_scope metric, time if @transaction_sampler
|
50
51
|
scope = ScopeStackElement.new(metric, deduct_call_time_from_parent)
|
51
52
|
stack.push scope
|
@@ -55,6 +56,7 @@ module Agent
|
|
55
56
|
# Pops a scope off the transaction stack - this updates the
|
56
57
|
# transaction sampler that we've finished execution of a traced method
|
57
58
|
def pop_scope(expected_scope, duration, time=Time.now.to_f)
|
59
|
+
GCProfiler.capture
|
58
60
|
stack = scope_stack
|
59
61
|
scope = stack.pop
|
60
62
|
fail "unbalanced pop from blame stack, got #{scope ? scope.name : 'nil'}, expected #{expected_scope ? expected_scope.name : 'nil'}" if scope != expected_scope
|
@@ -96,7 +98,6 @@ module Agent
|
|
96
98
|
def start_transaction(name = nil)
|
97
99
|
Thread::current[:newrelic_scope_stack] ||= []
|
98
100
|
self.scope_name = name if name
|
99
|
-
GCProfiler.init
|
100
101
|
end
|
101
102
|
|
102
103
|
# Try to clean up gracefully, otherwise we leave things hanging around on thread locals.
|
@@ -104,7 +105,6 @@ module Agent
|
|
104
105
|
# and is ignored.
|
105
106
|
#
|
106
107
|
def end_transaction
|
107
|
-
GCProfiler.capture
|
108
108
|
stack = scope_stack
|
109
109
|
|
110
110
|
if stack && stack.empty?
|
@@ -11,14 +11,15 @@ module NewRelic
|
|
11
11
|
@guid = ""
|
12
12
|
@transaction_name = "(unknown)"
|
13
13
|
@start_time = Time.now
|
14
|
+
@ignore_end_user = false
|
14
15
|
end
|
15
16
|
|
16
17
|
def force_persist_sample?(sample)
|
17
|
-
token && sample.duration >
|
18
|
+
token && sample.duration > Agent.config[:apdex_t]
|
18
19
|
end
|
19
20
|
|
20
21
|
def include_guid?
|
21
|
-
token && duration >
|
22
|
+
token && duration > Agent.config[:apdex_t]
|
22
23
|
end
|
23
24
|
|
24
25
|
def guid
|
@@ -32,6 +33,14 @@ module NewRelic
|
|
32
33
|
def duration
|
33
34
|
Time.now - start_time
|
34
35
|
end
|
36
|
+
|
37
|
+
def ignore_end_user?
|
38
|
+
@ignore_end_user
|
39
|
+
end
|
40
|
+
|
41
|
+
def ignore_end_user=(value)
|
42
|
+
@ignore_end_user = value
|
43
|
+
end
|
35
44
|
|
36
45
|
def self.get()
|
37
46
|
Thread.current[:newrelic_transaction_info] ||= TransactionInfo.new
|
@@ -57,17 +66,28 @@ module NewRelic
|
|
57
66
|
return nil unless request
|
58
67
|
|
59
68
|
agent_flag = request.cookies['NRAGENT']
|
60
|
-
if agent_flag
|
69
|
+
if agent_flag and agent_flag.instance_of? String
|
61
70
|
s = agent_flag.split("=")
|
62
71
|
if s.length == 2
|
63
72
|
if s[0] == "tk" && s[1]
|
64
|
-
ERB::Util.h(s[1])
|
73
|
+
ERB::Util.h(sanitize_token(s[1]))
|
65
74
|
end
|
66
75
|
end
|
67
76
|
else
|
68
77
|
nil
|
69
78
|
end
|
70
79
|
end
|
80
|
+
|
81
|
+
# Run through a collection of unsafe characters ( in the context of the token )
|
82
|
+
# and set the token to an empty string if any of them are found in the token so that
|
83
|
+
# potential XSS attacks via the token are avoided
|
84
|
+
def self.sanitize_token(token)
|
85
|
+
|
86
|
+
if ( /[<>'"]/ =~ token )
|
87
|
+
token.replace("")
|
88
|
+
end
|
89
|
+
token
|
90
|
+
end
|
71
91
|
end
|
72
92
|
end
|
73
93
|
end
|
@@ -17,8 +17,7 @@ module NewRelic
|
|
17
17
|
@sample = NewRelic::TransactionSample.new(time.to_f)
|
18
18
|
@sample_start = time.to_f
|
19
19
|
@current_segment = @sample.root_segment
|
20
|
-
@segment_limit =
|
21
|
-
.fetch('limit_segments', 4000)
|
20
|
+
@segment_limit = Agent.config[:'transaction_tracer.limit_segments']
|
22
21
|
end
|
23
22
|
|
24
23
|
def sample_id
|
@@ -93,7 +92,7 @@ module NewRelic
|
|
93
92
|
def set_transaction_info(path, uri, params)
|
94
93
|
@sample.params[:path] = path
|
95
94
|
|
96
|
-
if
|
95
|
+
if Agent.config[:capture_params]
|
97
96
|
params = normalize_params params
|
98
97
|
|
99
98
|
@sample.params[:request_params].merge!(params)
|
@@ -50,26 +50,19 @@ module NewRelic
|
|
50
50
|
# @segment_limit and @stack_trace_threshold come from the
|
51
51
|
# configuration file, with built-in defaults that should
|
52
52
|
# suffice for most customers
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@explain_threshold = config.fetch('explain_threshold', 0.5).to_f
|
59
|
-
@explain_enabled = config.fetch('explain_enabled', true)
|
60
|
-
@transaction_threshold = config.fetch('transation_threshold', 2.0)
|
53
|
+
@segment_limit = Agent.config[:'transaction_tracer.limit_segments']
|
54
|
+
@stack_trace_threshold = Agent.config[:'transaction_tracer.stack_trace_threshold']
|
55
|
+
@explain_threshold = Agent.config[:'transaction_tracer.explain_threshold']
|
56
|
+
@explain_enabled = Agent.config[:'transaction_tracer.explain_enabled']
|
57
|
+
@transaction_threshold = Agent.config[:'transaction_tracer.transation_threshold']
|
61
58
|
|
62
59
|
# Configure the sample storage policy. Create a list of methods to be called.
|
63
60
|
@store_sampler_methods = [ :store_random_sample, :store_slowest_sample ]
|
64
|
-
if
|
61
|
+
if Agent.config[:developer_mode]
|
65
62
|
@store_sampler_methods << :store_sample_for_developer_mode
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
69
|
-
def config
|
70
|
-
NewRelic::Control.instance.fetch('transaction_tracer', {})
|
71
|
-
end
|
72
|
-
|
73
66
|
# Returns the current sample id, delegated from `builder`
|
74
67
|
def current_sample_id
|
75
68
|
b=builder
|
@@ -121,14 +114,14 @@ module NewRelic
|
|
121
114
|
|
122
115
|
builder.trace_entry(scope, time.to_f)
|
123
116
|
|
124
|
-
capture_segment_trace if
|
117
|
+
capture_segment_trace if Agent.config[:developer_mode]
|
125
118
|
end
|
126
119
|
|
127
120
|
# in developer mode, capture the stack trace with the segment.
|
128
121
|
# this is cpu and memory expensive and therefore should not be
|
129
122
|
# turned on in production mode
|
130
123
|
def capture_segment_trace
|
131
|
-
return unless
|
124
|
+
return unless Agent.config[:developer_mode]
|
132
125
|
segment = builder.current_segment
|
133
126
|
if segment
|
134
127
|
# Strip stack frames off the top that match /new_relic/agent/
|
@@ -215,7 +208,7 @@ module NewRelic
|
|
215
208
|
# Samples take up a ton of memory, so we only store a lot of
|
216
209
|
# them in developer mode - we truncate to @max_samples
|
217
210
|
def store_sample_for_developer_mode(sample)
|
218
|
-
return unless
|
211
|
+
return unless Agent.config[:developer_mode]
|
219
212
|
@samples = [] unless @samples
|
220
213
|
@samples << sample
|
221
214
|
truncate_samples
|