newrelic_rpm 3.9.1.236 → 3.9.2.239

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data.tar.gz.sig +2 -4
  2. data/CHANGELOG +96 -2
  3. data/lib/new_relic/agent.rb +47 -4
  4. data/lib/new_relic/agent/agent.rb +51 -26
  5. data/lib/new_relic/agent/agent_logger.rb +4 -0
  6. data/lib/new_relic/agent/configuration.rb +2 -32
  7. data/lib/new_relic/agent/configuration/default_source.rb +153 -118
  8. data/lib/new_relic/agent/configuration/dotted_hash.rb +52 -0
  9. data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
  10. data/lib/new_relic/agent/configuration/manager.rb +101 -2
  11. data/lib/new_relic/agent/configuration/manual_source.rb +17 -0
  12. data/lib/new_relic/agent/configuration/server_source.rb +12 -4
  13. data/lib/new_relic/agent/configuration/yaml_source.rb +46 -22
  14. data/lib/new_relic/agent/cross_app_monitor.rb +1 -1
  15. data/lib/new_relic/agent/cross_app_tracing.rb +1 -1
  16. data/lib/new_relic/agent/database/obfuscation_helpers.rb +55 -14
  17. data/lib/new_relic/agent/database/obfuscator.rb +22 -7
  18. data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +6 -8
  19. data/lib/new_relic/agent/error_collector.rb +24 -16
  20. data/lib/new_relic/agent/event_loop.rb +189 -0
  21. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +8 -17
  22. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
  24. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -16
  25. data/lib/new_relic/agent/instrumentation/ignore_actions.rb +41 -0
  26. data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -11
  27. data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
  28. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -8
  29. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -9
  30. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -18
  31. data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
  33. data/lib/new_relic/agent/instrumentation/sinatra.rb +12 -1
  34. data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
  35. data/lib/new_relic/agent/method_tracer.rb +33 -39
  36. data/lib/new_relic/agent/new_relic_service.rb +35 -156
  37. data/lib/new_relic/agent/new_relic_service/encoders.rb +34 -0
  38. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +50 -0
  39. data/lib/new_relic/agent/new_relic_service/marshaller.rb +52 -0
  40. data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +52 -0
  41. data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
  42. data/lib/new_relic/agent/traced_method_stack.rb +16 -2
  43. data/lib/new_relic/agent/transaction.rb +0 -4
  44. data/lib/new_relic/collection_helper.rb +2 -2
  45. data/lib/new_relic/control/frameworks/rails.rb +3 -0
  46. data/lib/new_relic/control/instrumentation.rb +6 -2
  47. data/lib/new_relic/json_wrapper.rb +47 -25
  48. data/lib/new_relic/language_support.rb +0 -4
  49. data/lib/new_relic/latest_changes.rb +2 -2
  50. data/lib/new_relic/rack/developer_mode.rb +4 -3
  51. data/lib/new_relic/recipes/capistrano3.rb +2 -2
  52. data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
  53. data/lib/new_relic/timer_lib.rb +1 -1
  54. data/lib/new_relic/version.rb +2 -2
  55. data/lib/tasks/config.html.erb +28 -0
  56. data/lib/tasks/config.rake +134 -0
  57. data/lib/tasks/config.text.erb +7 -0
  58. data/lib/tasks/install.rake +0 -63
  59. data/newrelic.yml +7 -0
  60. data/test/active_record_fixtures.rb +4 -4
  61. data/test/agent_helper.rb +58 -18
  62. data/test/environments/lib/environments/runner.rb +1 -1
  63. data/test/environments/rails21/Gemfile +1 -1
  64. data/test/environments/rails21/config/boot.rb +1 -1
  65. data/test/environments/rails22/Gemfile +1 -1
  66. data/test/environments/rails22/config/boot.rb +1 -1
  67. data/test/environments/rails23/config/boot.rb +2 -2
  68. data/test/environments/rails30/Gemfile +1 -1
  69. data/test/environments/rails31/Gemfile +1 -1
  70. data/test/environments/rails32/Gemfile +1 -1
  71. data/test/environments/rails40/Gemfile +1 -1
  72. data/test/environments/rails41/Gemfile +1 -1
  73. data/test/fixtures/cross_agent_tests/labels.json +104 -0
  74. data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +23 -0
  75. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +1 -0
  76. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +1 -0
  77. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +1 -0
  78. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +1 -0
  79. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +1 -0
  80. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +1 -0
  81. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +2 -0
  82. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +2 -0
  83. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.obfuscated +1 -0
  84. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.sql +2 -0
  85. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +1 -0
  86. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +1 -0
  87. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +2 -0
  88. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +2 -0
  89. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +1 -0
  90. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +1 -0
  91. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +1 -0
  92. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +4 -0
  93. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +1 -0
  94. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +1 -0
  95. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.obfuscated +1 -0
  96. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.sql +2 -0
  97. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.obfuscated +1 -0
  98. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.sql +4 -0
  99. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.obfuscated +1 -0
  100. data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.sql +3 -0
  101. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +1 -0
  102. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +1 -0
  103. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +1 -0
  104. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +1 -0
  105. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +1 -0
  106. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +1 -0
  107. data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.obfuscated +1 -0
  108. data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.sql +1 -0
  109. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +1 -0
  110. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +1 -0
  111. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +1 -0
  112. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +1 -0
  113. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +1 -0
  114. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +4 -0
  115. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +1 -0
  116. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +1 -0
  117. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +1 -0
  118. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +2 -0
  119. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +1 -0
  120. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +1 -0
  121. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +1 -0
  122. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +1 -0
  123. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +1 -0
  124. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +4 -0
  125. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +1 -0
  126. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +1 -0
  127. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +1 -0
  128. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +1 -0
  129. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +1 -0
  130. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +1 -0
  131. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +1 -0
  132. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +1 -0
  133. data/test/multiverse/lib/multiverse/output_collector.rb +1 -1
  134. data/test/multiverse/lib/multiverse/runner.rb +1 -1
  135. data/test/multiverse/lib/multiverse/suite.rb +19 -4
  136. data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -38
  137. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +25 -35
  138. data/test/multiverse/suites/agent_only/config/newrelic.yml +2 -0
  139. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -0
  140. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
  141. data/test/multiverse/suites/agent_only/keepalive_test.rb +29 -0
  142. data/test/multiverse/suites/agent_only/labels_test.rb +89 -0
  143. data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -3
  144. data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
  145. data/test/multiverse/suites/agent_only/start_up_test.rb +9 -1
  146. data/test/multiverse/suites/capistrano/config/deploy.rb +6 -2
  147. data/test/multiverse/suites/capistrano/deployment_test.rb +12 -4
  148. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +29 -1
  149. data/test/multiverse/suites/curb/Envfile +6 -2
  150. data/test/multiverse/suites/datamapper/Envfile +0 -4
  151. data/test/multiverse/suites/deferred_instrumentation/Envfile +0 -4
  152. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
  153. data/test/multiverse/suites/excon/Envfile +5 -4
  154. data/test/multiverse/suites/excon/excon_test.rb +1 -1
  155. data/test/multiverse/suites/httpclient/Envfile +0 -4
  156. data/test/multiverse/suites/marshalling/Envfile +12 -0
  157. data/test/multiverse/suites/marshalling/config/newrelic.yml +20 -0
  158. data/test/multiverse/suites/marshalling/marshalling_test.rb +60 -0
  159. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +1 -1
  160. data/test/multiverse/suites/mongo/helpers/mongo_replica_set.rb +1 -1
  161. data/test/multiverse/suites/mongo/helpers/mongo_server.rb +4 -4
  162. data/test/multiverse/suites/padrino/Envfile +0 -5
  163. data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
  164. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +1 -1
  165. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +2 -1
  166. data/test/multiverse/suites/rails/ignore_test.rb +22 -0
  167. data/test/multiverse/suites/rails/rails2_app/config/boot.rb +2 -2
  168. data/test/multiverse/suites/rails/rails2_app/config/routes.rb +1 -0
  169. data/test/multiverse/suites/resque/Envfile +0 -4
  170. data/test/multiverse/suites/sequel/Envfile +0 -5
  171. data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
  172. data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
  173. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +22 -0
  174. data/test/multiverse/suites/typhoeus/Envfile +1 -4
  175. data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -13
  176. data/test/new_relic/agent/agent_logger_test.rb +11 -0
  177. data/test/new_relic/agent/agent_test.rb +43 -20
  178. data/test/new_relic/agent/audit_logger_test.rb +7 -3
  179. data/test/new_relic/agent/commands/thread_profiler_session_test.rb +0 -1
  180. data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
  181. data/test/new_relic/agent/configuration/dotted_hash_test.rb +53 -0
  182. data/test/new_relic/agent/configuration/manager_test.rb +99 -6
  183. data/test/new_relic/agent/configuration/manual_source_test.rb +18 -0
  184. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
  185. data/test/new_relic/agent/configuration/yaml_source_test.rb +8 -4
  186. data/test/new_relic/agent/database/sql_obfuscation_test.rb +76 -0
  187. data/test/new_relic/agent/database_test.rb +2 -38
  188. data/test/new_relic/agent/error_collector/notice_error_test.rb +21 -3
  189. data/test/new_relic/agent/error_collector_test.rb +15 -2
  190. data/test/new_relic/agent/event_loop_test.rb +202 -0
  191. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -0
  192. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +283 -182
  193. data/test/new_relic/agent/method_tracer_test.rb +1 -2
  194. data/test/new_relic/agent/new_relic_service_test.rb +83 -27
  195. data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -6
  196. data/test/new_relic/agent/rpm_agent_test.rb +1 -8
  197. data/test/new_relic/agent/sql_sampler_test.rb +10 -8
  198. data/test/new_relic/agent/threading/backtrace_service_test.rb +1 -1
  199. data/test/new_relic/agent/traced_method_stack_test.rb +45 -13
  200. data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -2
  201. data/test/new_relic/agent/transaction_test.rb +3 -3
  202. data/test/new_relic/agent_test.rb +47 -8
  203. data/test/new_relic/collection_helper_test.rb +5 -5
  204. data/test/new_relic/control/instrumentation_test.rb +56 -0
  205. data/test/new_relic/control_test.rb +4 -3
  206. data/test/new_relic/fake_collector.rb +7 -2
  207. data/test/new_relic/http_client_test_cases.rb +4 -4
  208. data/test/new_relic/latest_changes_test.rb +3 -3
  209. data/test/new_relic/transaction_sample/segment_test.rb +0 -1
  210. data/test/new_relic/transaction_sample_test.rb +19 -2
  211. data/test/performance/lib/performance/runner.rb +4 -4
  212. data/test/performance/suites/marshalling.rb +46 -30
  213. data/test/performance/suites/sql_obfuscation.rb +30 -0
  214. data/test/test_helper.rb +1 -1
  215. data/ui/helpers/developer_mode_helper.rb +2 -2
  216. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +1 -1
  217. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
  218. metadata +84 -3
  219. metadata.gz.sig +0 -0
  220. data/test/environments/rails23/config/environments/development.rb +0 -11
