newrelic_rpm 3.15.2.317 → 3.16.0.318

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +23 -0
  3. data/lib/new_relic/agent.rb +0 -3
  4. data/lib/new_relic/agent/agent.rb +29 -34
  5. data/lib/new_relic/agent/attribute_filter.rb +2 -0
  6. data/lib/new_relic/agent/configuration/default_source.rb +50 -4
  7. data/lib/new_relic/agent/database/obfuscation_helpers.rb +3 -2
  8. data/lib/new_relic/agent/hash_extensions.rb +16 -1
  9. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +82 -0
  10. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +9 -8
  11. data/lib/new_relic/agent/instrumentation/rails5/action_cable.rb +29 -0
  12. data/lib/new_relic/agent/new_relic_service.rb +12 -4
  13. data/lib/new_relic/agent/new_relic_service/encoders.rb +19 -3
  14. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +5 -1
  15. data/lib/new_relic/agent/supported_versions.rb +1 -1
  16. data/lib/new_relic/agent/transaction.rb +2 -1
  17. data/lib/new_relic/agent/transaction/request_attributes.rb +15 -0
  18. data/lib/new_relic/agent/utilization_data.rb +45 -1
  19. data/lib/new_relic/recipes/capistrano3.rb +44 -34
  20. data/lib/new_relic/version.rb +2 -2
  21. data/lib/tasks/versions.preface.html +7 -1
  22. data/lib/tasks/versions.rake +1 -1
  23. data/newrelic_rpm.gemspec +1 -0
  24. data/test/fixtures/cross_agent_tests/README.md +10 -32
  25. data/test/fixtures/cross_agent_tests/aws.json +2 -2
  26. data/test/fixtures/cross_agent_tests/rum_client_config.json +33 -4
  27. data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +1 -0
  28. data/test/fixtures/cross_agent_tests/utilization/README.md +13 -0
  29. data/test/fixtures/cross_agent_tests/utilization/utilization_json.json +132 -0
  30. data/test/multiverse/suites/agent_only/agent_attributes_test.rb +82 -0
  31. data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +2 -9
  32. data/test/multiverse/suites/rails/Envfile +1 -1
  33. data/test/multiverse/suites/rails/action_cable_test.rb +81 -0
  34. data/test/new_relic/agent/agent_test.rb +0 -1
  35. data/test/new_relic/agent/hash_extensions_test.rb +26 -1
  36. data/test/new_relic/agent/instrumentation/action_cable_subscriber_test.rb +124 -0
  37. data/test/new_relic/agent/method_tracer_test.rb +0 -1
  38. data/test/new_relic/agent/new_relic_service/json_marshaller_test.rb +27 -0
  39. data/test/new_relic/agent/utilization_data_test.rb +86 -0
  40. metadata +10 -4
  41. data/lib/new_relic/agent/transction_event_recorder.rb +0 -35
