wd_newrelic_rpm 3.5.6 → 3.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +43 -3
- data/Gemfile +6 -2
- data/LICENSE +23 -0
- data/lib/new_relic/agent.rb +50 -3
- data/lib/new_relic/agent/agent.rb +40 -60
- data/lib/new_relic/agent/configuration/defaults.rb +9 -3
- data/lib/new_relic/agent/configuration/server_source.rb +4 -0
- data/lib/new_relic/agent/cross_app_monitor.rb +239 -0
- data/lib/new_relic/agent/cross_app_tracing.rb +281 -0
- data/lib/new_relic/agent/database.rb +28 -10
- data/lib/new_relic/agent/error_collector.rb +5 -0
- data/lib/new_relic/agent/event_listener.rb +4 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +58 -39
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +16 -3
- data/lib/new_relic/agent/instrumentation/net.rb +13 -11
- data/lib/new_relic/agent/instrumentation/queue_time.rb +50 -192
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +145 -0
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +45 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +10 -10
- data/lib/new_relic/agent/instrumentation/sinatra.rb +19 -9
- data/lib/new_relic/agent/new_relic_service.rb +63 -9
- data/lib/new_relic/agent/pipe_service.rb +8 -12
- data/lib/new_relic/agent/rules_engine.rb +72 -0
- data/lib/new_relic/agent/shim_agent.rb +0 -1
- data/lib/new_relic/agent/sql_sampler.rb +3 -2
- data/lib/new_relic/agent/stats.rb +149 -0
- data/lib/new_relic/agent/stats_engine.rb +9 -0
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -24
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +84 -185
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +58 -0
- data/lib/new_relic/agent/stats_engine/transactions.rb +10 -2
- data/lib/new_relic/agent/transaction_info.rb +31 -6
- data/lib/new_relic/agent/transaction_sample_builder.rb +19 -8
- data/lib/new_relic/agent/transaction_sampler.rb +17 -10
- data/lib/new_relic/helper.rb +32 -0
- data/lib/new_relic/local_environment.rb +24 -32
- data/lib/new_relic/okjson.rb +599 -0
- data/lib/new_relic/transaction_sample.rb +2 -1
- data/lib/new_relic/transaction_sample/segment.rb +2 -1
- data/lib/new_relic/version.rb +1 -1
- data/newrelic.yml +27 -41
- data/test/multiverse/suites/agent_only/Envfile +5 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +2 -4
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -2
- data/test/multiverse/suites/agent_only/{cross_process_test.rb → cross_application_tracing_test.rb} +3 -3
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +66 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +9 -22
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +57 -0
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +17 -6
- data/test/multiverse/suites/rails/error_tracing_test.rb +20 -8
- data/test/multiverse/suites/rails/queue_time_test.rb +2 -2
- data/test/multiverse/suites/resque/instrumentation_test.rb +4 -3
- data/test/multiverse/suites/sinatra/Envfile +2 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +1 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +5 -5
- data/test/multiverse/suites/sinatra/sinatra_test.rb +77 -10
- data/test/new_relic/agent/agent/connect_test.rb +45 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +0 -3
- data/test/new_relic/agent/agent_test.rb +20 -40
- data/test/new_relic/agent/agent_test_controller_test.rb +27 -60
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +8 -3
- data/test/new_relic/agent/cross_app_monitor_test.rb +237 -0
- data/test/new_relic/agent/database_test.rb +60 -16
- data/test/new_relic/agent/error_collector_test.rb +28 -4
- data/test/new_relic/agent/event_listener_test.rb +23 -2
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +85 -12
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +95 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +436 -59
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +58 -357
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -5
- data/test/new_relic/agent/method_tracer_test.rb +4 -2
- data/test/new_relic/agent/new_relic_service_test.rb +108 -6
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
- data/test/new_relic/agent/pipe_service_test.rb +9 -9
- data/test/new_relic/agent/rpm_agent_test.rb +0 -11
- data/test/new_relic/agent/rules_engine_test.rb +82 -0
- data/test/new_relic/agent/shim_agent_test.rb +0 -4
- data/test/new_relic/agent/sql_sampler_test.rb +7 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +85 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +110 -23
- data/test/new_relic/agent/stats_engine_test.rb +1 -46
- data/test/new_relic/agent/stats_hash_test.rb +93 -0
- data/test/new_relic/agent/stats_test.rb +197 -0
- data/test/new_relic/agent/transaction_info_test.rb +63 -11
- data/test/new_relic/agent/transaction_sample_builder_test.rb +10 -3
- data/test/new_relic/agent/transaction_sampler_test.rb +92 -80
- data/test/new_relic/agent/worker_loop_test.rb +1 -1
- data/test/new_relic/agent_test.rb +35 -5
- data/test/new_relic/control_test.rb +1 -1
- data/test/new_relic/fake_collector.rb +87 -9
- data/test/new_relic/helper_test.rb +24 -0
- data/test/new_relic/metric_data_test.rb +11 -11
- data/test/new_relic/metric_spec_test.rb +1 -1
- data/test/script/ci.sh +1 -1
- data/test/test_contexts.rb +0 -1
- data/test/test_helper.rb +21 -3
- metadata +34 -41
- data/lib/new_relic/agent/cross_process_monitoring.rb +0 -187
- data/lib/new_relic/stats.rb +0 -337
- data/test/new_relic/agent/cross_process_monitoring_test.rb +0 -190
- data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +0 -133
- data/test/new_relic/fakes_sending_data.rb +0 -30
- data/test/new_relic/stats_test.rb +0 -421
@@ -11,7 +11,8 @@ module NewRelic
|
|
11
11
|
|
12
12
|
class TransactionSample
|
13
13
|
|
14
|
-
attr_accessor
|
14
|
+
attr_accessor(:params, :root_segment, :profile, :force_persist, :guid,
|
15
|
+
:threshold)
|
15
16
|
attr_reader :root_segment, :params, :sample_id
|
16
17
|
|
17
18
|
@@start_time = Time.now
|
@@ -8,9 +8,10 @@ module NewRelic
|
|
8
8
|
# have a timestamp.
|
9
9
|
attr_reader :exit_timestamp
|
10
10
|
attr_reader :parent_segment
|
11
|
-
attr_reader :metric_name
|
12
11
|
attr_reader :segment_id
|
13
12
|
|
13
|
+
attr_accessor :metric_name
|
14
|
+
|
14
15
|
def initialize(timestamp, metric_name, segment_id)
|
15
16
|
@entry_timestamp = timestamp
|
16
17
|
@metric_name = metric_name || '<unknown>'
|
data/lib/new_relic/version.rb
CHANGED
data/newrelic.yml
CHANGED
@@ -16,7 +16,7 @@ common: &default_settings
|
|
16
16
|
# account. This key binds your Agent's data to your account in the
|
17
17
|
# New Relic service.
|
18
18
|
license_key: '<%= license_key %>'
|
19
|
-
|
19
|
+
|
20
20
|
# Agent Enabled (Rails Only)
|
21
21
|
# Use this setting to force the agent to run or not run.
|
22
22
|
# Default is 'auto' which means the agent will install and run only
|
@@ -26,7 +26,7 @@ common: &default_settings
|
|
26
26
|
# Valid values are true, false and auto.
|
27
27
|
#
|
28
28
|
# agent_enabled: auto
|
29
|
-
|
29
|
+
|
30
30
|
# Application Name Set this to be the name of your application as
|
31
31
|
# you'd like it show up in New Relic. The service will then auto-map
|
32
32
|
# instances of your application into an "application" on your
|
@@ -41,12 +41,12 @@ common: &default_settings
|
|
41
41
|
# app_name:
|
42
42
|
# - Ajax Service
|
43
43
|
# - All Services
|
44
|
-
#
|
44
|
+
#
|
45
45
|
app_name: <%= @app_name %>
|
46
46
|
|
47
|
-
# When "true", the agent collects performance data about your
|
48
|
-
# application and reports this data to the New Relic service at
|
49
|
-
# newrelic.com. This global switch is normally overridden for each
|
47
|
+
# When "true", the agent collects performance data about your
|
48
|
+
# application and reports this data to the New Relic service at
|
49
|
+
# newrelic.com. This global switch is normally overridden for each
|
50
50
|
# environment below (formerly called 'enabled').
|
51
51
|
monitor_mode: true
|
52
52
|
|
@@ -64,7 +64,7 @@ common: &default_settings
|
|
64
64
|
# '/var/log/') The agent will attempt to create this directory if it
|
65
65
|
# does not exist.
|
66
66
|
# log_file_path: 'log'
|
67
|
-
|
67
|
+
|
68
68
|
# Optionally set the name of the log file, defaults to 'newrelic_agent.log'
|
69
69
|
# log_file_name: 'newrelic_agent.log'
|
70
70
|
|
@@ -79,9 +79,9 @@ common: &default_settings
|
|
79
79
|
# New Relic Real User Monitoring gives you insight into the performance real users are
|
80
80
|
# experiencing with your website. This is accomplished by measuring the time it takes for
|
81
81
|
# your users' browsers to download and render your web pages by injecting a small amount
|
82
|
-
# of JavaScript code into the header and footer of each page.
|
82
|
+
# of JavaScript code into the header and footer of each page.
|
83
83
|
browser_monitoring:
|
84
|
-
# By default the agent automatically injects the monitoring JavaScript
|
84
|
+
# By default the agent automatically injects the monitoring JavaScript
|
85
85
|
# into web pages. Set this attribute to false to turn off this behavior.
|
86
86
|
auto_instrument: true
|
87
87
|
|
@@ -101,7 +101,7 @@ common: &default_settings
|
|
101
101
|
# See: https://newrelic.com/docs/ruby/audit-log
|
102
102
|
audit_log:
|
103
103
|
enabled: false
|
104
|
-
|
104
|
+
|
105
105
|
# Tells transaction tracer and error collector (when enabled)
|
106
106
|
# whether or not to capture HTTP params. When true, frameworks can
|
107
107
|
# exclude HTTP parameters from being captured.
|
@@ -111,18 +111,17 @@ common: &default_settings
|
|
111
111
|
# ex: ignored_params: credit_card, ssn, password
|
112
112
|
capture_params: false
|
113
113
|
|
114
|
-
|
115
114
|
# Transaction tracer captures deep information about slow
|
116
115
|
# transactions and sends this to the service once a
|
117
116
|
# minute. Included in the transaction is the exact call sequence of
|
118
117
|
# the transactions including any SQL statements issued.
|
119
118
|
transaction_tracer:
|
120
|
-
|
119
|
+
|
121
120
|
# Transaction tracer is enabled by default. Set this to false to
|
122
121
|
# turn it off. This feature is only available at the Professional
|
123
122
|
# and above product levels.
|
124
123
|
enabled: true
|
125
|
-
|
124
|
+
|
126
125
|
# Threshold in seconds for when to collect a transaction
|
127
126
|
# trace. When the response time of a controller action exceeds
|
128
127
|
# this threshold, a transaction trace will be recorded and sent to
|
@@ -130,13 +129,13 @@ common: &default_settings
|
|
130
129
|
# "apdex_f", which will use the threshold for an dissatisfying
|
131
130
|
# Apdex controller action - four times the Apdex T value.
|
132
131
|
transaction_threshold: apdex_f
|
133
|
-
|
132
|
+
|
134
133
|
# When transaction tracer is on, SQL statements can optionally be
|
135
134
|
# recorded. The recorder has three modes, "off" which sends no
|
136
135
|
# SQL, "raw" which sends the SQL statement in its original form,
|
137
136
|
# and "obfuscated", which strips out numeric and string literals.
|
138
137
|
record_sql: obfuscated
|
139
|
-
|
138
|
+
|
140
139
|
# Threshold in seconds for when to collect stack trace for a SQL
|
141
140
|
# call. In other words, when SQL statements exceed this threshold,
|
142
141
|
# then capture and send the current stack trace. This is
|
@@ -148,42 +147,29 @@ common: &default_settings
|
|
148
147
|
# set to false when using other adapters.
|
149
148
|
# explain_enabled: true
|
150
149
|
|
151
|
-
# Threshold for query execution time below which query plans will not
|
150
|
+
# Threshold for query execution time below which query plans will not
|
152
151
|
# not be captured. Relevant only when `explain_enabled` is true.
|
153
152
|
# explain_threshold: 0.5
|
154
|
-
|
153
|
+
|
155
154
|
# Error collector captures information about uncaught exceptions and
|
156
155
|
# sends them to the service for viewing.
|
157
156
|
error_collector:
|
158
|
-
|
157
|
+
|
159
158
|
# Error collector is enabled by default. Set this to false to turn
|
160
159
|
# it off. This feature is only available at the Professional and above
|
161
160
|
# product levels.
|
162
161
|
enabled: true
|
163
|
-
|
164
|
-
# Rails Only - tells error collector whether or not to capture a
|
165
|
-
# source snippet around the place of the error when errors are View
|
162
|
+
|
163
|
+
# Rails Only - tells error collector whether or not to capture a
|
164
|
+
# source snippet around the place of the error when errors are View
|
166
165
|
# related.
|
167
|
-
capture_source: true
|
168
|
-
|
166
|
+
capture_source: true
|
167
|
+
|
169
168
|
# To stop specific errors from reporting to New Relic, set this property
|
170
169
|
# to comma separated values. Default is to ignore routing errors
|
171
170
|
# which are how 404's get triggered.
|
172
171
|
ignore_errors: ActionController::RoutingError
|
173
172
|
|
174
|
-
# (Advanced) Uncomment this to ensure the cpu and memory samplers
|
175
|
-
# won't run. Useful when you are using the agent to monitor an
|
176
|
-
# external resource.
|
177
|
-
# disable_samplers: true
|
178
|
-
|
179
|
-
# If you aren't interested in visibility in these areas, you can
|
180
|
-
# disable the instrumentation to reduce overhead.
|
181
|
-
#
|
182
|
-
# disable_view_instrumentation: true
|
183
|
-
# disable_activerecord_instrumentation: true
|
184
|
-
# disable_memcache_instrumentation: true
|
185
|
-
# disable_dj: true
|
186
|
-
|
187
173
|
# If you're interested in capturing memcache keys as though they
|
188
174
|
# were SQL uncomment this flag. Note that this does increase
|
189
175
|
# overhead slightly on every memcached call, and can have security
|
@@ -202,19 +188,19 @@ common: &default_settings
|
|
202
188
|
|
203
189
|
development:
|
204
190
|
<<: *default_settings
|
205
|
-
# Turn off communication to New Relic service in development mode (also
|
191
|
+
# Turn off communication to New Relic service in development mode (also
|
206
192
|
# 'enabled').
|
207
|
-
# NOTE: for initial evaluation purposes, you may want to temporarily
|
193
|
+
# NOTE: for initial evaluation purposes, you may want to temporarily
|
208
194
|
# turn the agent on in development mode.
|
209
195
|
monitor_mode: false
|
210
196
|
|
211
|
-
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
197
|
+
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
212
198
|
# present performance information on the last 100 transactions you have
|
213
199
|
# executed since starting the mongrel.
|
214
200
|
# NOTE: There is substantial overhead when running in developer mode.
|
215
|
-
# Do not use for production or load testing.
|
201
|
+
# Do not use for production or load testing.
|
216
202
|
developer_mode: true
|
217
|
-
|
203
|
+
|
218
204
|
# Enable textmate links
|
219
205
|
# textmate: true
|
220
206
|
|
@@ -67,7 +67,7 @@ class AuditLogTest < Test::Unit::TestCase
|
|
67
67
|
def run_agent_with_options(options)
|
68
68
|
NewRelic::Agent.manual_start(options)
|
69
69
|
yield NewRelic::Agent.agent if block_given?
|
70
|
-
NewRelic::Agent.shutdown
|
70
|
+
NewRelic::Agent.shutdown
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_logs_nothing_by_default
|
@@ -90,10 +90,8 @@ class AuditLogTest < Test::Unit::TestCase
|
|
90
90
|
agent.sql_sampler.notice_scope_empty
|
91
91
|
agent.send(:harvest_and_send_slowest_sql)
|
92
92
|
end
|
93
|
-
|
94
93
|
$collector.agent_data.each do |req|
|
95
|
-
body
|
96
|
-
assert_audit_log_contains_object(body, format)
|
94
|
+
assert_audit_log_contains_object(req.body, format)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
@@ -3,7 +3,7 @@ development:
|
|
3
3
|
error_collector:
|
4
4
|
capture_source: true
|
5
5
|
enabled: true
|
6
|
-
apdex_t: 0.
|
6
|
+
apdex_t: 0.24
|
7
7
|
ssl: false
|
8
8
|
monitor_mode: true
|
9
9
|
license_key: bootstrap_newrelic_admin_license_key_000
|
@@ -16,7 +16,6 @@ development:
|
|
16
16
|
record_sql: obfuscated
|
17
17
|
enabled: true
|
18
18
|
stack_trace_threshold: 0.5
|
19
|
-
transaction_threshold: 1.0
|
20
19
|
capture_params: false
|
21
20
|
log_level: debug
|
22
21
|
log_file_path: agent.log
|
data/test/multiverse/suites/agent_only/{cross_process_test.rb → cross_application_tracing_test.rb}
RENAMED
@@ -35,17 +35,17 @@ class CrossProcessTest < Test::Unit::TestCase
|
|
35
35
|
@@wrapper_app
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def test_cross_app_doesnt_modify_without_header
|
39
39
|
get '/'
|
40
40
|
assert_nil last_response.headers["X-NewRelic-App-Data"]
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def test_cross_app_doesnt_modify_with_invalid_header
|
44
44
|
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
|
45
45
|
assert_nil last_response.headers["X-NewRelic-App-Data"]
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def test_cross_app_writes_out_information
|
49
49
|
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
50
50
|
assert_not_nil last_response.headers["X-NewRelic-App-Data"]
|
51
51
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class KeyTransactionsTest < Test::Unit::TestCase
|
2
|
+
class TestWidget
|
3
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
4
|
+
|
5
|
+
def key_txn
|
6
|
+
sleep 0.05
|
7
|
+
end
|
8
|
+
add_transaction_tracer :key_txn
|
9
|
+
|
10
|
+
def other_txn
|
11
|
+
sleep 0.05
|
12
|
+
end
|
13
|
+
add_transaction_tracer :other_txn
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
$collector ||= NewRelic::FakeCollector.new
|
18
|
+
$collector.reset
|
19
|
+
key_apdex_config = { 'Controller/KeyTransactionsTest::TestWidget/key_txn' => 0.01 }
|
20
|
+
$collector.mock['connect'] = [200, {'return_value' => {
|
21
|
+
"agent_run_id" => 666,
|
22
|
+
'web_transactions_apdex' => key_apdex_config,
|
23
|
+
'apdex_t' => 0.1
|
24
|
+
}}]
|
25
|
+
$collector.run
|
26
|
+
|
27
|
+
NewRelic::Agent.manual_start(:sync_startup => true,
|
28
|
+
:force_reconnect => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
NewRelic::Agent.shutdown
|
33
|
+
end
|
34
|
+
|
35
|
+
SATISFYING = 0
|
36
|
+
TOLERATING = 1
|
37
|
+
FAILING = 2
|
38
|
+
|
39
|
+
def test_applied_correct_apdex_t_to_key_txn
|
40
|
+
TestWidget.new.key_txn
|
41
|
+
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
42
|
+
|
43
|
+
stats = $collector.reported_stats_for_metric('Apdex')[0]
|
44
|
+
assert_equal 1.0, stats[FAILING]
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_applied_correct_apdex_t_to_regular_txn
|
48
|
+
TestWidget.new.other_txn
|
49
|
+
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
50
|
+
|
51
|
+
stats = $collector.reported_stats_for_metric('Apdex')[0]
|
52
|
+
assert_equal 1.0, stats[SATISFYING]
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_applied_correct_tt_theshold
|
56
|
+
TestWidget.new.key_txn
|
57
|
+
TestWidget.new.other_txn
|
58
|
+
|
59
|
+
NewRelic::Agent.instance.send(:harvest_and_send_slowest_sample)
|
60
|
+
|
61
|
+
traces = $collector.calls_for('transaction_sample_data')
|
62
|
+
assert_equal 1, traces.size
|
63
|
+
assert_equal('Controller/KeyTransactionsTest::TestWidget/key_txn',
|
64
|
+
traces[0].metric_name)
|
65
|
+
end
|
66
|
+
end
|
@@ -41,31 +41,23 @@ class MarshalingTest < Test::Unit::TestCase
|
|
41
41
|
marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
|
42
42
|
end
|
43
43
|
|
44
|
-
assert_equal(666,
|
45
|
-
$collector.agent_data.select{|x| x.action == 'transaction_sample_data'}[0].body[0])
|
44
|
+
assert_equal('666', $collector.calls_for('transaction_sample_data')[0].run_id)
|
46
45
|
assert_equal(expected_sample.to_collector_array(marshaller.default_encoder),
|
47
|
-
$collector.
|
46
|
+
$collector.calls_for('transaction_sample_data')[0][1][0])
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_metric_data_marshalling
|
51
50
|
stats = NewRelic::Agent.instance.stats_engine.get_stats_no_scope('Custom/test/method')
|
52
51
|
stats.record_data_point(1.0)
|
53
52
|
stats.record_data_point(2.0, 1.0)
|
54
|
-
expected = [
|
55
|
-
[2, 3.0, 2.0, 1.0, 2.0, 5.0] ] ]
|
53
|
+
expected = [ 2, 3.0, 2.0, 1.0, 2.0, 5.0 ]
|
56
54
|
|
57
55
|
@agent.service.connect
|
58
56
|
@agent.send(:harvest_and_send_timeslice_data)
|
59
57
|
|
60
|
-
assert_equal(666,
|
61
|
-
$collector.agent_data.select{|x| x.action == 'metric_data'}[0].body[0])
|
58
|
+
assert_equal('666', $collector.calls_for('metric_data')[0].run_id)
|
62
59
|
|
63
|
-
|
64
|
-
.select{|x| x.action == 'metric_data'}[0].body[3]
|
65
|
-
assert metric_data
|
66
|
-
|
67
|
-
custom_metric = metric_data \
|
68
|
-
.select{|m| m[0]['name'] == 'Custom/test/method' }
|
60
|
+
custom_metric = $collector.reported_stats_for_metric('Custom/test/method')[0]
|
69
61
|
assert_equal(expected, custom_metric)
|
70
62
|
end
|
71
63
|
|
@@ -74,11 +66,9 @@ class MarshalingTest < Test::Unit::TestCase
|
|
74
66
|
@agent.service.connect
|
75
67
|
@agent.send(:harvest_and_send_errors)
|
76
68
|
|
77
|
-
assert_equal(666,
|
78
|
-
$collector.agent_data.select{|x| x.action == 'error_data'}[0].body[0])
|
69
|
+
assert_equal('666', $collector.calls_for('error_data')[0].run_id)
|
79
70
|
|
80
|
-
error_data = $collector.
|
81
|
-
.select{|x| x.action == 'error_data'}[0].body[1][0]
|
71
|
+
error_data = $collector.calls_for('error_data')[0][1][0]
|
82
72
|
assert_equal('test error', error_data[2])
|
83
73
|
end
|
84
74
|
|
@@ -92,8 +82,7 @@ class MarshalingTest < Test::Unit::TestCase
|
|
92
82
|
@agent.service.connect
|
93
83
|
@agent.send(:harvest_and_send_slowest_sql)
|
94
84
|
|
95
|
-
sql_data = $collector.
|
96
|
-
.select{|x| x.action == 'sql_trace_data'}[0].body[0]
|
85
|
+
sql_data = $collector.calls_for('sql_trace_data')[0][0]
|
97
86
|
assert_equal('select * from test', sql_data[0][3])
|
98
87
|
end
|
99
88
|
|
@@ -101,9 +90,7 @@ class MarshalingTest < Test::Unit::TestCase
|
|
101
90
|
@agent.service.connect('pid' => 1, 'agent_version' => '9000',
|
102
91
|
'app_name' => 'test')
|
103
92
|
|
104
|
-
connect_data = $collector.
|
105
|
-
.select{|x| x.action == 'connect'}[0].body[0]
|
93
|
+
connect_data = $collector.calls_for('connect')[0]
|
106
94
|
assert_equal '9000', connect_data['agent_version']
|
107
95
|
end
|
108
96
|
end
|
109
|
-
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class RenameRuleTest < Test::Unit::TestCase
|
2
|
+
class TestWidget
|
3
|
+
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
4
|
+
|
5
|
+
def txn
|
6
|
+
mthd
|
7
|
+
end
|
8
|
+
add_transaction_tracer :txn
|
9
|
+
|
10
|
+
def mthd
|
11
|
+
'doot de doo'
|
12
|
+
end
|
13
|
+
add_method_tracer :mthd
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
$collector ||= NewRelic::FakeCollector.new
|
18
|
+
$collector.reset
|
19
|
+
txn_rule_specs = [ { 'match_expression' => 'RenameRuleTest',
|
20
|
+
'replacement' => 'Class' } ]
|
21
|
+
metric_rule_specs = [ { 'match_expression' => 'RenameRuleTest',
|
22
|
+
'replacement' => 'Class' } ]
|
23
|
+
$collector.mock['connect'] = [200, {'return_value' => {
|
24
|
+
"agent_run_id" => 666,
|
25
|
+
'transaction_name_rules' => txn_rule_specs,
|
26
|
+
'metric_name_rules' => metric_rule_specs
|
27
|
+
}}]
|
28
|
+
$collector.run
|
29
|
+
|
30
|
+
NewRelic::Agent.manual_start(:sync_startup => true,
|
31
|
+
:force_reconnect => true)
|
32
|
+
TestWidget.new.txn
|
33
|
+
end
|
34
|
+
|
35
|
+
def teardown
|
36
|
+
NewRelic::Agent.shutdown
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_transaction_name_rules
|
40
|
+
metric_names = ::NewRelic::Agent.instance.stats_engine.metrics
|
41
|
+
assert(metric_names.include?('Controller/Class::TestWidget/txn'),
|
42
|
+
"'Controller/Class::TestWidget/txn' not found in #{metric_names}")
|
43
|
+
assert(metric_names.include?('Apdex/Class::TestWidget/txn'),
|
44
|
+
"'Apdex/Class::TestWidget/txn' not found in #{metric_names}")
|
45
|
+
assert(!metric_names.include?('Controller/RenameRuleTest::TestWidget/txn'),
|
46
|
+
"'Controller/RenameRuleTest::TestWidget/txn' should not be in #{metric_names}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_metric_name_rules
|
50
|
+
NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)
|
51
|
+
metric_names = $collector.calls_for('metric_data')[0].body[3].map{|m| m[0]['name']}
|
52
|
+
assert(metric_names.include?('Custom/Class::TestWidget/mthd'),
|
53
|
+
"'Custom/Class::TestWidget/mthd' not found in #{metric_names}")
|
54
|
+
assert(!metric_names.include?('Custom/RenameRuleTest::TestWidget/mthd'),
|
55
|
+
"'Custom/RenameRuleTest::TestWidget/mthd' should not be in #{metric_names}")
|
56
|
+
end
|
57
|
+
end
|