@@ -155,10 +155,32 @@ bazbangbarn:
155
155
 
156
156
  log = with_array_logger { NewRelic::Agent.manual_start }
157
157
 
158
- assert_log_contains(log, /ERROR.*Failed to read or parse configuration file at config\/newrelic\.yml/)
158
+ assert_log_contains(log, /ERROR.*Failed ERB processing/)
159
159
  assert_log_contains(log, /\(erb\):4/)
160
160
  end
161
161
 
162
+ def test_exclude_commented_out_erb_lines
163
+ config_contents = <<-YAML
164
+ development:
165
+ foo: "success!!"
166
+ test:
167
+ foo: "success!!"
168
+ boom:
169
+ # <%= this is not ruby %>
170
+ YAML
171
+
172
+ path = File.join(File.dirname(__FILE__), 'config', 'newrelic.yml')
173
+ setup_config(path, {}, config_contents)
174
+ setup_agent
175
+
176
+ log = with_array_logger { NewRelic::Agent.manual_start }
177
+
178
+ assert_equal "success!!", NewRelic::Agent.config[:foo]
179
+
180
+ refute_log_contains(log, /ERROR.*Failed ERB processing/)
181
+ refute_log_contains(log, /\(erb\)/)
182
+ end
183
+
162
184
  def test_config_loads_from_env_NRCONFIG