@@ -33,3 +33,4 @@ SQL Syntax Documentation:
33
33
  * [PostgreSQL](http://www.postgresql.org/docs/8.4/static/sql-syntax.html)
34
34
  * [Cassandra](http://docs.datastax.com/en/cql/3.1/cql/cql_reference/cql_lexicon_c.html)
35
35
  * [Oracle](http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/langelems.htm)
36
+ * [SQLite](https://www.sqlite.org/lang.html)
@@ -0,0 +1,13 @@
1
+ # The Utilization Tests
2
+
3
+ The Utilization tests ensure that the appropriate information is being gathered for pricing. It is centered around ensuring the JSON is correct. Each JSON block is a test case, with potentially the following fields:
4
+
5
+ - testname: The name of the test
6
+ - input_total_ram_mib: The total ram number calculated by the agent.
7
+ - input_logical_processors: The number of logical processors calculated by the agent.
8
+ - input_hostname: The hostname calculated by the agent.
9
+ - input_aws_id: The aws id determined by the agent.
10
+ - input_aws_type: The aws type determined by the agent.
11
+ - input_aws_zone: The aws zone determined by the agent.
12
+ - input_environment_variables: Any environment variables which have been set.
13
+ - expected_output_json: The expected JSON output from the agent for the utilization hash.
@@ -0,0 +1,132 @@
1
+ [
2
+ {
3
+ "testname":"only agent derived data",
4
+ "input_total_ram_mib": 1024,
5
+ "input_logical_processors": 8,
6
+ "input_hostname": "myhost",
7
+ "expected_output_json": {
8
+ "metadata_version":2,
9
+ "logical_processors":8,
10
+ "total_ram_mib":1024,
11
+ "hostname":"myhost"
12
+ }
13
+ },
14
+ {
15
+ "testname":"only agent derived data with aws",
16
+ "input_total_ram_mib": 2048,
17
+ "input_logical_processors": 8,
18
+ "input_hostname": "myotherhost",
19
+ "input_aws_id": "8BADFOOD",
20
+ "input_aws_type": "t2.micro",
21
+ "input_aws_zone": "us-west-1",
22
+ "expected_output_json": {
23
+ "metadata_version":2,
24
+ "logical_processors":8,
25
+ "total_ram_mib":2048,
26
+ "hostname":"myotherhost",
27
+ "vendors": {
28
+ "aws": {
29
+ "id":"8BADFOOD",
30
+ "type":"t2.micro",
31
+ "zone":"us-west-1"
32
+ }
33
+ }
34
+ }
35
+ },
36
+ {
37
+ "testname":"only agent derived but bad data",
38
+ "input_total_ram_mib": null,
39
+ "input_logical_processors": null,
40
+ "input_hostname": "myotherhost",
41
+ "expected_output_json": {
42
+ "metadata_version": 2,
43
+ "logical_processors":null,
44
+ "total_ram_mib":null,
45
+ "hostname":"myotherhost"
46
+ }
47
+ },
48
+ {
49
+ "testname":"agent derived null and so environment variables",
50
+ "input_total_ram_mib": null,
51
+ "input_logical_processors": null,
52
+ "input_hostname": "myotherhost",
53
+ "input_environment_variables": {
54
+ "NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS": 8,
55
+ "NEW_RELIC_UTILIZATION_TOTAL_RAM_MIB" : 2048
56
+ },
57
+ "expected_output_json": {
58
+ "metadata_version": 2,
59
+ "logical_processors":null,
60
+ "total_ram_mib":null,
61
+ "hostname":"myotherhost",
62
+ "config" : {
63
+ "logical_processors": 8,
64
+ "total_ram_mib": 2048
65
+ }
66
+ }
67
+ },
68
+ {
69
+ "testname":"all environment variables",
70
+ "input_total_ram_mib": 1,
71
+ "input_logical_processors": 2,
72
+ "input_hostname": "myotherhost",
73
+ "input_environment_variables": {
74
+ "NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS": 16,
75
+ "NEW_RELIC_UTILIZATION_TOTAL_RAM_MIB" : 4096,
76
+ "NEW_RELIC_UTILIZATION_BILLING_HOSTNAME" : "localhost"
77
+ },
78
+ "expected_output_json": {
79
+ "metadata_version": 2,
80
+ "logical_processors":2,
81
+ "total_ram_mib":1,
82
+ "hostname":"myotherhost",
83
+ "config" : {
84
+ "logical_processors": 16,
85
+ "total_ram_mib": 4096,
86
+ "hostname": "localhost"
87
+ }
88
+ }
89
+ },
90
+ {
91
+ "testname":"all environment variables with error in processors",
92
+ "input_total_ram_mib": 1024,
93
+ "input_logical_processors": 4,
94
+ "input_hostname": "myotherhost",
95
+ "input_environment_variables": {
96
+ "NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS": "abc",
97
+ "NEW_RELIC_UTILIZATION_TOTAL_RAM_MIB" : 4096,
98
+ "NEW_RELIC_UTILIZATION_BILLING_HOSTNAME" : "localhost"
99
+ },
100
+ "expected_output_json": {
101
+ "metadata_version": 2,
102
+ "logical_processors":4,
103
+ "total_ram_mib":1024,
104
+ "hostname":"myotherhost",
105
+ "config" : {
106
+ "total_ram_mib": 4096,
107
+ "hostname": "localhost"
108
+ }
109
+ }
110
+ },
111
+ {
112
+ "testname":"all environment variables with error in ram",
113
+ "input_total_ram_mib": 1024,
114
+ "input_logical_processors": 4,
115
+ "input_hostname": "myotherhost",
116
+ "input_environment_variables": {
117
+ "NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS": 8,
118
+ "NEW_RELIC_UTILIZATION_TOTAL_RAM_MIB" : "notgood",
119
+ "NEW_RELIC_UTILIZATION_BILLING_HOSTNAME" : "localhost"
120
+ },
121
+ "expected_output_json": {
122
+ "metadata_version": 2,
123
+ "logical_processors":4,
124
+ "total_ram_mib":1024,
125
+ "hostname":"myotherhost",
126
+ "config" : {
127
+ "logical_processors": 8,
128
+ "hostname": "localhost"
129
+ }
130
+ }
131
+ }
132
+ ]
@@ -214,6 +214,88 @@ class AgentAttributesTest < Minitest::Test
214
214
  assert_browser_monitoring_has_agent_attribute("request.parameters.bar", "baz")
215
215
  end
216
216
 
217
+ def test_request_uri_captured_on_transaction_events_when_enabled
218
+ config = {:'transaction_events.attributes.include' => 'request_uri'}
219
+ txn_options = {
220
+ :request => stub(:path => "/foobar")
221
+ }
222
+ run_transaction(config, txn_options)
223
+
224
+ assert_event_has_agent_attribute("request_uri", "/foobar")
225
+ refute_error_has_agent_attribute("request_uri")
226
+ refute_transaction_trace_has_agent_attribute("request_uri")
227
+ refute_browser_monitoring_has_agent_attribute("request_uri")
228
+ end
229
+
230
+ def test_request_uri_excluded_by_default
231
+ config = {:'transaction_events.attributes.include' => ''}
232
+ txn_options = {
233
+ :request => stub(:path => "/foobar")
234
+ }
235
+ run_transaction(config, txn_options)
236
+
237
+ refute_event_has_agent_attribute("request_uri")
238
+ refute_error_has_agent_attribute("request_uri")
239
+ refute_transaction_trace_has_agent_attribute("request_uri")
240
+ refute_browser_monitoring_has_agent_attribute("request_uri")
241
+ end
242
+
243
+ def test_request_uri_not_captured_on_transaction_traces
244
+ config = {:'transaction_tracer.attributes.include' => 'request_uri'}
245
+ txn_options = {
246
+ :request => stub(:path => "/foobar")
247
+ }
248
+ run_transaction(config, txn_options)
249
+
250
+ refute_transaction_trace_has_agent_attribute("request_uri")
251
+ end
252
+
253
+ def test_request_uri_not_captured_on_error_traces
254
+ config = {:'error_collector.attributes.include' => 'request_uri'}
255
+ txn_options = {
256
+ :request => stub(:path => "/foobar")
257
+ }
258
+ run_transaction(config, txn_options)
259
+
260
+ refute_error_has_agent_attribute("request_uri")
261
+ end
262
+
263
+ def test_request_uri_not_captured_on_traces_if_only_configured_as_general_attribute
264
+ config = {:'attributes.include' => 'request_uri'}
265
+ txn_options = {
266
+ :request => stub(:path => "/foobar")
267
+ }
268
+ run_transaction(config, txn_options)
269
+
270
+ refute_transaction_trace_has_agent_attribute("request_uri")
271
+ refute_error_has_agent_attribute("request_uri")
272
+ refute_event_has_agent_attribute("request_uri")
273
+ end
274
+
275
+ def test_request_uri_only_included_on_transaction_events_with_attributes_include_wildcard
276
+ config = { :'attributes.include' => '*',
277
+ :'transaction_events.attributes.include' => 'request_uri'}
278
+
279
+ txn_options = {
280
+ :request => stub(:path => "/foobar")
281
+ }
282
+ run_transaction(config, txn_options)
283
+
284
+ assert_event_has_agent_attribute("request_uri", "/foobar")
285
+ refute_transaction_trace_has_agent_attribute("request_uri")
286
+ refute_error_has_agent_attribute("request_uri")
287
+ end
288
+
289
+ def test_request_uri_captured_with_wildcard
290
+ config = {:'transaction_events.attributes.include' => '*'}
291
+ txn_options = {
292
+ :request => stub(:path => "/foobar")
293
+ }
294
+ run_transaction(config, txn_options)
295
+
296
+ assert_event_has_agent_attribute("request_uri", "/foobar")
297
+ end
298
+
217
299
  def test_http_response_code_excluded_in_txn_events_when_disabled
218
300
  with_config(:'transaction_events.attributes.exclude' => 'httpResponseCode') do
219
301
  in_web_transaction do |txn|
@@ -11,7 +11,7 @@ class UtilizationDataCollectionTest < Minitest::Test
11
11
  def test_sends_all_utilization_data_on_connect
12
12
  expected = {
13
13
  "hostname" => "host",
14
- "metadata_version" => 1,
14
+ "metadata_version" => 2,
15
15
  "logical_processors" => 5,
16
16
  "total_ram_mib" => 128,
17
17
  "vendors" => {
@@ -46,7 +46,7 @@ class UtilizationDataCollectionTest < Minitest::Test
46
46
  def test_omits_sending_vendor_data_on_connect_when_not_available
47
47
  expected = {
48
48
  "hostname" => "host",
49
- "metadata_version" => 1,
49
+ "metadata_version" => 2,
50
50
  "logical_processors" => 5,
51
51
  "total_ram_mib" => 128
52
52
  }
@@ -63,13 +63,6 @@ class UtilizationDataCollectionTest < Minitest::Test
63
63
  assert_equal expected, single_connect_posted.utilization
64
64
  end
65
65
 
66
- def test_utilization_data_not_sent_when_disabled
67
- with_config :disable_utilization => true do
68
- setup_agent
69
- assert_nil single_connect_posted.utilization, "Expected utilization data to be nil"
70
- end
71
- end
72
-
73
66
  def with_fake_metadata_service
74
67
  metadata_service = NewRelic::FakeInstanceMetadataService.new
75
68
  metadata_service.run
@@ -1,6 +1,6 @@
1
1
  if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
2
2
  gemfile <<-RB
3
- gem 'rails', '5.0.0beta3'
3
+ gem 'rails', '5.0.0.rc1'
4
4
  gem 'haml', :require => false
5
5
  gem 'minitest', '5.2.3'
6
6
  RB
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ begin
6
+ require 'action_cable'
7
+ rescue LoadError
8
+ end
9
+
10
+ if defined?(ActionCable::Channel)
11
+
12
+ require 'stringio'
13
+ require 'logger'
14
+ require 'json'
15
+
16
+ class ActionCableTest < Minitest::Test
17
+ include MultiverseHelpers
18
+
19
+ class TestConnection
20
+ attr_reader :transmissions, :identifiers, :logger
21
+
22
+ def initialize
23
+ @transmissions = []
24
+ @identifiers = []
25
+ @logger = Logger.new StringIO.new
26
+ end
27
+
28
+ def transmit data
29
+ @transmissions << data
30
+ end
31
+
32
+ def last_transmission
33
+ JSON.parse @transmissions.last
34
+ end
35
+ end
36
+
37
+ class TestChannel < ActionCable::Channel::Base
38
+ def test_action data
39
+ transmit data['content']
40
+ end
41
+
42
+ def boom data
43
+ raise StandardError.new("Boom!")
44
+ end
45
+ end
46
+
47
+ setup_and_teardown_agent do
48
+ @connection = TestConnection.new
49
+ @channel = TestChannel.new @connection, "{id: 1}"
50
+ end
51
+
52
+ def test_creates_trace
53
+ @channel.perform_action({ 'action' => :test_action, 'content' => 'hello' })
54
+
55
+ last_sample = NewRelic::Agent.instance.transaction_sampler.last_sample
56
+ assert_equal('Controller/ActionCable/ActionCableTest::TestChannel/test_action', last_sample.transaction_name)
57
+ end
58
+
59
+ def test_creates_web_transaction
60
+ @channel.perform_action({ 'action'=> :test_action, 'content' => 'hello' })
61
+
62
+ expected_metrics = {
63
+ 'HttpDispatcher' => { :call_count => 1 },
64
+ 'Controller/ActionCable/ActionCableTest::TestChannel/test_action' => { :call_count => 1}
65
+ }
66
+
67
+ assert_metrics_recorded expected_metrics
68
+ end
69
+
70
+ def test_action_with_error_is_noticed_by_agent
71
+ @channel.perform_action({ 'action'=> :boom }) rescue nil
72
+
73
+ error_trace = last_traced_error
74
+
75
+ assert_equal "StandardError", error_trace.exception_class_name
76
+ assert_equal "Boom!", error_trace.message
77
+ assert_equal "Controller/ActionCable/ActionCableTest::TestChannel/boom", error_trace.path
78
+ end
79
+ end
80
+
81
+ end
@@ -311,7 +311,6 @@ module NewRelic
311
311
  def test_connect_does_not_retry_if_keep_retrying_false
312
312
  @agent.service.expects(:connect).once.raises(Timeout::Error)
313
313
  @agent.send(:connect, :keep_retrying => false)
314
- assert(@agent.disconnected?)
315
314
  end
316
315
 
317
316
  def test_connect_does_not_retry_on_license_error
@@ -31,4 +31,29 @@ class HashExtensionsTest < Minitest::Test
31
31
  refute_same arg, result
32
32
  assert_includes arg.keys, :foo
33
33
  end
34
- end
34
+
35
+ def test_symbolize_keys_in_object_with_nested_hash
36
+ hash = {"foo" => {"bar" => [{"baz" => "qux"}, "quux"]}}
37
+ expected = {:foo => {:bar => [{:baz => "qux"}, "quux"]}}
38
+
39
+ actual = NewRelic::Agent::HashExtensions.symbolize_keys_in_object(hash)
40
+
41
+ assert_equal expected, actual
42
+ end
43
+
44
+ def test_symbolize_keys_in_object_with_array
45
+ array = ["foo", {"bar" => [{"baz" => "qux"}, "quux"]}]
46
+ expected = ["foo", {:bar => [{:baz => "qux"}, "quux"]}]
47
+
48
+ actual = NewRelic::Agent::HashExtensions.symbolize_keys_in_object(array)
49
+
50
+ assert_equal expected, actual
51
+ end
52
+
53
+ def test_symbolize_keys_in_object_does_not_mutate_argument
54
+ arg = {"foo" => "bar"}
55
+ result = NewRelic::Agent::HashExtensions.symbolize_keys_in_object(arg)
56
+ refute_same arg, result
57
+ assert_includes arg.keys, "foo"
58
+ end
59
+ end
@@ -0,0 +1,124 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= 5
6
+
7
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
8
+ require 'new_relic/agent/instrumentation/action_cable_subscriber'
9
+
10
+
11
+ module NewRelic
12
+ module Agent
13
+ module Instrumentation
14
+ class ActionCableSubscriberTest < Minitest::Test
15
+
16
+ def setup
17
+ freeze_time
18
+ @subscriber = ActionCableSubscriber.new
19
+
20
+ NewRelic::Agent.drop_buffered_data
21
+ @stats_engine = NewRelic::Agent.instance.stats_engine
22
+ @stats_engine.clear_stats
23
+ NewRelic::Agent.manual_start
24
+ NewRelic::Agent::TransactionState.tl_clear_for_testing
25
+ end
26
+
27
+ def teardown
28
+ NewRelic::Agent.shutdown
29
+ @stats_engine.clear_stats
30
+ end
31
+
32
+ def test_creates_web_transaction
33
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
34
+ assert NewRelic::Agent::TransactionState.tl_get.in_web_transaction?
35
+ advance_time(1.0)
36
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
37
+
38
+ assert_equal('Controller/ActionCable/TestChannel/test_action',
39
+ NewRelic::Agent.instance.transaction_sampler.last_sample.transaction_name)
40
+ assert_equal('Controller/ActionCable/TestChannel/test_action',
41
+ NewRelic::Agent.instance.transaction_sampler.last_sample.root_node.called_nodes[0].metric_name)
42
+ end
43
+
44
+ def test_records_apdex_metrics
45
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
46
+ advance_time(1.5)
47
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
48
+
49
+ expected_values = { :apdex_f => 0, :apdex_t => 1, :apdex_s => 0 }
50
+ assert_metrics_recorded(
51
+ 'Apdex/ActionCable/TestChannel/test_action' => expected_values,
52
+ 'Apdex' => expected_values
53
+ )
54
+ end
55
+
56
+ def test_sets_default_transaction_name_on_start
57
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
58
+ assert_equal 'Controller/ActionCable/TestChannel/test_action', NewRelic::Agent::Transaction.tl_current.best_name
59
+ ensure
60
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
61
+ end
62
+
63
+ def test_sets_default_transaction_keeps_name_through_stop
64
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
65
+ txn = NewRelic::Agent::Transaction.tl_current
66
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
67
+ assert_equal 'Controller/ActionCable/TestChannel/test_action', txn.best_name
68
+ end
69
+
70
+ def test_sets_transaction_name
71
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
72
+ NewRelic::Agent.set_transaction_name('something/else')
73
+ assert_equal 'Controller/ActionCable/something/else', NewRelic::Agent::Transaction.tl_current.best_name
74
+ ensure
75
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
76
+ end
77
+
78
+ def test_sets_transaction_name_holds_through_stop
79
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
80
+ txn = NewRelic::Agent::Transaction.tl_current
81
+ NewRelic::Agent.set_transaction_name('something/else')
82
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
83
+ assert_equal 'Controller/ActionCable/something/else', txn.best_name
84
+ end
85
+
86
+ def test_creates_tt_node_for_transmit
87
+ @subscriber.start('perform_action.action_cable', :id, payload_for_perform_action)
88
+ assert NewRelic::Agent::TransactionState.tl_get.in_web_transaction?
89
+ @subscriber.start('transmit.action_cable', :id, payload_for_transmit)
90
+ advance_time(1.0)
91
+ @subscriber.finish('transmit.action_cable', :id, payload_for_transmit)
92
+ @subscriber.finish('perform_action.action_cable', :id, payload_for_perform_action)
93
+
94
+ sample = NewRelic::Agent.instance.transaction_sampler.last_sample
95
+
96
+ assert_equal('Controller/ActionCable/TestChannel/test_action', sample.transaction_name)
97
+ metric_name = 'Ruby/ActionCable/TestChannel/transmit'
98
+ refute_nil(find_node_with_name(sample, metric_name), "Expected trace to have node with name: #{metric_name}")
99
+ end
100
+
101
+ def test_records_unscoped_metrics_but_does_not_create_trace_for_transmit_outside_of_active_txn
102
+ @subscriber.start('transmit.action_cable', :id, payload_for_transmit)
103
+ advance_time(1.0)
104
+ @subscriber.finish('transmit.action_cable', :id, payload_for_transmit)
105
+
106
+ sample = NewRelic::Agent.instance.transaction_sampler.last_sample
107
+
108
+ assert_nil sample, "Did not expect a transaction to be created for transmit"
109
+ assert_metrics_recorded ['Ruby/ActionCable/TestChannel/transmit']
110
+ end
111
+
112
+ def payload_for_perform_action action = 'test_action'
113
+ {:channel_class => "TestChannel", :action => action.to_sym, :data => {"action"=>"#{action}"}}
114
+ end
115
+
116
+ def payload_for_transmit data = {}, via = nil
117
+ {:channel_class => "TestChannel", :data => data, :via => via}
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ end