newrelic_rpm 3.9.5.251 → 3.9.6.257

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +74 -3
  3. data/GUIDELINES_FOR_CONTRIBUTING.md +19 -15
  4. data/README.md +1 -1
  5. data/Rakefile +22 -1
  6. data/lib/new_relic/agent/agent.rb +17 -5
  7. data/lib/new_relic/agent/agent_logger.rb +4 -0
  8. data/lib/new_relic/agent/configuration/default_source.rb +45 -1
  9. data/lib/new_relic/agent/configuration/manager.rb +43 -7
  10. data/lib/new_relic/agent/cross_app_monitor.rb +0 -3
  11. data/lib/new_relic/agent/cross_app_tracing.rb +8 -5
  12. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +4 -1
  13. data/lib/new_relic/agent/instrumentation/active_job.rb +93 -0
  14. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -1
  15. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +2 -2
  16. data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -2
  17. data/lib/new_relic/agent/new_relic_service.rb +1 -1
  18. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +20 -1
  19. data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +5 -1
  20. data/lib/new_relic/agent/pipe_channel_manager.rb +32 -11
  21. data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
  22. data/lib/new_relic/agent/threading/backtrace_node.rb +4 -3
  23. data/lib/new_relic/agent/transaction.rb +27 -6
  24. data/lib/new_relic/agent/transaction_state.rb +3 -3
  25. data/lib/new_relic/agent/vm/mri_vm.rb +3 -3
  26. data/lib/new_relic/control/frameworks/rails3.rb +1 -16
  27. data/lib/new_relic/control/instance_methods.rb +2 -0
  28. data/lib/new_relic/json_wrapper.rb +18 -3
  29. data/lib/new_relic/rack/browser_monitoring.rb +7 -5
  30. data/lib/new_relic/rack/developer_mode.rb +2 -0
  31. data/lib/new_relic/rack/error_collector.rb +12 -51
  32. data/lib/new_relic/transaction_sample.rb +0 -4
  33. data/lib/new_relic/transaction_sample/segment.rb +0 -4
  34. data/lib/new_relic/version.rb +1 -1
  35. data/newrelic_rpm.gemspec +3 -2
  36. data/test/agent_helper.rb +1 -1
  37. data/test/config/test.cert.crt +16 -12
  38. data/test/config/test.cert.key +13 -13
  39. data/test/environments/lib/environments/runner.rb +3 -0
  40. data/test/environments/rails30/Gemfile +2 -2
  41. data/test/environments/rails31/Gemfile +2 -2
  42. data/test/environments/rails32/Gemfile +2 -2
  43. data/test/environments/rails40/Gemfile +2 -4
  44. data/test/environments/rails41/Gemfile +2 -4
  45. data/test/environments/rails42/Gemfile +2 -4
  46. data/test/fixtures/cross_agent_tests/attribute_configuration.json +349 -0
  47. data/test/fixtures/cross_agent_tests/labels.json +31 -2
  48. data/test/fixtures/cross_agent_tests/postgres_explain_obfuscation/README.md +16 -0
  49. data/test/fixtures/cross_agent_tests/rum_client_config.json +9 -9
  50. data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/empty_head +4 -0
  51. data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/no_end_header.html +6 -0
  52. data/test/fixtures/cross_agent_tests/rum_loader_insertion_location/x_ua_meta_tag_multiple_tags.html +12 -0
  53. data/test/multiverse/lib/multiverse/runner.rb +33 -1
  54. data/test/multiverse/lib/multiverse/suite.rb +79 -7
  55. data/test/multiverse/suites/active_record/Envfile +1 -1
  56. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -1
  57. data/test/multiverse/suites/agent_only/labels_test.rb +2 -1
  58. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +2 -3
  59. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +6 -6
  60. data/test/multiverse/suites/capistrano/Envfile +2 -2
  61. data/test/multiverse/suites/capistrano2/Envfile +4 -0
  62. data/test/multiverse/suites/curb/Envfile +4 -0
  63. data/test/multiverse/suites/high_security/config/newrelic.yml +5 -2
  64. data/test/multiverse/suites/high_security/high_security_test.rb +10 -8
  65. data/test/multiverse/suites/json/Envfile +23 -0
  66. data/test/multiverse/suites/json/config/newrelic.yml +22 -0
  67. data/test/multiverse/suites/json/json_test.rb +17 -0
  68. data/test/multiverse/suites/marshalling/marshalling_test.rb +2 -45
  69. data/test/multiverse/suites/rails/Envfile +3 -3
  70. data/test/multiverse/suites/rails/activejob_test.rb +137 -0
  71. data/test/multiverse/suites/rails/error_tracing_test.rb +15 -8
  72. data/test/multiverse/suites/rails/parameter_capture_test.rb +39 -19
  73. data/test/multiverse/suites/sequel/Envfile +5 -5
  74. data/test/multiverse/suites/sidekiq/Envfile +2 -2
  75. data/test/multiverse/suites/sinatra/Envfile +2 -1
  76. data/test/multiverse/suites/yajl/Envfile +13 -0
  77. data/test/multiverse/suites/yajl/config/newrelic.yml +21 -0
  78. data/test/multiverse/suites/yajl/yajl_test.rb +19 -0
  79. data/test/new_relic/agent/agent_logger_test.rb +10 -0
  80. data/test/new_relic/agent/agent_test.rb +7 -1
  81. data/test/new_relic/agent/configuration/default_source_test.rb +24 -0
  82. data/test/new_relic/agent/configuration/manager_test.rb +60 -2
  83. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +25 -13
  84. data/test/new_relic/agent/cross_app_tracing_test.rb +10 -1
  85. data/test/new_relic/agent/instrumentation/active_job_test.rb +20 -0
  86. data/test/new_relic/agent/instrumentation/active_record_test.rb +10 -17
  87. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +15 -0
  88. data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
  89. data/test/new_relic/agent/new_relic_service_test.rb +24 -0
  90. data/test/new_relic/agent/pipe_channel_manager_test.rb +44 -2
  91. data/test/new_relic/agent/threading/agent_thread_test.rb +1 -2
  92. data/test/new_relic/agent/threading/backtrace_node_test.rb +12 -0
  93. data/test/new_relic/agent/transaction_state_test.rb +3 -6
  94. data/test/new_relic/agent/transaction_test.rb +163 -0
  95. data/test/new_relic/agent_test.rb +13 -1
  96. data/test/new_relic/fake_collector.rb +5 -5
  97. data/test/new_relic/fake_server.rb +5 -3
  98. data/test/new_relic/http_client_test_cases.rb +0 -4
  99. data/test/new_relic/marshalling_test_cases.rb +54 -0
  100. data/test/new_relic/multiverse_helpers.rb +2 -2
  101. data/test/new_relic/rack/browser_monitoring_test.rb +6 -0
  102. data/test/new_relic/rack/developer_mode_test.rb +8 -0
  103. data/test/new_relic/rack/error_collector_test.rb +0 -41
  104. data/test/new_relic/transaction_sample/segment_test.rb +0 -13
  105. data/test/new_relic/transaction_sample_test.rb +1 -11
  106. data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
  107. data/test/performance/lib/performance/runner.rb +1 -1
  108. data/test/performance/script/runner +2 -1
  109. data/test/performance/suites/rum_autoinsertion.rb +12 -2
  110. metadata +24 -11
  111. metadata.gz.sig +0 -0
  112. data/test/config/test.cert.csr +0 -11
  113. data/test/config/testing-privkey.pem +0 -18