163
185
  ENV["NRCONFIG"] = "/tmp/foo/bar.yml"
164
186
  assert_config_read_from("/tmp/foo/bar.yml")
@@ -184,4 +206,10 @@ bazbangbarn:
184
206
  failure_message = "Did not find '#{message}' in log. Log contained:\n#{lines.join('')}"
185
207
  assert (lines.any? { |line| line.match(message) }), failure_message
186
208
  end
209
+
210
+ def refute_log_contains(log, message)
211
+ lines = log.array
212
+ failure_message = "Found unexpected '#{message}' in log. Log contained:\n#{lines.join('')}"
213
+ refute (lines.any? { |line| line.match(message) }), failure_message
214
+ end
187
215
  end
@@ -2,8 +2,12 @@ suite_condition("Curb is not useful on JRuby") do
2
2
  RUBY_PLATFORM != 'java'
3
3
  end
4
4
 
5
+ # There appears to be a bug in curb 0.8.6 that manifests in hangs of this suite
6
+ # when run on Ruby 1.8.7 or REE, so don't run against that version on those
7
+ # Rubies.
8
+ curb_version_spec = RUBY_VERSION == "1.8.7" ? '0.8.5' : '~>0.8.6'
5
9
  gemfile <<-RB
6
- gem 'curb', '~> 0.8.4'
10
+ gem 'curb', '#{curb_version_spec}'
7
11
  gem 'rack'
