newrelic_rpm 3.8.0.218 → 3.8.1.221

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +32 -0
  3. data/README.md +4 -7
  4. data/Rakefile +3 -0
  5. data/lib/new_relic/agent.rb +3 -7
  6. data/lib/new_relic/agent/agent.rb +4 -14
  7. data/lib/new_relic/agent/agent_logger.rb +19 -11
  8. data/lib/new_relic/agent/autostart.rb +1 -1
  9. data/lib/new_relic/agent/configuration/default_source.rb +25 -12
  10. data/lib/new_relic/agent/configuration/manager.rb +14 -7
  11. data/lib/new_relic/agent/configuration/yaml_source.rb +39 -8
  12. data/lib/new_relic/agent/cross_app_monitor.rb +9 -7
  13. data/lib/new_relic/agent/cross_app_tracing.rb +6 -6
  14. data/lib/new_relic/agent/datastores/mongo.rb +6 -7
  15. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +32 -13
  16. data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +4 -3
  17. data/lib/new_relic/agent/error_collector.rb +2 -2
  18. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -69
  19. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
  20. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +77 -93
  22. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/mongo.rb +26 -42
  24. data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
  25. data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -1
  26. data/lib/new_relic/agent/javascript_instrumentor.rb +15 -6
  27. data/lib/new_relic/agent/method_tracer.rb +41 -92
  28. data/lib/new_relic/agent/request_sampler.rb +0 -1
  29. data/lib/new_relic/agent/rules_engine.rb +36 -12
  30. data/lib/new_relic/agent/shim_agent.rb +0 -1
  31. data/lib/new_relic/agent/sql_sampler.rb +8 -15
  32. data/lib/new_relic/agent/stats_engine.rb +2 -6
  33. data/lib/new_relic/agent/stats_engine/metric_stats.rb +8 -2
  34. data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
  35. data/lib/new_relic/agent/supported_versions.rb +1 -1
  36. data/lib/new_relic/agent/traced_method_stack.rb +87 -0
  37. data/lib/new_relic/agent/transaction.rb +277 -107
  38. data/lib/new_relic/agent/transaction_sample_builder.rb +2 -2
  39. data/lib/new_relic/agent/transaction_sampler.rb +18 -27
  40. data/lib/new_relic/agent/transaction_state.rb +15 -40
  41. data/lib/new_relic/control/instance_methods.rb +8 -4
  42. data/lib/new_relic/recipes.rb +3 -3
  43. data/lib/new_relic/transaction_sample.rb +3 -7
  44. data/lib/new_relic/version.rb +1 -1
  45. data/lib/sequel/extensions/newrelic_instrumentation.rb +3 -3
  46. data/newrelic_rpm.gemspec +15 -9
  47. data/test/agent_helper.rb +71 -36
  48. data/test/environments/norails/Gemfile +2 -0
  49. data/test/environments/rails21/Gemfile +2 -0
  50. data/test/environments/rails22/Gemfile +2 -0
  51. data/test/environments/rails23/Gemfile +2 -0
  52. data/test/environments/rails30/Gemfile +2 -0
  53. data/test/environments/rails31/Gemfile +2 -0
  54. data/test/environments/rails32/Gemfile +2 -0
  55. data/test/environments/rails40/Gemfile +2 -0
  56. data/test/environments/rails41/Gemfile +1 -0
  57. data/test/helpers/mongo_metric_builder.rb +1 -1
  58. data/test/multiverse/suites/agent_only/audit_log_test.rb +2 -2
  59. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +9 -1
  60. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -1
  61. data/test/multiverse/suites/agent_only/logging_test.rb +2 -2
  62. data/test/multiverse/suites/agent_only/marshaling_test.rb +8 -9
  63. data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +14 -1
  64. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +30 -13
  65. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +9 -8
  66. data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +43 -0
  67. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +77 -5
  68. data/test/multiverse/suites/excon/excon_test.rb +1 -1
  69. data/test/multiverse/suites/mongo/Envfile +4 -7
  70. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +55 -16
  71. data/test/multiverse/suites/mongo/helpers/mongo_server.rb +6 -4
  72. data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -2
  73. data/test/multiverse/suites/rails/error_tracing_test.rb +3 -1
  74. data/test/multiverse/suites/rails/request_statistics_test.rb +14 -14
  75. data/test/multiverse/suites/rails/transaction_ignoring_test.rb +45 -0
  76. data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +1 -1
  77. data/test/new_relic/agent/agent/connect_test.rb +4 -4
  78. data/test/new_relic/agent/agent_logger_test.rb +32 -0
  79. data/test/new_relic/agent/configuration/manager_test.rb +12 -4
  80. data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
  81. data/test/new_relic/agent/cross_app_monitor_test.rb +6 -2
  82. data/test/new_relic/agent/cross_app_tracing_test.rb +5 -5
  83. data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +7 -6
  84. data/test/new_relic/agent/error_collector_test.rb +1 -2
  85. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +24 -11
  86. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +2 -2
  87. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +12 -17
  88. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +43 -32
  89. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +3 -4
  90. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +36 -20
  91. data/test/new_relic/agent/javascript_instrumentor_test.rb +1 -2
  92. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +15 -26
  93. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +66 -103
  94. data/test/new_relic/agent/method_tracer_test.rb +2 -2
  95. data/test/new_relic/agent/mock_scope_listener.rb +3 -6
  96. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -4
  97. data/test/new_relic/agent/rules_engine_test.rb +13 -0
  98. data/test/new_relic/agent/sql_sampler_test.rb +8 -10
  99. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +18 -0
  100. data/test/new_relic/agent/stats_engine_test.rb +0 -173
  101. data/test/new_relic/agent/threading/agent_thread_test.rb +27 -26
  102. data/test/new_relic/agent/traced_method_stack_test.rb +139 -0
  103. data/test/new_relic/agent/transaction_sample_builder_test.rb +2 -12
  104. data/test/new_relic/agent/transaction_sampler_test.rb +98 -107
  105. data/test/new_relic/agent/transaction_state_test.rb +52 -61
  106. data/test/new_relic/agent/transaction_test.rb +209 -140
  107. data/test/new_relic/agent_test.rb +3 -2
  108. data/test/new_relic/control_test.rb +10 -9
  109. data/test/new_relic/fake_collector.rb +34 -2
  110. data/test/new_relic/http_client_test_cases.rb +0 -5
  111. data/test/new_relic/license_test.rb +4 -2
  112. data/test/new_relic/local_environment_test.rb +14 -28
  113. data/test/new_relic/multiverse_helpers.rb +2 -2
  114. data/test/new_relic/rack/developer_mode_test.rb +4 -5
  115. data/test/new_relic/transaction_ignoring_test_cases.rb +104 -0
  116. data/test/new_relic/transaction_sample_test.rb +14 -7
  117. data/test/performance/lib/performance/instrumentation/gc_stats.rb +6 -3
  118. data/test/performance/suites/transaction_tracing.rb +4 -1
  119. data/test/test_helper.rb +31 -60
  120. data/ui/views/newrelic/show_sample.rhtml +1 -1
  121. metadata +46 -101
  122. metadata.gz.sig +0 -0
  123. data/lib/new_relic/agent/stats_engine/transactions.rb +0 -114
  124. data/lib/new_relic/agent/transaction/pop.rb +0 -52
  125. data/test/new_relic/agent/transaction/pop_test.rb +0 -79
