newrelic_rpm 3.18.1.330 → 4.0.0.332

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -74
  3. data/CHANGELOG.md +77 -0
  4. data/CONTRIBUTING.md +14 -6
  5. data/LICENSE +1 -88
  6. data/lib/new_relic/agent.rb +2 -103
  7. data/lib/new_relic/agent/agent.rb +3 -32
  8. data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
  9. data/lib/new_relic/agent/configuration/default_source.rb +1 -8
  10. data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
  12. data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
  13. data/lib/new_relic/agent/datastores/mongo.rb +1 -1
  14. data/lib/new_relic/agent/datastores/redis.rb +1 -1
  15. data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
  16. data/lib/new_relic/agent/error_collector.rb +8 -21
  17. data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
  18. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
  19. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
  20. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
  21. data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
  22. data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
  23. data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
  24. data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
  25. data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
  26. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
  27. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
  28. data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
  29. data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
  30. data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
  32. data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
  33. data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
  34. data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
  35. data/lib/new_relic/agent/method_tracer.rb +1 -60
  36. data/lib/new_relic/agent/new_relic_service.rb +3 -2
  37. data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
  38. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
  39. data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
  40. data/lib/new_relic/agent/pipe_service.rb +1 -3
  41. data/lib/new_relic/agent/rules_engine.rb +2 -17
  42. data/lib/new_relic/agent/stats_engine.rb +0 -2
  43. data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
  44. data/lib/new_relic/agent/supported_versions.rb +12 -19
  45. data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
  46. data/lib/new_relic/agent/transaction.rb +0 -3
  47. data/lib/new_relic/agent/transaction/attributes.rb +1 -10
  48. data/lib/new_relic/agent/vm.rb +1 -4
  49. data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
  50. data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
  51. data/lib/new_relic/control.rb +1 -2
  52. data/lib/new_relic/control/frameworks/rails.rb +1 -1
  53. data/lib/new_relic/control/frameworks/rails3.rb +1 -2
  54. data/lib/new_relic/control/frameworks/rails4.rb +1 -1
  55. data/lib/new_relic/control/frameworks/rails5.rb +1 -1
  56. data/lib/new_relic/control/instance_methods.rb +1 -1
  57. data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
  58. data/lib/new_relic/helper.rb +6 -13
  59. data/lib/new_relic/language_support.rb +44 -139
  60. data/lib/new_relic/metric_spec.rb +0 -17
  61. data/lib/new_relic/noticed_error.rb +18 -27
  62. data/lib/new_relic/version.rb +3 -48
  63. data/lib/tasks/versions.rake +7 -5
  64. data/newrelic_rpm.gemspec +1 -16
  65. data/test/agent_helper.rb +4 -2
  66. data/test/environments/lib/environments/runner.rb +5 -14
  67. data/test/environments/norails/Gemfile +0 -8
  68. data/test/environments/rails21/Gemfile +0 -8
  69. data/test/environments/rails21/config/database.yml +1 -1
  70. data/test/environments/rails22/Gemfile +0 -8
  71. data/test/environments/rails22/config/database.yml +1 -1
  72. data/test/environments/rails23/Gemfile +1 -7
  73. data/test/environments/rails23/config/database.yml +1 -1
  74. data/test/environments/rails30/Gemfile +0 -1
  75. data/test/environments/rails30/config/database.yml +1 -1
  76. data/test/environments/rails31/Gemfile +0 -3
  77. data/test/environments/rails31/config/database.yml +1 -1
  78. data/test/environments/rails32/Gemfile +0 -3
  79. data/test/environments/rails32/config/database.yml +1 -1
  80. data/test/environments/rails40/Gemfile +0 -26
  81. data/test/environments/rails40/config/database.yml +1 -1
  82. data/test/environments/rails41/Gemfile +0 -18
  83. data/test/environments/rails41/config/database.yml +1 -1
  84. data/test/environments/rails42/Gemfile +0 -22
  85. data/test/environments/rails42/config/database.yml +1 -1
  86. data/test/environments/rails50/Gemfile +0 -13
  87. data/test/environments/rails50/config/database.yml +1 -1
  88. data/test/helpers/logging.rb +37 -0
  89. data/test/helpers/minitest.rb +50 -0
  90. data/test/helpers/misc.rb +87 -0
  91. data/test/helpers/transaction_sample.rb +44 -0
  92. data/test/multiverse/lib/multiverse/suite.rb +6 -91
  93. data/test/multiverse/script/runner +1 -1
  94. data/test/multiverse/suites/active_record/Envfile +1 -28
  95. data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
  96. data/test/multiverse/suites/active_record/config/database.rb +2 -3
  97. data/test/multiverse/suites/active_record/config/database.yml +0 -2
  98. data/test/multiverse/suites/activemerchant/Envfile +4 -18
  99. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
  100. data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
  101. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
  102. data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
  103. data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
  104. data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
  105. data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
  106. data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
  107. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
  108. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
  109. data/test/multiverse/suites/capistrano/Envfile +2 -4
  110. data/test/multiverse/suites/capistrano2/Envfile +0 -4
  111. data/test/multiverse/suites/curb/Envfile +3 -7
  112. data/test/multiverse/suites/datamapper/Envfile +2 -2
  113. data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
  114. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
  115. data/test/multiverse/suites/delayed_job/Envfile +28 -41
  116. data/test/multiverse/suites/excon/Envfile +0 -3
  117. data/test/multiverse/suites/grape/Envfile +0 -4
  118. data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
  119. data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
  120. data/test/multiverse/suites/json/Envfile +1 -9
  121. data/test/multiverse/suites/marshalling/Envfile +0 -9
  122. data/test/multiverse/suites/memcached/Envfile +5 -23
  123. data/test/multiverse/suites/mongo/Envfile +9 -11
  124. data/test/multiverse/suites/padrino/Envfile +0 -6
  125. data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
  126. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
  127. data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
  128. data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
  129. data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
  130. data/test/multiverse/suites/rails/Envfile +1 -19
  131. data/test/multiverse/suites/rails/activejob_test.rb +1 -2
  132. data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
  133. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
  134. data/test/multiverse/suites/rake/Envfile +15 -22
  135. data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
  136. data/test/multiverse/suites/sequel/database.rb +1 -4
  137. data/test/multiverse/suites/sidekiq/Envfile +13 -23
  138. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
  139. data/test/multiverse/suites/typhoeus/Envfile +0 -19
  140. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
  141. data/test/multiverse/suites/yajl/Envfile +5 -0
  142. data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
  143. data/test/new_relic/agent/agent/start_test.rb +3 -3
  144. data/test/new_relic/agent/agent_logger_test.rb +2 -2
  145. data/test/new_relic/agent/agent_test.rb +2 -2
  146. data/test/new_relic/agent/attribute_processing_test.rb +3 -4
  147. data/test/new_relic/agent/audit_logger_test.rb +4 -6
  148. data/test/new_relic/agent/aws_info_test.rb +17 -1
  149. data/test/new_relic/agent/busy_calculator_test.rb +14 -16
  150. data/test/new_relic/agent/configuration/manager_test.rb +1 -7
  151. data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
  152. data/test/new_relic/agent/database_test.rb +2 -10
  153. data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
  154. data/test/new_relic/agent/datastores/redis_test.rb +14 -16
  155. data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
  156. data/test/new_relic/agent/error_collector_test.rb +16 -49
  157. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
  158. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
  159. data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
  160. data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
  161. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
  162. data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
  163. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
  164. data/test/new_relic/agent/method_tracer_test.rb +35 -76
  165. data/test/new_relic/agent/new_relic_service_test.rb +86 -102
  166. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
  167. data/test/new_relic/agent/pipe_service_test.rb +2 -3
  168. data/test/new_relic/agent/rpm_agent_test.rb +0 -4
  169. data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
  170. data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
  171. data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
  172. data/test/new_relic/agent/sized_buffer_test.rb +1 -1
  173. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
  174. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
  175. data/test/new_relic/agent/stats_test.rb +6 -8
  176. data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
  177. data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
  178. data/test/new_relic/agent/transaction_test.rb +2 -10
  179. data/test/new_relic/agent/utilization_data_test.rb +17 -1
  180. data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
  181. data/test/new_relic/agent_test.rb +0 -43
  182. data/test/new_relic/coerce_test.rb +1 -3
  183. data/test/new_relic/fake_collector.rb +3 -3
  184. data/test/new_relic/fake_external_server.rb +1 -1
  185. data/test/new_relic/fake_server.rb +1 -1
  186. data/test/new_relic/http_client_test_cases.rb +3 -3
  187. data/test/new_relic/language_support_test.rb +6 -12
  188. data/test/new_relic/latest_changes_test.rb +0 -11
  189. data/test/new_relic/license_test.rb +3 -8
  190. data/test/new_relic/multiverse_helpers.rb +1 -1
  191. data/test/new_relic/noticed_error_test.rb +11 -7
  192. data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
  193. data/test/nullverse/nullverse_helper.rb +1 -1
  194. data/test/performance/lib/performance.rb +1 -1
  195. data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
  196. data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
  197. data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
  198. data/test/performance/lib/performance/platform.rb +1 -8
  199. data/test/performance/script/runner +1 -3
  200. data/test/performance/suites/active_record.rb +3 -24
  201. data/test/test_helper.rb +9 -216
  202. metadata +9 -45
  203. data/lib/conditional_vendored_dependency_detection.rb +0 -7
  204. data/lib/new_relic/agent/hash_extensions.rb +0 -41
  205. data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
  206. data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
  207. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
  208. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
  209. data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
  210. data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
  211. data/lib/new_relic/json_wrapper.rb +0 -78
  212. data/lib/new_relic/okjson.rb +0 -602
  213. data/lib/new_relic/rack/error_collector.rb +0 -27
  214. data/lib/new_relic/timer_lib.rb +0 -31
  215. data/test/helpers/runtime_detection.rb +0 -17
  216. data/test/multiverse/suites/no_json/Envfile +0 -12
  217. data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
  218. data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
  219. data/test/new_relic/agent/hash_extensions_test.rb +0 -59
  220. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
  221. data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
  222. data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
  223. data/test/new_relic/json_wrapper_test.rb +0 -32
  224. data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
  225. data/test/new_relic/rack/error_collector_test.rb +0 -83
  226. data/test/new_relic/version_number_test.rb +0 -101
  227. data/test/script/before_install/revert_rubygems.sh +0 -15
  228. data/test/script/before_install/update_bundler.sh +0 -12
  229. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -1,6 +1,6 @@