@@ -0,0 +1,4 @@
1
+ <html>
2
+ <head/>
3
+ <body>im some body text</body>
4
+ </html>
@@ -0,0 +1,6 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>EXPECTED_RUM_LOADER_LOCATION<body>
4
+ Cribbed from the Java agent
5
+ </body>
6
+ </html>
@@ -0,0 +1,12 @@
1
+ <html>
2
+ <head>
3
+ <title>im a title</title>
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>EXPECTED_RUM_LOADER_LOCATION
5
+ <meta name="keywords" content="testing,rum,insertion" >
6
+ <script>
7
+ junk
8
+ </script>
9
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
10
+ </head>
11
+ <body>im some body text</body>
12
+ </html>
@@ -62,7 +62,7 @@ module Multiverse
62
62
  full_path = File.join(SUITES_DIRECTORY, dir)
63
63
 
64
64
  next if dir =~ /\A\./
65
- next unless filter.nil? || dir.include?(filter)
65
+ next unless passes_filter?(dir, filter)
66
66
  next unless File.exists?(File.join(full_path, "Envfile"))
67
67
 
68
68
  begin
@@ -80,5 +80,37 @@ module Multiverse
80
80
  OutputCollector.overall_report
81
81
  exit exit_status
82
82
  end
83
+
84
+ GROUPS = {
85
+ "agent" => ["agent_only", "bare", "config_file_loading",
86
+ "deferred_instrumentation", "high_security"],
87
+ "background" => ["resque", "sidekiq"],
88
+ "database" => ["datamapper", "mongo", "sequel"],
89
+ "httpclients" => ["curb", "excon", "httpclient", "typhoeus", "net_http"],
90
+ "rails" => ["active_record", "rails"],
91
+ "serialization" => ["json", "marshalling", "yajl"],
92
+ "sinatra" => ["sinatra", "padrino"],
93
+
94
+ "rest" => [] # Specially handled below
95
+ }
96
+
97
+ def passes_filter?(dir, filter)
98
+ return true if filter.nil?
99
+
100
+ if filter.include?("group=")
101
+ key = filter.sub("group=", "")
102
+ group = GROUPS[key]
103
+ if group.nil?
104
+ puts red("Unrecognized group '#{key}'. Stopping!")
105
+ exit 1
106
+ elsif group.any?
107
+ GROUPS[key].include?(dir)
108
+ else
109
+ !GROUPS.values.flatten.include?(dir)
110
+ end
111
+ else
112
+ dir.include?(filter)
113
+ end
114
+ end
83
115
  end