@@ -168,7 +168,7 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
168
168
 
169
169
  def test_config_data_for_js_agent
170
170
  freeze_time
171
- in_transaction do
171
+ in_transaction('most recent transaction') do
172
172
  with_config(CAPTURE_ATTRIBUTES => true) do
173
173
  NewRelic::Agent.set_user_attributes(:user => "user")
174
174
 
@@ -176,7 +176,6 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
176
176
  txn.stubs(:queue_time).returns(0)
177
177
  txn.stubs(:start_time).returns(Time.now - 10)
178
178
  txn.stubs(:guid).returns('ABC')
179
- txn.name = 'most recent transaction'
180
179
 
181
180
  state = NewRelic::Agent::TransactionState.get
182
181
  state.request_token = '0123456789ABCDEF'
@@ -16,7 +16,7 @@ module NewRelic
16
16
 
17
17
  def test_validate_options_nonhash
18
18
  assert_raises(TypeError) do
19
- validate_options([])
19
+ validate_options(:fluttershy, [])
20
20
  end
21
21
  end
22
22
 
@@ -24,14 +24,14 @@ module NewRelic
24
24
  self.expects(:check_for_illegal_keys!)
25
25
  self.expects(:set_deduct_call_time_based_on_metric).with(DEFAULT_SETTINGS)