8
12
  gem 'json', :platforms => [:rbx, :mri_18]
9
13
 
@@ -12,7 +16,7 @@ gemfile <<-RB
12
16
  RB
13
17
 
14
18
  gemfile <<-RB
15
- gem 'curb', '~> 0.8.4'
19
+ gem 'curb', '#{curb_version_spec}'
16
20
  gem 'rack'
17
21
  gem 'json', :platforms => [:rbx, :mri_18]
18
22
  RB
@@ -1,7 +1,3 @@
1
- suite_condition("Datamapper not supported in 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
3
- end
4
-
5
1
  omit_collector!
6
2
 
7
3
  gemfile <<-RB
@@ -1,7 +1,3 @@
1
- suite_condition("Sinatra not compatible with 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
3
- end
4
-
5
1
  gemfile <<-RB
6
2
  gem 'sinatra', '~> 1.4.0', :require => false
7
3
  gem 'rack-test', :require => 'rack/test'
@@ -75,7 +75,7 @@ class DeferredSinatraTestApp < Sinatra::Base
75
75
  @filtered ? 'got filtered' : 'nope'
76
76
  end
77
77
 
78
- get /\/regex.*/ do
78
+ get(/\/regex.*/) do
79
79
  "Yeah, regex's!"
80
80
  end
81
81
  end
@@ -1,9 +1,10 @@
1
- suite_condition("Excon not supported in 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
1
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
2
+ # Excon 0.10.0 doesn't seem to work on Rubinius 2.2.10
3
+ excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0)
4
+ else
5
+ excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0 0.10.0)
3
6
  end
4
7
 
5
- excon_versions = %w(0.25.0 0.24.0 0.19.0 0.18.0 0.10.0)
6
-
7
8
  excon_versions.each do |excon_version|
8
9
  gemfile <<-RB
9
10
  gem 'excon', '~> #{excon_version}'
@@ -72,7 +72,7 @@ class ExconTest < Minitest::Test
72
72
  conn = Excon.new("#{default_url}?status=500")
73
73
  begin
74
74
  conn.request(:method => :get, :expects => [200])
75
- rescue Excon::Errors::Error => e
75
+ rescue Excon::Errors::Error
76
76
  # meh
77
77
  end
78
78
 
@@ -1,7 +1,3 @@
1
- suite_condition("HTTPClient not supported in 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
3
- end
4
-
5
1
  httpclient_versions = %w(2.3.3 2.2.0)
6
2
 
7
3
  httpclient_versions.each do |httpclient_version|
@@ -0,0 +1,12 @@
1
+ gemfile <<-RB
2
+ gem 'rack'
3
+ RB
4
+
5
+ # On Ruby 1.8.7 we need to explicitly run with the JSON gem to get JSON
6
+ # serialization. Otherwise first env will run with pruby.
7
+ if RUBY_VERSION < "1.9"
8
+ gemfile <<-RB
9
+ gem 'json'
10
+ gem 'rack'
11
+ RB
12
+ end
@@ -0,0 +1,20 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ enabled: true
5
+ apdex_t: 0.24
6
+ ssl: false
7
+ monitor_mode: true
8
+ license_key: bootstrap_newrelic_admin_license_key_000
9
+ developer_mode: false
10
+ app_name: test
11
+ host: 127.0.0.1
12
+ api_host: 127.0.0.1
13
+ port: <%= $collector && $collector.port %>
14
+ transaction_tracer:
15
+ record_sql: obfuscated
16
+ enabled: true
17
+ stack_trace_threshold: 0.5
18
+ capture_params: false
19
+ browser_monitoring:
20
+ auto_instrument: true
@@ -0,0 +1,60 @@
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
+
7
+ # These tests are intended to exercise the basic marshalling functionality of
8
+ # the agent in it's different permutations (Ruby and JSON)
9
+ class MarshallingTest < Minitest::Test
10
+
11
+ include MultiverseHelpers
12
+
13
+ setup_and_teardown_agent
14
+
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
+ end
@@ -61,7 +61,7 @@ module MongoOperationTests
61
61
  @collection.save(@tribble)
62
62
 
63
63
  metrics = build_test_metrics(:save)
64
- expected = metrics_with_attributes(metrics)
64
+ metrics_with_attributes(metrics)
65
65
 
66
66
  assert_metrics_not_recorded(['Datastore/operation/MongoDB/insert'])
67
67
  end
@@ -40,7 +40,7 @@ class MongoReplicaSet
40
40
  tries = 0
41
41
 
42
42
  begin
43
- result = yield
43
+ yield
44
44
  rescue exception => e
45
45
  if message
46
46
  raise e unless e.message.include? message
@@ -143,7 +143,7 @@ class MongoServer
143
143
  begin
144
144
  self.client = client_class.new('localhost', self.port, :connect_timeout => 10)
145
145
  rescue Mongo::ConnectionFailure => e
146
- raise e unless message = "Failed to connect to a master node at localhost:#{port}"
146
+ raise e unless message == "Failed to connect to a master node at localhost:#{port}"
147
147
  retry
148
148
  end
149
149
  end
@@ -152,7 +152,7 @@ class MongoServer
152
152
  if pid
153
153
  begin
154
154
  Process.kill('TERM', pid)
155
- rescue Errno::ESRCH => e
155
+ rescue Errno::ESRCH
156
156
  # fine if we're already gone...
157
157
  end
158
158
 
@@ -171,7 +171,7 @@ class MongoServer
171
171
  def running?
172
172
  return false unless pid
173
173
  Process.kill(0, pid) == 1
174
- rescue Errno::ESRCH => e
174
+ rescue Errno::ESRCH
175
175
  false
176
176
  end
177
177
 
@@ -214,7 +214,7 @@ class MongoServer
214
214
  tries = 0
215
215
 
216
216
  begin
217
- result = yield
217
+ yield
218
218
  rescue exception => e
219
219
  if message
220
220
  raise e unless e.message.include? message
@@ -1,8 +1,3 @@
1
- suite_condition("Sinatra not compatible with 1.8.6 or Rubinius") do
2
- is_rbx = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
3
- RUBY_VERSION != '1.8.6' && !is_rbx # https://github.com/rubinius/rubinius/issues/2671
4
- end
5
-
6
1
  gemfile <<-RB
7
2
  # Gemspec from rubygems on this version gets illformed warnings on 1.8.7
8
3
  gem 'http_router', '0.11.0', :git => 'git://github.com/joshbuddy/http_router.git', :tag => 'v0.11.0'
@@ -17,7 +17,7 @@ class PadrinoTestApp < Padrino::Application
17
17
  "please log in"
18
18
  end
19
19
 
20
- get /\/regex.*/ do
20
+ get(/\/regex.*/) do
21
21
  "with extra regex's please!"
22
22
  end
23
23
  end
@@ -126,7 +126,7 @@ class RackAutoInstrumentationTest < Minitest::Test
126
126
  end
127
127
 
128
128
  def test_middleware_that_returns_early_middleware_all_has_correct_call_times
129
- t0 = freeze_time
129
+ freeze_time
130
130
 
131
131
  get '/?return-early=true'
132
132
  assert_metrics_recorded('Middleware/all' => { :total_exclusive_time => 3.0, :call_count => 2 })
@@ -11,7 +11,7 @@ if NewRelic::LanguageSupport.ree? ||
11
11
  class GcController < ApplicationController
12
12
  def gc_action
13
13
  begin
14
- profiler = NewRelic::Agent::StatsEngine::GCProfiler.init
14
+ NewRelic::Agent::StatsEngine::GCProfiler.init
15
15
  initial_gc_count = current_gc_count
16
16
 
17
17
  Timeout.timeout(5) do
@@ -19,6 +19,7 @@ class GcController < ApplicationController
19
19
  long_string = "01234567" * 100_000
20
20
  long_string = nil
21
21
  another_long_string = "01234567" * 100_000
22
+ another_long_string = nil
22
23
  end
23
24
  end
24
25
  rescue Timeout::Error
@@ -19,6 +19,21 @@ class IgnoredController < ApplicationController
19
19
  end
20
20
  end
21
21
 
22
+ class ParentController < ApplicationController
23
+ newrelic_ignore_apdex
24
+
25
+ def foo(*args); end
26
+
27
+ add_transaction_tracer :foo
28
+ end
29
+
30
+ class ChildController < ParentController
31
+ def bar(*args); end
32
+
33
+ add_transaction_tracer :bar
34
+ end
35
+
36
+
22
37
  class IgnoredActionsTest < RailsMultiverseTest
23
38
  include MultiverseHelpers
24
39
 
@@ -54,4 +69,11 @@ class IgnoredActionsTest < RailsMultiverseTest
54
69
  get 'ignored/action_to_ignore', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
55
70
  assert_nil @response.headers["X-NewRelic-App-Data"]
56
71
  end
72
+
73
+ def test_apdex_ignored_if_ignored_in_parent_class
74
+ get 'child/foo'
75
+ get 'child/bar'
76
+
77
+ assert_metrics_not_recorded("Apdex")
78
+ end
57
79
  end
@@ -64,7 +64,7 @@ module Rails
64
64
  else
65
65
  gem 'rails'
66
66
  end
67
- rescue Gem::LoadError => load_error
67
+ rescue Gem::LoadError
68
68
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
69
69
  exit 1
70
70
  end
@@ -121,7 +121,7 @@ class Rails::Boot
121
121
 
122
122
  Rails::Initializer.run(:set_load_path)
123
123
  end
124
- end
124
+ end
125
125
 
126
126
  # All that for this:
127
127
  Rails.boot!
@@ -13,6 +13,7 @@ ActionController::Routing::Routes.draw do |map|
13
13
  map.connect 'views/:action', :controller => 'views'
14
14
  map.connect 'ignored/:action', :controller => 'ignored'
15
15
  map.connect 'parameter_capture/:action', :controller => 'parameter_capture'
16
+ map.connect 'child/:action', :controller => 'child'
16
17
 
17
18
  map.connect ':controller/:action'
18
19
  end
@@ -1,7 +1,3 @@
1
- suite_condition("Resque tests not compatible with 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
3
- end
4
-
5
1
  gemfile <<-RB
6
2
  gem 'resque', '1.23.0'
7
3
  gem 'json'
@@ -1,8 +1,3 @@
1
- suite_condition("Sequel not supported in 1.8.6") do
2
- RUBY_VERSION != '1.8.6'
3
- end
4
-
5
-
6
1
  gemfile <<-RB
7
2
  gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
8
3
  gem 'jdbc-sqlite3', '3.7.2', :platform => :jruby
@@ -80,7 +80,7 @@ get '/ignored' do
80
80
  "don't trace me bro"
81
81
  end
82
82
 
83
- get /\/regex.*/ do
83
+ get(/\/regex.*/) do
84
84
  "Yeah, regex's!"
85
85
  end
86
86
 
@@ -76,7 +76,7 @@ class SinatraModularTestApp < Sinatra::Base
76
76
  "don't trace me bro"
77
77
  end
78
78
 
79
- get /\/regex.*/ do
79
+ get(/\/regex.*/) do
80
80
  "Yeah, regex's!"
81
81
  end
82
82
  end
@@ -114,4 +114,26 @@ module SinatraTestCases
114
114
  assert_equal 200, last_response.status
115
115
  assert_metrics_not_recorded(["Controller/Sinatra/#{app_name}/GET ignored"])
116
116
  end
117
+
118
+ def test_rack_request_params_errors_are_swallowed
119
+ fail_on_second_params_call
120
+
121
+ get '/pass'
122
+ assert_equal 200, last_response.status
123
+ end
124
+
125
+ def test_rack_request_params_errors_are_logged
126
+ NewRelic::Agent.logger.stubs(:debug)
127
+ NewRelic::Agent.logger.expects(:debug).with("Failed to get params from Rack request.", kind_of(StandardError)).at_least_once
128
+
129
+ fail_on_second_params_call
130
+
131
+ get '/pass'
132
+ end
133
+
134
+ def fail_on_second_params_call
135
+ Sinatra::Request.any_instance.
136
+ stubs(:params).returns({}).
137
+ then.raises("Rack::Request#params error")
138
+ end
117
139
  end