1
1
  mysql: &mysql
2
2
  adapter: mysql
3
- socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
3
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" : "/tmp/mysql.sock" %>
4
4
  username: root
5
5
  host: localhost
6
6
  database: <%= db = "#{ENV['RUBY_VERSION']}#{ENV['BRANCH']}"; db.empty? ? "rails_blog" : db %>
@@ -4,23 +4,6 @@ gem 'rake', '< 11'
4
4
 
5
5
  gem 'rails', '~>4.0.13'
6
6
 
7
- # mime-types 2.99.1 and 3.x introduce mime-types-data
8
- # mime-types-data requires Ruby version >= 2.0
9
- # mime-types 2.99 requires Ruby version >= 1.9.3
10
- if RUBY_VERSION < '1.9.3'
11
- gem 'mime-types', '1.25.1'
12
- elsif RUBY_VERSION < '2'
13
- gem 'mime-types', '< 3'
14
- end
15
-
16
- # Do not automatically require minitest, since this will break with rbx-2.2.5.
17
- # rbx-2.2.5 helpfully bundles minitest-5.3.0.
18
- # Our tests don't work with minitest-5.3.0.
19
- # minitest-4.7.5 is the version we want to use here, but if you just do
20
- # a require 'minitest' on rbx-2.2.5, you'll get 5.3.0 (since 4.7.5 doesn't
21
- # actually have a minitest.rb file under lib/). The :require => false prevents
22
- # us from inadvertently loading minitest 5.3.0 on rbx (we'll require
23
- # minitest/unit instead via a different path).
24
7
  gem 'minitest', '~>4.7.5', :require => false