26
26
  self.expects(:check_for_push_scope_and_metric)
27
- validate_options({})
27
+ validate_options(:applejack, {})
28
28
  end
29
29
 
30
30
  def test_validate_options_override
31
31
  opts = {:push_scope => false, :metric => false, :force => true}
32
32
  self.expects(:check_for_illegal_keys!)
33
33
  self.expects(:check_for_push_scope_and_metric)
34
- val = validate_options(opts)
34
+ val = validate_options(:pinkie_pie, opts)
35
35
  assert val.is_a?(Hash)
36
36
  assert (val[:push_scope] == false), val.inspect
37
37
  assert (val[:metric] == false), val.inspect
@@ -82,31 +82,25 @@ module NewRelic
82
82
  assert !val[:deduct_call_time_from_parent]
83
83
  end
84
84
 
85
- def test_unrecognized_keys_positive
86
- assert_equal [:unrecognized, :keys].to_set, unrecognized_keys([:hello, :world], {:unrecognized => nil, :keys => nil}).to_set
87
- end
88
-
89
- def test_unrecognized_keys_negative
90
- assert_equal [], unrecognized_keys([:hello, :world], {:hello => nil, :world => nil})
91
- end
92
-
93
- def test_any_unrecognized_keys_positive
94
- assert any_unrecognized_keys?([:one], {:one => nil, :two => nil})
95
- end
96
-
97
- def test_any_unrecognized_keys_negative
98
- assert !any_unrecognized_keys?([:one], {:one => nil})
99
- end
100
-
101
85
  def test_check_for_illegal_keys_positive
102
86
  assert_raises(RuntimeError) do
103
- check_for_illegal_keys!({:unknown_key => nil})
87
+ check_for_illegal_keys!(:twilight_sparkle, {:unknown_key => nil})
104
88
  end
105
89
  end
106
90
 
107
91
  def test_check_for_illegal_keys_negative
108
92
  test_keys = Hash[*ALLOWED_KEYS.map {|x| [x, nil]}.flatten]
109
- check_for_illegal_keys!(test_keys)
93
+ check_for_illegal_keys!(:rainbow_dash, test_keys)
94
+ end
95
+
96
+ def test_check_for_illegal_keys_deprecated
97
+ log = with_array_logger do
98
+ check_for_illegal_keys!(:rarity, :force => true)
99
+ end.array
100
+
101
+ assert_equal(1, log.size)
102
+
103
+ assert_match(/Deprecated options when adding method tracer to rarity: force/, log[0])
110
104
  end
111
105
 
112
106
  def test_traced_method_exists_positive
@@ -121,11 +115,6 @@ module NewRelic
121
115
  assert !traced_method_exists?(nil, nil)
122
116
  end
123
117
 
124
- def test_assemble_code_header_forced
125
- opts = {:force => true, :code_header => 'CODE HEADER'}
126
- assert_equal "CODE HEADER", assemble_code_header('test_method', 'Custom/Test/test_method', opts)
127
- end
128
-
129
118
  def test_assemble_code_header_unforced
130
119
  self.expects(:_untraced_method_name).returns("method_name_without_tracing")
131
120
  opts = {:force => false, :code_header => 'CODE HEADER'}
@@ -11,24 +11,6 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
11
11
  NewRelic::Agent.agent.stats_engine.clear_stats
12
12
  end
13
13
 