84
116
  end
@@ -8,6 +8,8 @@
8
8
  # Rubies starting with 1.9.x
9
9
  require 'rubygems'
10
10
  require 'base64'
11
+ require 'fileutils'
12
+ require 'digest'
11
13
 
12
14
  require File.expand_path(File.join(File.dirname(__FILE__), 'environment'))
13
15
 
@@ -46,6 +48,10 @@ module Multiverse
46
48
  opts.fetch(:names, [])
47
49
  end
48
50
 
51
+ def use_cache?
52
+ !opts.fetch(:nocache, false)
53
+ end
54
+
49
55
  def filter_env
50
56
  value = opts.fetch(:env, nil)
51
57
  value = value.to_i if value
@@ -60,11 +66,14 @@ module Multiverse
60
66
  FileUtils.rm_rf File.join(directory, "Gemfile.#{env_index}.lock")
61
67
  end
62
68
 
69
+ def envfile_path
70
+ File.join(directory, 'Envfile')
71
+ end
63
72
 
64
73
  def environments
65
74
  @environments ||= (
66
75
  Dir.chdir directory
67
- Envfile.new(File.join(directory, 'Envfile'))
76
+ Envfile.new(envfile_path)
68
77
  )
69
78
  end
70
79
 
@@ -74,30 +83,93 @@ module Multiverse
74
83
  clean_gemfiles(env_index)
75
84
  begin
76
85
  generate_gemfile(gemfile_text, env_index)
77
- bundle
86
+ ensure_bundle(env_index)
78
87
  rescue => e