25
8
  gem 'mocha', '1.1', :require => false
26
9
  gem 'rack', '< 2.0.0'
@@ -37,15 +20,6 @@ platforms :ruby do
37
20
  gem "sqlite3"
38
21
  end
39
22
 
40
- platforms :rbx do
41
- gem "rubysl"
42
- gem "json", '< 2.0.0'
43
- # If we don't skip the require here, test-unit tries to install its at_exit
44
- # hook and run when we run our rake task to create the test DB.
45
- gem "rubysl-test-unit", :require => false
46
- gem "racc" # https://github.com/rubinius/rubinius/issues/2632
47
- end
48
-
49
23
  gem "newrelic_rpm", :path => "../../.."
50
24
 
51
25
  gem 'pry', '~> 0.9.12'
@@ -1,6 +1,6 @@
1
1
  mysql: &mysql
2
2
  adapter: mysql2
3
- socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
3
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" : "/tmp/mysql.sock" %>
4
4
  username: root
5
5
  host: localhost
6
6
  database: <%= db = "#{ENV['RUBY_VERSION']}#{ENV['BRANCH']}"; db.empty? ? "rails_blog" : db %>
@@ -4,15 +4,6 @@ gem 'rake', '< 11'
4
4
 
5
5
  gem 'rails', '~>4.1.10'