14
- def test_trace_disabled_negative
15
- self.expects(:traced?).returns(false)
16
- options = {:force => false}
17
- assert trace_disabled?(options)
18
- end
19
-
20
- def test_trace_disabled_forced
21
- self.expects(:traced?).returns(false)
22
- options = {:force => true}
23
- assert !(trace_disabled?(options))
24
- end
25
-
26
- def test_trace_disabled_positive
27
- self.expects(:traced?).returns(true)
28
- options = {:force => false}
29
- assert !(trace_disabled?(options))
30
- end
31
-
32
14
  def test_get_stats_unscoped
33
15
  fake_engine = mocked_object('stat_engine')
34
16
  fake_engine.expects(:get_stats_no_scope).with('foob').returns('fakestats')
@@ -64,29 +46,26 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
64
46
  )
65
47
  end
66
48
 
67
- def test_metric_recording_in_root_transaction
68
- options = { :transaction => true }
69
- self.stubs(:has_parent?).returns(false)
70
-
49
+ def test_metric_recording_in_non_nested_transaction
71
50
  in_transaction('outer') do
72
- trace_execution_scoped(['foo', 'bar'], options) do
51
+ trace_execution_scoped(['foo', 'bar']) do
73
52
  # erm
74
53
  end
75
54
  end
76
55
 
77
56
  expected_values = { :call_count => 1 }
78
57
  assert_metrics_recorded_exclusive(
79
- 'foo' => expected_values,
80
- 'bar' => expected_values
58
+ ['foo', 'outer'] => expected_values,
59
+ 'foo' => expected_values,
60
+ 'bar' => expected_values,
61
+ 'outer' => expected_values
81
62
  )
82
63
  end
83
64
 
84
- def test_metric_recording_in_non_root_transaction
85
- options = { :transaction => true }
86
- self.stubs(:has_parent?).returns(true)
87
- in_transaction('outer') do
88
- in_transaction('inner') do
89
- trace_execution_scoped(['inner', 'bar'], options) do
65
+ def test_metric_recording_in_nested_transactions
66
+ in_transaction('Controller/outer_txn') do
67
+ in_transaction('Controller/inner_txn') do
68
+ trace_execution_scoped(['foo', 'bar']) do
90
69
  # erm
91
70
  end
92
71
  end
@@ -94,42 +73,47 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
94
73
 
95
74
  expected_values = { :call_count => 1 }
96
75
  assert_metrics_recorded_exclusive(
97
- 'inner' => expected_values,
98
- ['inner', 'outer'] => expected_values,
99
- 'bar' => expected_values
76
+ 'HttpDispatcher' => expected_values,
77
+ 'Controller/inner_txn' => expected_values,
78
+
79
+ 'Nested/Controller/inner_txn' => expected_values,
80
+ ['Nested/Controller/inner_txn', 'Controller/inner_txn'] => expected_values,
81
+ 'Nested/Controller/outer_txn' => expected_values,
82
+ ['Nested/Controller/outer_txn', 'Controller/inner_txn'] => expected_values,
83
+
84
+ ['foo' , 'Controller/inner_txn'] => expected_values,
85
+ 'foo' => expected_values,
86
+ 'bar' => expected_values
100
87
  )
101
88
  end
102
89
 
103
- def test_metric_recording_in_root_non_transaction
104
- options = { :transaction => false }
105
- self.stubs(:has_parent?).returns(false)
106
-
107
- in_transaction('outer') do
108
- trace_execution_scoped(['foo', 'bar'], options) do
109
- # erm
90
+ def test_metric_recording_in_3_nested_transactions
91
+ in_transaction('Controller/outer_txn') do
92
+ in_transaction('Controller/middle_txn') do
93
+ in_transaction('Controller/inner_txn') do
94
+ # erm
95
+ end
110
96
  end
111
97
  end
112
98
 
113
- expected_values = { :call_count => 1 }
114
- assert_metrics_recorded_exclusive(
115
- 'foo' => expected_values,
116
- ['foo', 'outer'] => expected_values,
117
- 'bar' => expected_values
118
- )
99
+ assert_metrics_recorded([
100
+ 'Controller/inner_txn',
101
+ 'Nested/Controller/inner_txn',
102
+ 'Nested/Controller/middle_txn',
103
+ 'Nested/Controller/outer_txn'
104
+ ])
119
105
  end
120
106
 
121
- def test_metric_recording_in_non_root_non_transaction
122
- options = { :transaction => false }
123
- self.stubs(:has_parent?).returns(false)
124
-
107
+ def test_metric_recording_inside_transaction
125
108
  in_transaction('outer') do
126
- trace_execution_scoped(['foo', 'bar'], options) do
109
+ trace_execution_scoped(['foo', 'bar']) do
127
110
  # erm
128
111
  end
129
112
  end
130
113
 
131
114
  expected_values = { :call_count => 1 }
132
115
  assert_metrics_recorded_exclusive(
116
+ 'outer' => expected_values,
133
117
  'foo' => expected_values,
134
118
  ['foo', 'outer'] => expected_values,
135
119
  'bar' => expected_values
@@ -137,8 +121,7 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
137
121
  end
138
122
 
139
123
  def test_metric_recording_without_metric_option
140
- options = { :metric => false, :transaction => true }
141
- self.stubs(:has_parent?).returns(false)
124
+ options = { :metric => false, :scoped_metric => false }
142
125
 
143
126
  in_transaction('outer') do
144
127
  trace_execution_scoped(['foo', 'bar'], options) do
@@ -148,13 +131,13 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
148
131
 
149
132
  expected_values = { :call_count => 1 }
150
133
  assert_metrics_recorded_exclusive(
151
- 'bar' => expected_values
134
+ 'outer' => expected_values,
135
+ 'bar' => expected_values
152
136
  )
153
137
  end
154
138
 
155
139
  def test_metric_recording_with_scoped_metric_only_option
156
- options = { :transaction => false, :scoped_metric_only => true }
157
- self.stubs(:has_parent?).returns(false)
140
+ options = { :scoped_metric_only => true }
158
141
 
159
142
  in_transaction('outer') do
160
143
  trace_execution_scoped(['foo', 'bar'], options) do
@@ -164,6 +147,7 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
164
147
 
165
148
  expected_values = { :call_count => 1 }
166
149
  assert_metrics_recorded_exclusive(
150
+ 'outer' => expected_values,
167
151
  ['foo', 'outer'] => expected_values
168
152
  )
169
153
  end
@@ -177,28 +161,6 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
177
161
  assert !h[:bar]
178
162
  end
179
163
 
180
- def test_push_flag_true
181
- fake_agent = mocked_object('agent_instance')
182
- fake_agent.expects(:push_trace_execution_flag).with(true)
183
- push_flag!(true)
184
- end
185
-
186
- def test_push_flag_false
187
- self.expects(:agent_instance).never
188
- push_flag!(false)
189
- end
190
-
191
- def test_pop_flag_true
192
- fake_agent = mocked_object('agent_instance')
193
- fake_agent.expects(:pop_trace_execution_flag)
194
- pop_flag!(true)
195
- end
196
-
197
- def test_pop_flag_false
198
- self.expects(:agent_instance).never
199
- pop_flag!(false)
200
- end
201
-
202
164
  def test_log_errors_base
203
165
  ran = false
204
166
  log_errors("name") do
@@ -231,9 +193,7 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
231
193
  def test_trace_execution_scoped_header
232
194
  options = {:force => false, :deduct_call_time_from_parent => false}
233
195
  self.expects(:log_errors).with('trace_execution_scoped header').yields
234
- self.expects(:push_flag!).with(false)
235
- fakestats = mocked_object('stat_engine')
236
- fakestats.expects(:push_scope).with(:method_tracer, 1.0, false)
196
+ NewRelic::Agent::TracedMethodStack.expects(:push_frame).with(:method_tracer, 1.0, false)
237
197
  trace_execution_scoped_header(options, 1.0)
238
198
  end
239
199
 
@@ -249,31 +209,34 @@ class NewRelic::Agent::MethodTracer::TraceExecutionScopedTest < Minitest::Test
249
209
  end
250
210
 
251
211
  assert_metrics_recorded_exclusive(
252
- 'parent' => { :call_count => 1, :total_call_time => 20, :total_exclusive_time => 10 },
253
- ['parent', 'txn'] => { :call_count => 1, :total_call_time => 20, :total_exclusive_time => 10 },
254
- 'child' => { :call_count => 1, :total_call_time => 10, :total_exclusive_time => 10 },
255
- ['child', 'txn'] => { :call_count => 1, :total_call_time => 10, :total_exclusive_time => 10 }
212
+ 'txn' => {
213
+ :call_count => 1,
214
+ },
215
+ 'parent' => {
216
+ :call_count => 1,
217
+ :total_call_time => 20,
218
+ :total_exclusive_time => 10,
219
+ },
220
+ ['parent', 'txn'] => {
221
+ :call_count => 1,
222
+ :total_call_time => 20,
223
+ :total_exclusive_time => 10,
224
+ },
225
+ 'child' => {
226
+ :call_count => 1,
227
+ :total_call_time => 10,
228
+ :total_exclusive_time => 10,
229
+ },
230
+ ['child', 'txn'] => {
231
+ :call_count => 1,
232
+ :total_call_time => 10,
233
+ :total_exclusive_time => 10,
234
+ }
256
235
  )
257
236
  end
258
237
 
259
- def test_force_flag_enables_metric_recording_in_ignored_transaction
260
- NewRelic::Agent.instance.push_trace_execution_flag(false)
261
- in_transaction('txn') do
262
- trace_execution_scoped(['foo'], :force => true) do
263
- # whatever, man
264
- end
265
- end
266
-
267
- assert_metrics_recorded_exclusive(
268
- 'foo' => { :call_count => 1 },
269
- ['foo', 'txn'] => { :call_count => 1 }
270
- )
271
- ensure
272
- NewRelic::Agent.instance.pop_trace_execution_flag()
273
- end
274
-
275
238
  def test_trace_execution_scoped_disabled
276
- self.expects(:trace_disabled?).returns(true)
239
+ self.expects(:traced?).returns(false)
277
240
  # make sure the method doesn't beyond the abort
278
241
  self.expects(:set_if_nil).never
279
242
  ran = false
@@ -26,9 +26,9 @@ class Insider
26
26
  # sampler = NewRelic::Agent::TransactionSampler.new(NewRelic::Agent.instance)
27
27
  sampler = "<none>"
28
28
  begin
29
- @stats_engine.transaction_sampler = sampler
30
29
  fail "This should not have worked."
31
- rescue; end
30
+ rescue
31
+ end
32
32
  else
33
33
  thrower(level-1)
34
34
  end
@@ -11,17 +11,14 @@ class NewRelic::Agent::MockScopeListener
11
11
  @scopes = []
12
12
  end
13
13
 
14
- def notice_first_scope_push(time)
14
+ def notice_push_frame(time)
15
15
  end
16
16
 
17
- def notice_push_scope(time)
18
- end
19
-
20
- def notice_pop_scope(scope, time)
17
+ def notice_pop_frame(scope, time)
21
18
  @scopes << scope
22
19
  end
23
20
 
24
- def notice_scope_empty(time)
21
+ def on_finishing_transaction(time)
25
22
  end
26
23
 
27
24
  def enabled?
@@ -57,14 +57,14 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
57
57
 
58
58
  def test_listener_merges_transaction_traces
59
59
  sampler = NewRelic::Agent.agent.transaction_sampler
60
- sample = run_sample_trace_on(sampler)
60
+ sample = run_sample_trace
61
61
  assert_equal(1, sampler.count)
62
62
 
63
63
  listener = start_listener_with_pipe(667)
64
64
  run_child(667) do
65
65
  NewRelic::Agent.after_fork
66
66
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
67
- sample = run_sample_trace_on(sampler)
67
+ sample = run_sample_trace
68
68
  service = NewRelic::Agent::PipeService.new(667)
69
69
  service.transaction_sample_data(sampler.harvest!)
70
70
  end
@@ -172,9 +172,9 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
172
172
  end
173
173
 
174
174
  def create_sql_sample(sampler)
175
- sampler.notice_first_scope_push(Time.now)
175
+ sampler.on_start_transaction(Time.now)
176
176
  sampler.notice_sql("SELECT * FROM table", "ActiveRecord/Widgets/find", nil, 100)
177
- sampler.notice_scope_empty('noodles', Time.now)
177
+ sampler.on_finishing_transaction('noodles', Time.now)
178
178
  end
179
179
  end
180
180
 
@@ -89,4 +89,17 @@ class RulesEngineTest < Minitest::Test
89
89
 
90
90
  assert_equal('foo/*/bar/*', @engine.rename('foo/1/bar/22'))
91
91
  end
92
+
93
+ load_cross_agent_test('rules').each do |testcase|
94
+ define_method("test_#{testcase['testname']}") do
95
+ testcase["rules"].each do |rule|
96
+ @engine << NewRelic::Agent::RulesEngine::Rule.new(rule)
97
+ end
98
+
99
+ testcase["tests"].each do |test|
100
+ assert_equal(test["expected"], @engine.rename(test["input"]), "Input: #{test['input'].inspect}")
101
+ end
102
+ end
103
+ end
104
+
92
105
  end
@@ -23,9 +23,9 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
23
23
 
24
24
  def populate_container(sampler, n)
25
25
  n.times do |i|
26
- sampler.notice_first_scope_push nil
26
+ sampler.on_start_transaction nil
27
27
  sampler.notice_sql("SELECT * FROM test#{i}", "Database/test/select", nil, 1)
28
- sampler.notice_scope_empty('txn')
28
+ sampler.on_finishing_transaction('txn')
29
29
  end
30
30
  end
31
31
 
@@ -33,11 +33,11 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
33
33
 
34
34
  # Tests
35
35
 
36
- def test_notice_first_scope_push
36
+ def test_on_start_transaction
37
37
  assert_nil @sampler.transaction_data
38
- @sampler.notice_first_scope_push nil
38
+ @sampler.on_start_transaction nil
39
39
  refute_nil @sampler.transaction_data
40
- @sampler.notice_scope_empty('txn')
40
+ @sampler.on_finishing_transaction('txn')
41
41
  assert_nil @sampler.transaction_data
42
42
  end
43
43
 
@@ -47,7 +47,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
47
47
  end
48
48
 
49
49
  def test_notice_sql
50
- @sampler.notice_first_scope_push nil
50
+ @sampler.on_start_transaction nil
51
51
  @sampler.notice_sql "select * from test", "Database/test/select", nil, 1.5
52
52
  @sampler.notice_sql "select * from test2", "Database/test2/select", nil, 1.3
53
53
  # this sql will not be captured
@@ -57,7 +57,7 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
57
57
  end
58
58
 
59
59
  def test_notice_sql_truncates_query
60
- @sampler.notice_first_scope_push nil
60
+ @sampler.on_start_transaction nil
61
61
  message = 'a' * 17_000
62
62
  @sampler.notice_sql(message, "Database/test/select", nil, 1.5)
63
63
  assert_equal('a' * 16_381 + '...', @sampler.transaction_data.sql_data[0].sql)
@@ -174,10 +174,8 @@ class NewRelic::Agent::SqlSamplerTest < Minitest::Test
174
174
 
175
175
  def test_sql_trace_should_include_transaction_guid
176
176
  txn_sampler = NewRelic::Agent::TransactionSampler.new
177
- NewRelic::Agent.instance.stats_engine.transaction_sampler = txn_sampler
178
177
  txn_sampler.start_builder(Time.now)
179
- @sampler.create_transaction_data
180
- @sampler.notice_transaction('a uri', {:some => :params})
178
+ @sampler.on_start_transaction(Time.now, 'a uri', {:some => :params})
181
179
 
182
180
  assert_equal(NewRelic::Agent.instance.transaction_sampler.builder.sample.guid,
183
181
  NewRelic::Agent.instance.sql_sampler.transaction_data.guid)