79
88
  puts "#{e.class}: #{e}"
80
89
  puts "Fast local bundle failed. Attempting to install from rubygems.org"
81
90
  clean_gemfiles(env_index)
82
91
  generate_gemfile(gemfile_text, env_index, false)
83
- bundle
92
+ ensure_bundle(env_index)
84
93
  end
85
94
  print_environment if should_print
86
95
  end
87
96
 
88
- def bundle
97
+ def bundling_lock_file
98
+ File.join(Bundler.bundle_path, 'multiverse-bundler.lock')
99
+ end
100
+
101
+ def bundler_cache_dir
102
+ File.join(Bundler.bundle_path, 'multiverse-cache')
103
+ end
104
+
105
+ # Running the bundle should only happen one at a time per Ruby version or
106
+ # we occasionally get compilation errors. With the groups and parallelizing
107
+ # things out more, this is more of an issue, so start locking it down.
108
+ def exclusive_bundle
109
+ bundler_out = nil
110
+ File.open(bundling_lock_file, File::RDWR|File::CREAT) do |f|
111
+ puts "Waiting on '#{bundling_lock_file}' for our chance to bundle" if verbose?
112
+ f.flock(File::LOCK_EX)
113
+ puts "Let's get ready to BUNDLE!" if verbose?
114
+ bundler_out = `bundle`
115
+ end
116
+ bundler_out
117
+ end
118
+
119
+ def ensure_bundle(env_index)
89
120
  require 'rubygems'
90
121
  require 'bundler'
91
- bundler_out = `bundle`
122
+ if use_cache?
123
+ ensure_bundle_cached(env_index) || ensure_bundle_uncached(env_index)
124
+ else
125
+ ensure_bundle_uncached(env_index)
126
+ end
127
+ Bundler.require
128
+ end
129
+
130
+ def envfile_hash
131
+ Digest::MD5.hexdigest(File.read(envfile_path))
132
+ end
133
+
134
+ def cached_gemfile_lock_filename(env_index)
135
+ "Gemfile.#{suite}.#{env_index}.#{envfile_hash}.lock"
136
+ end
137
+
138
+ def cache_gemfile_lock(env_index)
139
+ filename = cached_gemfile_lock_filename(env_index)
140
+ dst_path = File.join(bundler_cache_dir, filename)
141
+ src_path = File.join(directory, "Gemfile.#{env_index}.lock")
142
+ puts "Caching Gemfile.lock from #{src_path} to #{dst_path}" if verbose?
143
+ FileUtils.cp(src_path, dst_path)
144
+ end
145
+
146
+ def ensure_bundle_cached(env_index)
147
+ cache_dir = bundler_cache_dir
148
+ FileUtils.mkdir_p(cache_dir)
149
+ filename = cached_gemfile_lock_filename(env_index)
150
+ path = File.join(cache_dir, filename)
151
+
152
+ if File.exist?(path)
153
+ dst_path = File.join(directory, "Gemfile.#{env_index}.lock")
154
+ puts "Using cached Gemfile.lock from #{path} at #{dst_path}" if verbose?
155
+ FileUtils.cp(path, dst_path)
156
+ true
157
+ else
158
+ false
159
+ end
160
+ end
161
+
162
+ def ensure_bundle_uncached(env_index)
163
+ bundler_out = exclusive_bundle
92
164
  puts bundler_out if verbose? || $? != 0
93
165
  raise "bundle command failed with (#{$?})" unless $? == 0
94
- Bundler.require
166
+ cache_gemfile_lock(env_index)
95
167
  end
96
168
 
97
169
  def generate_gemfile(gemfile_text, env_index, local = true)
98
170
  gemfile = File.join(Dir.pwd, "Gemfile.#{env_index}")
99
171
  File.open(gemfile,'w') do |f|
100
- f.puts ' source :rubygems' unless local
172
+ f.puts ' source "https://rubygems.org"' unless local
101
173
  f.print gemfile_text
102
174
  f.puts newrelic_gemfile_line unless gemfile_text =~ /^\s*gem .newrelic_rpm./
103
175
  f.puts jruby_openssl_line unless gemfile_text =~ /^\s*gem .jruby-openssl./
@@ -8,6 +8,6 @@ gemfile <<-RB
8
8
  gem 'activerecord', '~> 3.2.0'
9
9
  else
10
10
  gem 'activerecord', '~> 3.2.0'
11
- gem 'sqlite3', '1.3.8'
11
+ gem 'sqlite3'
12
12
  end
13
13
  RB
@@ -88,7 +88,7 @@ class EncodingHandlingTest < Minitest::Test
88
88
 
89
89
  def assert_endpoint_received_string(endpoint, string)
90
90
  agent.send(:transmit_data)
91
- agent.send(:transmit_transaction_event_data)
91
+ agent.send(:transmit_event_data)
92
92
  requests = $collector.calls_for(endpoint)
93
93
  assert_equal(1, requests.size)
94
94
  request = requests.first
@@ -79,6 +79,7 @@ class LabelsTest < Minitest::Test
79
79
 
80
80
  def assert_connect_had_labels(expected)
81
81
  result = $collector.calls_for('connect').last['labels']
82
- assert_equal expected, result
82
+ assert_equal expected.sort_by { |h| h['label_type']},
83
+ result.sort_by { |h| h['label_type']}
83
84
  end
84
85
  end
@@ -41,9 +41,8 @@ class SetTransactionNameTest < Minitest::Test
41
41
 
42
42
  assert_metrics_recorded([
43
43
  'Controller/TestTransactor/parent',
44
- 'OtherTransaction/Background/TestTransactor/child',
45
- ['OtherTransaction/Background/TestTransactor/child',
46
- 'Controller/TestTransactor/parent'],
44
+ 'Nested/OtherTransaction/Background/TestTransactor/child',
45
+ ['Nested/OtherTransaction/Background/TestTransactor/child', 'Controller/TestTransactor/parent'],
47
46
  'Apdex/TestTransactor/parent'])
48
47
  end
49
48
 
@@ -61,8 +61,8 @@ class ThreadProfilingTest < Minitest::Test
61
61
  # go only let a few cycles through, so we check less than 10
62
62
 
63
63
  def test_thread_profiling
64
- run_transaction_in_thread(:type => :controller, :request => stub)
65
- run_transaction_in_thread(:type => :task)
64
+ run_transaction_in_thread(:controller)
65
+ run_transaction_in_thread(:task)
66
66
 
67
67
  issue_command(START_COMMAND)
68
68
 
@@ -80,8 +80,8 @@ class ThreadProfilingTest < Minitest::Test
80
80
 
81
81
  def test_thread_profiling_with_pruby_marshaller
82
82
  with_config(:marshaller => 'pruby') do
83
- run_transaction_in_thread(:type => :controller, :request => stub)
84
- run_transaction_in_thread(:type => :task)
83
+ run_transaction_in_thread(:controller)
84
+ run_transaction_in_thread(:task)
85
85
 
86
86
  issue_command(START_COMMAND)
87
87
 
@@ -118,11 +118,11 @@ class ThreadProfilingTest < Minitest::Test
118
118
  end
119
119
 
120
120
  # Runs a thread we expect to span entire test and be killed at the end
121
- def run_transaction_in_thread(opts)
121
+ def run_transaction_in_thread(category)
122
122
  q = Queue.new
123
123
  @threads ||= []
124
124
  @threads << Thread.new do
125
- in_transaction(opts) do
125
+ in_transaction(:category => category) do
126
126
  q.push('.')
127
127
  sleep # sleep until explicitly woken in join_background_threads
128
128
  end
@@ -1,5 +1,5 @@
1
- suite_condition("Capistrano 3 not supported in 1.8.7") do
2
- RUBY_VERSION != '1.8.7'
1
+ suite_condition("Capistrano 3 not supported in 1.8.7 and flaky on JRuby") do
2
+ RUBY_VERSION != '1.8.7' && RUBY_PLATFORM != 'java'
3
3
  end
4
4
 
5
5
  gemfile <<-RB
@@ -1,3 +1,7 @@
1
+ suite_condition("Capistrano testing is flaky on JRuby") do
2
+ RUBY_PLATFORM != 'java'
3
+ end
4
+
1
5
  gemfile <<-RB
2
6
  gem 'capistrano', '~>2.15.5'
3
7
  gem 'rack'
@@ -21,8 +21,12 @@ gemfile <<-RB
21
21
  gem 'json', :platforms => [:rbx, :mri_18]
22
22
  RB
23
23
 
24
+ # Older curb's than 0.8.6 don't build against Ruby 2.2.0-preview1
25
+ # Recheck on later RC's, but for now, just skip this env for Ruby 2.2.0
26
+ if RUBY_VERSION < "2.2.0"
24
27
  gemfile <<-RB
25
28
  gem 'curb', '0.8.1'
26
29
  gem 'rack'
27
30
  gem 'json', :platforms => [:rbx, :mri_18]
28
31
  RB
32
+ end
@@ -20,8 +20,11 @@ development:
20
20
  license_key: bootstrap_newrelic_admin_license_key_000
21
21
  developer_mode: false
22
22
  app_name: test
23
- host: 127.0.0.1
24
- api_host: 127.0.0.1
23
+ host: localhost
24
+ api_host: localhost
25
25
  port: <%= $collector && $collector.port %>
26
26
  browser_monitoring:
27
27
  auto_instrument: true
28
+
29
+ # Fake collector uses SSL, and we want agent to trust its self-signed cert.
30
+ ca_bundle_path: ../../../config/test.cert.crt
@@ -3,6 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'multiverse_helpers'
6
+ require 'fake_server'
6
7
 
7
8
  # These tests are designed to work in conjunction with a local newrelic.yml
8
9
  # file set with "insecure" settings and the server returning "insecure" values,
@@ -12,12 +13,11 @@ class HighSecurityTest < Minitest::Test
12
13
 
13
14
  include MultiverseHelpers
14
15
 
15
- setup_and_teardown_agent do |collector|
16
- # Because our tests will default to using SSL, we need to stub that out
17
- # on our HTTP connects to the fake collector which doesn't have SSL...
18
- Net::HTTPSession.any_instance.expects('use_ssl=').with(true).at_least_once
16
+ setup_and_teardown_agent do |_collector|
17
+ $collector = nil
18
+ setup_collector(true)
19
19
 
20
- collector.stub('connect', {
20
+ $collector.stub('connect', {
21
21
  "agent_run_id" => 1,
22
22
  "listen_to_server_config" => true,
23
23
 
@@ -28,9 +28,11 @@ class HighSecurityTest < Minitest::Test
28
28
  end
29
29
 
30
30
  def test_connects_via_ssl_no_matter_what
31
- # Expectation is set in setup since we all need to sidestep the use_ssl=
32
- # setting, and mocking gets weird if we call `stubs` then try to `expects`
33
- NewRelic::Agent.manual_start(:ssl => false)
31
+ assert_equal 1, $collector.calls_for('connect').size
32
+
33
+ trigger_agent_reconnect(:ssl => false)
34
+
35
+ assert_equal 2, $collector.calls_for('connect').size
34
36
  end
35
37
 
36
38
  def test_sends_high_security_flag_in_connect
@@ -0,0 +1,23 @@
1
+ all_versions = [ '~> 1.8.1', '~> 1.7.7', '~> 1.6.8', '~> 1.5.5' ]
2
+ before_2_0_0 = [ '~> 1.4.6', '~> 1.2.4', '~> 1.1.9' ]
3
+ before_1_9_2 = [ '1.1.2' ]
4
+
5
+ json_gems = all_versions.dup
6
+ json_gems += before_2_0_0 if RUBY_VERSION < '2.0.0'
7
+ json_gems += before_1_9_2 if RUBY_VERSION < '1.9.2'
8
+
9
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
10
+ json_gems.delete('~> 1.7.7')
11
+ end
12
+
13
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
14
+ json_gems.delete('~> 1.2.4')
15
+ json_gems.delete('~> 1.1.9')
16
+ end
17
+
18
+ json_gems.each do |version|
19
+ gemfile <<-RB
20
+ gem 'rack'
21
+ gem 'json', '#{version}'
22
+ RB
23
+ end
@@ -0,0 +1,22 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ enabled: true
5
+ apdex_t: 0.24
6
+ ssl: false
7
+ log_level: debug
8
+ monitor_mode: true
9
+ license_key: bootstrap_newrelic_admin_license_key_000
10
+ developer_mode: false
11
+ app_name: test
12
+ host: 127.0.0.1
13
+ api_host: 127.0.0.1
14
+ port: <%= $collector && $collector.port %>
15
+ transaction_tracer:
16
+ record_sql: obfuscated
17
+ enabled: true
18
+ stack_trace_threshold: 0.5
19
+ capture_params: false
20
+ browser_monitoring:
21
+ auto_instrument: true
22
+ marshaller: json
@@ -0,0 +1,17 @@
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
+ require 'multiverse_helpers'
6
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'new_relic', 'marshalling_test_cases')
7
+
8
+ # This is intended as a sanity check for our serialization to JSON via the
9
+ # json gem across various Ruby versions.
10
+ class JsonTest < Minitest::Test
11
+
12
+ include MultiverseHelpers
13
+ include MarshallingTestCases
14
+
15
+ setup_and_teardown_agent
16
+
17
+ end
@@ -3,58 +3,15 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'multiverse_helpers'
6
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'new_relic', 'marshalling_test_cases')
6
7
 
7
8
  # These tests are intended to exercise the basic marshalling functionality of
8
9
  # the agent in it's different permutations (Ruby and JSON)
9
10
  class MarshallingTest < Minitest::Test
10
11
 
11
12
  include MultiverseHelpers
13
+ include MarshallingTestCases
12
14
 
13
15
  setup_and_teardown_agent
14
16
 
15
- def test_sends_metrics
16
- NewRelic::Agent.record_metric('Boo', 42)
17
-
18
- transmit_data
19
-
20
- result = $collector.calls_for('metric_data')
21
- assert_equal 1, result.length
22
- assert_includes result.first.metric_names, 'Boo'
23
- end
24
-
25
- def test_sends_errors
26
- NewRelic::Agent.notice_error(StandardError.new("Boom"))
27
-
28
- transmit_data
29
-
30
- result = $collector.calls_for('error_data')
31
- assert_equal 1, result.length
32
- assert_equal 1, result.first.errors.length
33
- assert_equal "StandardError", result.first.errors.first.exception_class_name
34
- end
35
-
36
- def test_sends_transaction_traces
37
- with_config(:'transaction_tracer.transaction_threshold' => -1.0) do
38
- Transactioner.new.do_it
39
- end
40
-
41
- transmit_data
42
-
43
- result = $collector.calls_for('transaction_sample_data')
44
- assert_equal 1, result.length
45
- assert_equal "Controller/MarshallingTest::Transactioner/do_it", result.first.metric_name
46
- end
47
-
48
- class Transactioner
49
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
50
-
51
- def do_it
52
- end
53
-
54
- add_transaction_tracer :do_it
55
- end
56
-
57
- def transmit_data
58
- NewRelic::Agent.instance.send(:transmit_data)
59
- end
60
17
  end