6
6
 
7
- # mime-types 2.99.1 and 3.x introduce mime-types-data
8
- # mime-types-data requires Ruby version >= 2.0
9
- # mime-types 2.99 requires Ruby version >= 1.9.3
10
- if RUBY_VERSION < '1.9.3'
11
- gem 'mime-types', '1.25.1'
12
- elsif RUBY_VERSION < '2'
13
- gem 'mime-types', '< 3'
14
- end
15
-
16
7
  gem 'minitest', '5.2.3'
17
8
  gem 'mocha', '1.1', :require => false
18
9
  gem 'rack', '< 2.0.0'
@@ -29,15 +20,6 @@ platforms :ruby do
29
20
  gem "sqlite3"
30
21
  end
31
22
 
32
- platforms :rbx do
33
- gem "rubysl"
34
- gem "json", '< 2.0.0'
35
- # If we don't skip the require here, test-unit tries to install its at_exit
36
- # hook and run when we run our rake task to create the test DB.
37
- gem "rubysl-test-unit", :require => false
38
- gem "racc" # https://github.com/rubinius/rubinius/issues/2632
39
- end
40
-
41
23
  gem "newrelic_rpm", :path => "../../.."
42
24
 
43
25
  gem 'pry', '~> 0.9.12'
@@ -1,6 +1,6 @@
1
1
  mysql: &mysql
2
2
  adapter: mysql2
3
- socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
3
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" : "/tmp/mysql.sock" %>
4
4
  username: root
5
5
  host: localhost
6
6
  database: <%= db = "#{ENV['RUBY_VERSION']}#{ENV['BRANCH']}"; db.empty? ? "rails_blog" : db %>
@@ -4,15 +4,6 @@ gem 'rake', '< 11'
4
4
 
5
5
  gem 'rails', '~>4.2.1'
6
6
 
7
- # mime-types 2.99.1 and 3.x introduce mime-types-data
8
- # mime-types-data requires Ruby version >= 2.0
9
- # mime-types 2.99 requires Ruby version >= 1.9.3
10
- if RUBY_VERSION < '1.9.3'
11
- gem 'mime-types', '1.25.1'
12
- elsif RUBY_VERSION < '2'
13
- gem 'mime-types', '< 3'
14
- end
15
-
16
7
  gem 'minitest', '5.2.3'
17
8
  gem 'mocha', '1.1', :require => false
18
9
  gem 'rack', '< 2.0.0'
@@ -29,19 +20,6 @@ platforms :ruby do
29
20
  gem "sqlite3"
30
21
  end
31
22
 
32
- platforms :rbx do
33
- gem "rubysl"
34
- gem "json", '< 2.0.0'
35
- # If we don't skip the require here, test-unit tries to install its at_exit
36
- # hook and run when we run our rake task to create the test DB.
37
- gem "rubysl-test-unit", :require => false
38
- gem "racc" # https://github.com/rubinius/rubinius/issues/2632
39
-
40
- # Compilation issues with rubysl-openssl 2.2.1, lock at 2.1.0 for now.
41
- # https://github.com/rubysl/rubysl-openssl/issues/11
42
- gem "rubysl-openssl", "2.1.0"
43
- end
44
-
45
23
  gem "newrelic_rpm", :path => "../../.."
46
24
 
47
25
  gem 'pry', '~> 0.9.12'
@@ -1,6 +1,6 @@
1
1
  mysql: &mysql
2
2
  adapter: mysql2
3
- socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
3
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" : "/tmp/mysql.sock" %>
4
4
  username: root
5
5
  host: localhost
6
6
  database: <%= db = "#{ENV['RUBY_VERSION']}#{ENV['BRANCH']}"; db.empty? ? "rails_blog" : db %>
@@ -17,19 +17,6 @@ platforms :ruby do
17
17
  gem "mysql2"
18
18
  end
19
19
 
20
- platforms :rbx do
21
- gem "rubysl"
22
- gem "json", '< 2.0.0'
23
- # If we don't skip the require here, test-unit tries to install its at_exit
24
- # hook and run when we run our rake task to create the test DB.
25
- gem "rubysl-test-unit", :require => false
26
- gem "racc" # https://github.com/rubinius/rubinius/issues/2632
27
-
28
- # Compilation issues with rubysl-openssl 2.2.1, lock at 2.1.0 for now.
29
- # https://github.com/rubysl/rubysl-openssl/issues/11
30
- gem "rubysl-openssl", "2.1.0"
31
- end
32
-
33
20
  gem "newrelic_rpm", :path => "../../.."
34
21
 
35
22
  gem 'pry', '~> 0.9.12'
@@ -1,6 +1,6 @@
1
1
  mysql: &mysql
2
2
  adapter: mysql2
3
- socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
3
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" : "/tmp/mysql.sock" %>
4
4
  username: root
5
5
  host: localhost
6
6
  database: <%= db = "#{ENV['RUBY_VERSION']}#{ENV['BRANCH']}"; db.empty? ? "rails_blog" : db %>
@@ -0,0 +1,37 @@
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
+ def with_verbose_logging
6
+ orig_logger = NewRelic::Agent.logger
7
+ $stderr.puts '', '---', ''
8
+ new_logger = NewRelic::Agent::AgentLogger.new('', Logger.new($stderr) )
9
+ NewRelic::Agent.logger = new_logger
10
+
11
+ with_config(:log_level => 'debug') do
12
+ yield
13
+ end
14
+ ensure
15
+ NewRelic::Agent.logger = orig_logger
16
+ end
17
+
18
+ # Need to be a bit sloppy when testing against the logging--let everything
19
+ # through, but check we (at least) get our particular message we care about
20
+ def expects_logging(level, *with_params)
21
+ ::NewRelic::Agent.logger.stubs(level)
22
+ ::NewRelic::Agent.logger.expects(level).with(*with_params).once
23
+ end
24
+
25
+ def expects_no_logging(level)
26
+ ::NewRelic::Agent.logger.expects(level).never
27
+ end
28
+
29
+ # Sometimes need to test cases where we muddle with the global logger
30
+ # If so, use this method to ensure it gets restored after we're done
31
+ def without_logger
32
+ logger = ::NewRelic::Agent.logger
33
+ ::NewRelic::Agent.logger = nil
34
+ yield
35
+ ensure
36
+ ::NewRelic::Agent.logger = logger
37
+ end
@@ -0,0 +1,50 @@
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
+ unless defined?(Minitest::Test)
6
+ Minitest::Test = MiniTest::Unit::TestCase
7
+ end
8
+
9
+ # Set up a watcher for leaking agent threads out of tests. It'd be nice to
10
+ # disable the threads everywhere, but not all tests have newrelic.yml loaded to
11
+ # us to rely on, so instead we'll just watch for it.
12
+ class Minitest::Test
13
+
14
+ def before_setup
15
+ if self.respond_to?(:name)
16
+ test_method_name = self.name
17
+ else
18
+ test_method_name = self.__name__
19
+ end
20
+
21
+ NewRelic::Agent.logger.info("*** #{self.class}##{test_method_name} **")
22
+
23
+ @__thread_count = ruby_threads.count
24
+ super
25
+ end
26
+
27
+ def after_teardown
28
+ unfreeze_time
29
+
30
+ threads = ruby_threads
31
+ if @__thread_count != threads.count
32
+ backtraces = threads.map do |thread|
33
+ trace = Hometown.for(thread)
34
+ trace.backtrace.join("\n ")
35
+ end.join("\n\n")
36
+
37
+ fail "Thread count changed in this test from #{@__thread_count} to #{threads.count}\n#{backtraces}"
38
+ end
39
+
40
+ super
41
+ end
42
+
43
+ # We only want to count threads that were spun up from Ruby (i.e.
44
+ # Thread.new) JRuby has system threads we don't care to track.
45
+ def ruby_threads
46
+ Thread.list.select { |t| Hometown.for(t) }
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,87 @@
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
+ def default_service(stubbed_method_overrides = {})
6
+ service = stub
7
+ stubbed_method_defaults = {
8
+ :connect => {},
9
+ :shutdown => nil,
10
+ :agent_id= => nil,
11
+ :agent_id => nil,
12
+ :collector => stub_everything,
13
+ :request_timeout= => nil,
14
+ :metric_data => nil,
15
+ :error_data => nil,
16
+ :transaction_sample_data => nil,
17
+ :sql_trace_data => nil,
18
+ :get_agent_commands => [],
19
+ :agent_command_results => nil,
20
+ :analytic_event_data => nil,
21
+ :valid_to_marshal? => true
22
+ }
23
+
24
+ service.stubs(stubbed_method_defaults.merge(stubbed_method_overrides))
25
+
26
+ # When session gets called yield to the given block.
27
+ service.stubs(:session).yields
28
+ service
29
+ end
30
+
31
+ def fixture_tcp_socket( response )
32
+ # Don't actually talk to Google.
33
+ socket = stub("socket") do
34
+ stubs(:closed?).returns(false)
35
+ stubs(:close)
36
+ stubs(:setsockopt)
37
+
38
+ # Simulate a bunch of socket-ey stuff since Mocha doesn't really
39
+ # provide any other way to do it
40
+ class << self
41
+ attr_accessor :response, :write_checker
42
+ end
43
+
44
+ def self.check_write
45
+ self.write_checker = Proc.new
46
+ end
47
+
48
+ def self.write( buf )
49
+ self.write_checker.call( buf ) if self.write_checker
50
+ buf.length
51
+ end
52
+
53
+ def self.sysread( size, buf='' )
54
+ @data ||= response.to_s
55
+ raise EOFError if @data.empty?
56
+ buf.replace @data.slice!( 0, size )
57
+ buf
58
+ end
59
+ class << self
60
+ alias_method :read_nonblock, :sysread
61
+ end
62
+
63
+ end
64
+
65
+ socket.response = response
66
+ TCPSocket.stubs( :open ).returns( socket )
67
+
68
+ return socket
69
+ end
70
+
71
+ def dummy_mysql_explain_result(hash=nil)
72
+ hash ||= {
73
+ 'Id' => '1',
74
+ 'Select Type' => 'SIMPLE',
75
+ 'Table' => 'sandwiches',
76
+ 'Type' => 'range',
77
+ 'Possible Keys' => 'PRIMARY',
78
+ 'Key' => 'PRIMARY',
79
+ 'Key Length' => '4',
80
+ 'Ref' => '',
81
+ 'Rows' => '1',
82
+ 'Extra' => 'Using index'
83
+ }
84
+ explain_result = mock('explain result')
85
+ explain_result.stubs(:each_hash).yields(hash)
86
+ explain_result
87
+ end
@@ -0,0 +1,44 @@
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
+ module TransactionSampleTestHelper
6
+ module_function
7
+ def make_sql_transaction(*sql)
8
+ sampler = nil
9
+ state = NewRelic::Agent::TransactionState.tl_get
10
+
11
+ in_transaction('/path') do
12
+ sampler = NewRelic::Agent.instance.transaction_sampler
13
+ sampler.notice_push_frame(state, "a")
14
+ explainer = NewRelic::Agent::Instrumentation::ActiveRecord::EXPLAINER
15
+ sql.each {|sql_statement| sampler.notice_sql(sql_statement, {:adapter => "mysql"}, 0, state, explainer) }
16
+ sleep 0.02
17
+ yield if block_given?
18
+ sampler.notice_pop_frame(state, "a")
19
+ end
20
+
21
+ return sampler.last_sample
22
+ end
23
+
24
+ def run_sample_trace(path='/path')
25
+ sampler = nil
26
+ state = NewRelic::Agent::TransactionState.tl_get
27
+
28
+ request = stub(:path => path)
29
+
30
+ in_transaction("Controller/sandwiches/index", :request => request) do
31
+ sampler = NewRelic::Agent.instance.transaction_sampler
32
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0, state)
33
+ sampler.notice_push_frame(state, "ab")
34
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'white'", {}, 0, state)
35
+ yield sampler if block_given?
36
+ sampler.notice_pop_frame(state, "ab")
37
+ sampler.notice_push_frame(state, "lew")
38
+ sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'french'", {}, 0, state)
39
+ sampler.notice_pop_frame(state, "lew")
40
+ end
41
+
42
+ return sampler.last_sample
43
+ end
44
+ end
@@ -165,7 +165,6 @@ module Multiverse
165
165
 
166
166
  def generate_gemfile(gemfile_text, env_index, local = true)
167
167
  pin_rack_version_if_needed(gemfile_text)
168
- pin_json_version_if_needed(gemfile_text)
169
168
 
170
169
  gemfile = File.join(Dir.pwd, "Gemfile.#{env_index}")
171
170
  File.open(gemfile,'w') do |f|
@@ -173,24 +172,15 @@ module Multiverse
173
172
  f.print gemfile_text
174
173
  f.puts newrelic_gemfile_line unless gemfile_text =~ /^\s*gem .newrelic_rpm./
175
174
  f.puts jruby_openssl_line unless gemfile_text =~ /^\s*gem .jruby-openssl./ || (defined?(JRUBY_VERSION) && JRUBY_VERSION > '1.7')
176
- f.puts mime_types_line unless gemfile_text =~ /^\s*gem .mime-types[^_-]./
177
175
  f.puts minitest_line unless gemfile_text =~ /^\s*gem .minitest[^_]./
178
- f.puts rake_line unless gemfile_text =~ /^\s*gem .rake[^_]./ || suite == 'rake'
179
- if RUBY_VERSION == "1.8.7"
180
- f.puts "gem 'json', '< 1.8.5'" unless gemfile_text =~ /^\s.*gem .json./
181
- end
182
-
183
- rbx_gemfile_lines(f, gemfile_text)
176
+ f.puts "gem 'rake'" unless gemfile_text =~ /^\s*gem .rake[^_]./ || suite == 'rake'
184
177
 
185
178
  f.puts " gem 'mocha', '0.14.0', :require => false"
186
179
 
187
180
  if debug
188
- pry_version = RUBY_VERSION > '1.8.7' ? '0.10.0' : '0.9.12'
189
-
190
- # Pry 0.10.0 breaks compatibility with Ruby 1.8.7 :(
191
- f.puts " gem 'pry', '~> #{pry_version}'"
192
- f.puts " gem 'pry-byebug'" if defined?(RUBY_ENGINE) && RUBY_VERSION >= "2.0.0" && RUBY_ENGINE == "ruby"
193
- f.puts " gem 'pry-stack_explorer'" if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby"
181
+ f.puts " gem 'pry', '~> 0.10.0'"
182
+ f.puts " gem 'pry-byebug', platforms: :mri"
183
+ f.puts " gem 'pry-stack_explorer', platforms: :mri"
194
184
  end
195
185
  end
196
186
  puts yellow("Gemfile.#{env_index} set to:") if verbose?
@@ -204,33 +194,10 @@ module Multiverse
204
194
  line
205
195
  end
206
196
 
207
- def rbx_gemfile_lines(f, gemfile_text)
208
- return unless is_rbx?
209
-
210
- f.puts "gem 'rubysl', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .rubysl./
211
- f.puts "gem 'json', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .json./
212
- f.puts "gem 'racc', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .racc./
213
- end
214
-
215
- def is_rbx?
216
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
217
- end
218
-
219
197
  def jruby_openssl_line
220
198
  "gem 'jruby-openssl', '~> 0.9.10', :require => false, :platforms => [:jruby]"
221
199
  end
222
200
 
223
- # mime-types got a new dependency after 2.99 that breaks compatibility with ruby < 2.0
224
- def mime_types_line
225
- if RUBY_VERSION <= '1.9.3'
226
- "gem 'mime-types', '1.25.1'"
227
- elsif RUBY_VERSION < '2'
228
- "gem 'mime-types', '2.99'"
229
- else
230
- ''
231
- end
232
- end
233
-
234
201
  def minitest_line
235
202
  "gem 'minitest', '~> #{minitest_version}', :require => false"
236
203
  end
@@ -250,15 +217,6 @@ module Multiverse
250
217
  require 'minitest/unit'
251
218
  end
252
219
 
253
- # rake 11 dropped support for ruby < 1.9.3
254
- def rake_line
255
- if RUBY_VERSION < '1.9.3'
256
- "gem 'rake', '< 11'"
257
- else
258
- "gem 'rake'"
259
- end
260
- end
261
-
262
220
  # Rack 2.0 works with Ruby > 2.2.2. Earlier rubies need to pin
263
221
  # their Rack version prior to 2.0
264
222
  def pin_rack_version_if_needed gemfile_text
@@ -269,49 +227,6 @@ module Multiverse
269
227
  end
270
228
  end
271
229
 
272
- # JSON gem version 2.0.0 requires Ruby ~> 2.0. We need to pin
273
- # the json version for older rubies. In some cases json is pulled
274
- # in by other libraries without pinning the version. For older rubies
275
- # we will preemptively require json with an appropriate version. None of
276
- # this is ideal and should be fixed, either by this PR to bundler:
277
- # https://github.com/bundler/bundler/pull/4650 or with a better solution
278
- # in mutiverse.
279
- def pin_json_version_if_needed gemfile_text
280
- return if suite == "json" || suite == "no_json" || suite == "datamapper" ||
281
- RUBY_VERSION >= "2.0.0" && RUBY_VERSION < "2.4.0" &&
282
- !pin_json_for_jruby?
283
-
284
- match = gemfile_text.match(/^\s*?(gem\s*?['"]json['"]).*?$/)
285
- version = json_version
286
- if match
287
- return if match[0].include? version
288
-
289
- replacement = match[0].gsub(match[1], "#{match[1]}, '#{version}'")
290
- gemfile_text.gsub! match[0], replacement
291
- else
292
- gemfile_text.concat "\ngem 'json', '#{version}'\n"
293
- end
294
- end
295
-
296
- def json_version
297
- case
298
- when RUBY_VERSION >= '2.4'
299
- '~> 2.0.2'
300
- when RUBY_VERSION == '1.8.7'
301
- '< 1.8.5'
302
- else
303
- '< 2.0.0'
304
- end
305
- end
306
-
307
- # Bundler does not seem to be able to find version 2.0.1 of the json
308
- # gem for jruby 9000. This is likely a temporary situation and we
309
- # can probably remove this check in the near future. For now we need
310
- # this for CI to pass.
311
- def pin_json_for_jruby?
312
- defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && RUBY_VERSION >= "2.0.0"
313
- end
314
-
315
230
  def print_environment
316
231
  puts yellow("Environment loaded with:") if verbose?
317
232
  gems = Bundler.definition.specs.inject([]) do |m, s|
@@ -564,8 +479,8 @@ module Multiverse
564
479
 
565
480
  def require_helpers
566
481
  # If used from a 3rd-party, these paths likely need to be added
567
- $LOAD_PATH << File.expand_path(File.join(__FILE__, "..", "..", "..", ".."))
568
- $LOAD_PATH << File.expand_path(File.join(__FILE__, "..", "..", "..", "..", "new_relic"))
482
+ $: << File.expand_path('../../../..', __FILE__)
483
+ $: << File.expand_path('../../../../new_relic', __FILE__)
569
484
  require 'multiverse_helpers'
570
485
  end
571
486