newrelic_rpm 3.11.2.286 → 3.12.0.288

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/.yardopts +2 -0
  4. data/CHANGELOG +39 -4
  5. data/README.md +4 -2
  6. data/lib/new_relic/agent.rb +229 -214
  7. data/lib/new_relic/agent/agent.rb +23 -12
  8. data/lib/new_relic/agent/attribute_filter.rb +242 -0
  9. data/lib/new_relic/agent/attribute_processing.rb +62 -0
  10. data/lib/new_relic/agent/commands/xray_session_collection.rb +4 -1
  11. data/lib/new_relic/agent/configuration/default_source.rb +284 -30
  12. data/lib/new_relic/agent/configuration/high_security_source.rb +0 -8
  13. data/lib/new_relic/agent/configuration/manager.rb +1 -1
  14. data/lib/new_relic/agent/configuration/server_source.rb +86 -31
  15. data/lib/new_relic/agent/configuration/yaml_source.rb +1 -1
  16. data/lib/new_relic/agent/cross_app_monitor.rb +8 -13
  17. data/lib/new_relic/agent/cross_app_tracing.rb +15 -15
  18. data/lib/new_relic/agent/custom_event_aggregator.rb +6 -2
  19. data/lib/new_relic/agent/database.rb +15 -2
  20. data/lib/new_relic/agent/datastores.rb +52 -38
  21. data/lib/new_relic/agent/datastores/metric_helper.rb +2 -1
  22. data/lib/new_relic/agent/encoding_normalizer.rb +82 -0
  23. data/lib/new_relic/agent/error_collector.rb +125 -169
  24. data/lib/new_relic/agent/hash_extensions.rb +26 -0
  25. data/lib/new_relic/agent/http_clients/excon_wrappers.rb +13 -11
  26. data/lib/new_relic/agent/http_clients/uri_util.rb +9 -0
  27. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -3
  28. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +1 -1
  29. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  30. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +12 -5
  31. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +6 -7
  32. data/lib/new_relic/agent/instrumentation/curb.rb +6 -6
  33. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +4 -4
  34. data/lib/new_relic/agent/instrumentation/grape.rb +4 -3
  35. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +6 -3
  36. data/lib/new_relic/agent/instrumentation/rails/errors.rb +9 -3
  37. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -1
  38. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +9 -7
  39. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +8 -6
  40. data/lib/new_relic/agent/instrumentation/resque.rb +2 -3
  41. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -3
  42. data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
  43. data/lib/new_relic/agent/javascript_instrumentor.rb +24 -16
  44. data/lib/new_relic/agent/parameter_filtering.rb +8 -1
  45. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -2
  46. data/lib/new_relic/agent/sql_sampler.rb +1 -0
  47. data/lib/new_relic/agent/stats.rb +0 -4
  48. data/lib/new_relic/agent/stats_engine/metric_stats.rb +5 -3
  49. data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -0
  50. data/lib/new_relic/agent/supported_versions.rb +2 -2
  51. data/lib/new_relic/agent/traced_method_stack.rb +3 -3
  52. data/lib/new_relic/agent/transaction.rb +141 -118
  53. data/lib/new_relic/agent/transaction/attributes.rb +161 -0
  54. data/lib/new_relic/agent/transaction/developer_mode_sample_buffer.rb +4 -4
  55. data/lib/new_relic/agent/transaction/trace.rb +150 -0
  56. data/lib/new_relic/agent/transaction/trace_node.rb +190 -0
  57. data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +2 -2
  58. data/lib/new_relic/agent/transaction_event_aggregator.rb +23 -7
  59. data/lib/new_relic/agent/transaction_sample_builder.rb +37 -62
  60. data/lib/new_relic/agent/transaction_sampler.rb +29 -66
  61. data/lib/new_relic/cli/commands/install.rb +2 -2
  62. data/lib/new_relic/coerce.rb +15 -28
  63. data/lib/new_relic/json_wrapper.rb +14 -73
  64. data/lib/new_relic/noticed_error.rb +81 -5
  65. data/lib/new_relic/rack/browser_monitoring.rb +14 -19
  66. data/lib/new_relic/rack/developer_mode.rb +68 -14
  67. data/lib/new_relic/rack/developer_mode/segment_summary.rb +56 -0
  68. data/lib/new_relic/version.rb +2 -2
  69. data/newrelic.yml +19 -196
  70. data/test/agent_helper.rb +42 -36
  71. data/test/config/newrelic.yml +0 -1
  72. data/test/environments/rails40/Gemfile +1 -1
  73. data/test/environments/rails41/Gemfile +1 -1
  74. data/test/environments/rails42/Gemfile +1 -1
  75. data/test/fixtures/cross_agent_tests/attribute_configuration.json +35 -0
  76. data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +19 -12
  77. data/test/fixtures/cross_agent_tests/sql_obfuscation/sql_obfuscation.json +365 -0
  78. data/test/multiverse/lib/multiverse/suite.rb +5 -1
  79. data/test/multiverse/suites/active_record/active_record_test.rb +8 -8
  80. data/test/multiverse/suites/agent_only/agent_attributes_test.rb +145 -0
  81. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +8 -0
  82. data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +5 -1
  83. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +6 -6
  84. data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -1
  85. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +2 -3
  86. data/test/multiverse/suites/agent_only/synthetics_test.rb +3 -3
  87. data/test/multiverse/suites/agent_only/testing_app.rb +4 -0
  88. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -1
  89. data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +9 -7
  90. data/test/multiverse/suites/curb/Envfile +5 -6
  91. data/test/multiverse/suites/curb/curb_test.rb +4 -5
  92. data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
  93. data/test/multiverse/suites/excon/Envfile +11 -4
  94. data/test/multiverse/suites/excon/excon_test.rb +5 -5
  95. data/test/multiverse/suites/grape/config/newrelic.yml +1 -0
  96. data/test/multiverse/suites/grape/grape_test.rb +76 -12
  97. data/test/multiverse/suites/grape/grape_test_api.rb +16 -0
  98. data/test/multiverse/suites/high_security/config/newrelic.yml +43 -3
  99. data/test/multiverse/suites/high_security/high_security_test.rb +165 -9
  100. data/test/multiverse/suites/httpclient/Envfile +5 -1
  101. data/test/multiverse/suites/httpclient/httpclient_test.rb +2 -2
  102. data/test/multiverse/suites/memcached/Envfile +1 -1
  103. data/test/multiverse/suites/mongo/Envfile +8 -1
  104. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +29 -29
  105. data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +43 -8
  106. data/test/multiverse/suites/rack/rack_parameter_filtering_test.rb +13 -3
  107. data/test/multiverse/suites/rails/Envfile +3 -3
  108. data/test/multiverse/suites/rails/error_tracing_test.rb +52 -31
  109. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +1 -1
  110. data/test/multiverse/suites/rails/ignore_test.rb +1 -1
  111. data/test/multiverse/suites/rails/parameter_capture_test.rb +108 -40
  112. data/test/multiverse/suites/rails/request_statistics_test.rb +10 -4
  113. data/test/multiverse/suites/rails/view_instrumentation_test.rb +24 -24
  114. data/test/multiverse/suites/resque/instrumentation_test.rb +46 -12
  115. data/test/multiverse/suites/sequel/sequel_extension_test.rb +8 -8
  116. data/test/multiverse/suites/sequel/sequel_helpers.rb +11 -11
  117. data/test/multiverse/suites/sequel/sequel_plugin_test.rb +11 -11
  118. data/test/multiverse/suites/sidekiq/Envfile +1 -4
  119. data/test/multiverse/suites/sidekiq/after_suite.rb +9 -0
  120. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +49 -16
  121. data/test/multiverse/suites/sidekiq/test_worker.rb +1 -2
  122. data/test/multiverse/suites/sinatra/Envfile +1 -1
  123. data/test/multiverse/suites/sinatra/config/newrelic.yml +1 -0
  124. data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +0 -4
  125. data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +0 -4
  126. data/test/multiverse/suites/sinatra/sinatra_parameter_capture_test.rb +65 -0
  127. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +0 -11
  128. data/test/multiverse/suites/typhoeus/Envfile +8 -2
  129. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +4 -4
  130. data/test/new_relic/agent/agent/connect_test.rb +13 -9
  131. data/test/new_relic/agent/agent_test.rb +34 -24
  132. data/test/new_relic/agent/attribute_filter_test.rb +218 -0
  133. data/test/new_relic/agent/attribute_processing_test.rb +160 -0
  134. data/test/new_relic/agent/configuration/default_source_test.rb +88 -0
  135. data/test/new_relic/agent/configuration/manager_test.rb +3 -4
  136. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +3 -1
  137. data/test/new_relic/agent/configuration/server_source_test.rb +39 -0
  138. data/test/new_relic/agent/cross_app_monitor_test.rb +6 -30
  139. data/test/new_relic/agent/cross_app_tracing_test.rb +12 -12
  140. data/test/new_relic/agent/database/sql_obfuscation_test.rb +39 -65
  141. data/test/new_relic/agent/datastores/metric_helper_test.rb +36 -0
  142. data/test/new_relic/agent/encoding_normalizer_test.rb +66 -0
  143. data/test/new_relic/agent/error_collector_test.rb +181 -34
  144. data/test/new_relic/agent/hash_extensions_test.rb +34 -0
  145. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +20 -23
  146. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +12 -12
  147. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +5 -5
  148. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +4 -4
  149. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +21 -11
  150. data/test/new_relic/agent/javascript_instrumentor_test.rb +69 -45
  151. data/test/new_relic/agent/pipe_service_test.rb +2 -2
  152. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
  153. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +8 -7
  154. data/test/new_relic/agent/stats_engine/stats_hash_test.rb +2 -2
  155. data/test/new_relic/agent/threading/backtrace_node_test.rb +2 -2
  156. data/test/new_relic/agent/transaction/attributes_test.rb +276 -0
  157. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +10 -10
  158. data/test/new_relic/agent/transaction/trace_node_test.rb +361 -0
  159. data/test/new_relic/agent/transaction/trace_test.rb +394 -0
  160. data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
  161. data/test/new_relic/agent/transaction_event_aggregator_test.rb +127 -57
  162. data/test/new_relic/agent/transaction_sample_builder_test.rb +70 -78
  163. data/test/new_relic/agent/transaction_sampler_test.rb +76 -185
  164. data/test/new_relic/agent/transaction_test.rb +283 -135
  165. data/test/new_relic/agent_test.rb +27 -12
  166. data/test/new_relic/cli/commands/install_test.rb +27 -0
  167. data/test/new_relic/coerce_test.rb +0 -59
  168. data/test/new_relic/data_container_tests.rb +5 -5
  169. data/test/new_relic/fake_collector.rb +27 -9
  170. data/test/new_relic/filtering_test_app.rb +2 -1
  171. data/test/new_relic/http_client_test_cases.rb +16 -16
  172. data/test/new_relic/json_wrapper_test.rb +0 -54
  173. data/test/new_relic/marshalling_test_cases.rb +1 -0
  174. data/test/new_relic/multiverse_helpers.rb +144 -0
  175. data/test/new_relic/noticed_error_test.rb +112 -9
  176. data/test/new_relic/rack/browser_monitoring_test.rb +12 -7
  177. data/test/new_relic/{transaction_analysis → rack/developer_mode}/segment_summary_test.rb +5 -4
  178. data/test/new_relic/rack/developer_mode_test.rb +17 -3
  179. data/test/new_relic/rack/error_collector_test.rb +1 -1
  180. data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
  181. data/test/performance/script/runner +2 -2
  182. data/test/performance/suites/active_record.rb +3 -3
  183. data/test/performance/suites/agent_attributes.rb +62 -0
  184. data/test/performance/suites/rack_middleware.rb +78 -28
  185. data/test/performance/suites/transaction_tracing.rb +35 -0
  186. data/test/test_helper.rb +9 -1
  187. data/ui/helpers/developer_mode_helper.rb +16 -23
  188. data/ui/views/newrelic/_sample.rhtml +3 -3
  189. data/ui/views/newrelic/_segment.rhtml +1 -1
  190. data/ui/views/newrelic/_show_sample_summary.rhtml +1 -1
  191. data/ui/views/newrelic/show_sample.rhtml +5 -4
  192. metadata +23 -80
  193. data/lib/new_relic/agent/transaction/force_persist_sample_buffer.rb +0 -25
  194. data/lib/new_relic/transaction_analysis.rb +0 -80
  195. data/lib/new_relic/transaction_analysis/segment_summary.rb +0 -53
  196. data/lib/new_relic/transaction_sample.rb +0 -207
  197. data/lib/new_relic/transaction_sample/composite_segment.rb +0 -31
  198. data/lib/new_relic/transaction_sample/fake_segment.rb +0 -13
  199. data/lib/new_relic/transaction_sample/segment.rb +0 -197
  200. data/lib/new_relic/transaction_sample/summary_segment.rb +0 -25
  201. data/lib/new_relic/url_rule.rb +0 -18
  202. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +0 -1
  203. data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +0 -1
  204. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +0 -1
  205. data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +0 -1
  206. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +0 -1
  207. data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +0 -1
  208. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +0 -2
  209. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +0 -2
  210. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +0 -1
  211. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +0 -1
  212. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +0 -2
  213. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +0 -2
  214. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +0 -1
  215. data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +0 -1
  216. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +0 -1
  217. data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +0 -4
  218. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +0 -1
  219. data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +0 -1
  220. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +0 -1
  221. data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +0 -1
  222. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +0 -1
  223. data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +0 -1
  224. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +0 -1
  225. data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +0 -1
  226. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/README.md +0 -4
  227. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/end_of_line_comments_with_quotes.obfuscated +0 -1
  228. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/end_of_line_comments_with_quotes.sql +0 -2
  229. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_comments_and_quotes.obfuscated +0 -1
  230. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_comments_and_quotes.sql +0 -2
  231. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_comments_and_newlines.obfuscated +0 -1
  232. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_comments_and_newlines.sql +0 -4
  233. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_end_of_line_comments.obfuscated +0 -1
  234. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/mixed_quotes_end_of_line_comments.sql +0 -3
  235. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/quote_delimiters_in_comments.obfuscated +0 -1
  236. data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/quote_delimiters_in_comments.sql +0 -1
  237. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +0 -1
  238. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +0 -1
  239. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +0 -1
  240. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +0 -1
  241. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +0 -1
  242. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +0 -4
  243. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +0 -1
  244. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +0 -1
  245. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +0 -1
  246. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +0 -2
  247. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +0 -1
  248. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +0 -1
  249. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +0 -1
  250. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +0 -1
  251. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +0 -1
  252. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +0 -4
  253. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +0 -1
  254. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +0 -1
  255. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +0 -1
  256. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +0 -1
  257. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +0 -1
  258. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +0 -1
  259. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +0 -1
  260. data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +0 -1
  261. data/test/new_relic/agent/error_collector/notice_error_test.rb +0 -261
  262. data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +0 -52
  263. data/test/new_relic/transaction_analysis_test.rb +0 -125
  264. data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -38
  265. data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -18
  266. data/test/new_relic/transaction_sample/segment_test.rb +0 -361
  267. data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -34
  268. data/test/new_relic/transaction_sample_subtest_test.rb +0 -41
  269. data/test/new_relic/transaction_sample_test.rb +0 -361
@@ -1,4 +1,8 @@
1
- httpclient_versions = %w(2.3.3 2.2.0)
1
+ httpclient_versions = %w(2.6.0
2
+ 2.5.3
3
+ 2.4.0
4
+ 2.3.4
5
+ 2.2.0)
2
6
 
3
7
  httpclient_versions.each do |httpclient_version|
4
8
  gemfile <<-RB
@@ -68,8 +68,8 @@ class HTTPClientTest < Minitest::Test
68
68
  raise e unless e == test_exception
69
69
  end
70
70
 
71
- last_segment = find_last_transaction_segment()
72
- assert_equal("External/localhost/HTTPClient/GET", last_segment.metric_name)
71
+ last_node = find_last_transaction_node()
72
+ assert_equal("External/localhost/HTTPClient/GET", last_node.metric_name)
73
73
  end
74
74
  end
75
75
  end
@@ -14,7 +14,7 @@ memcache_client_versions.each do |version|
14
14
  gem 'memcache-client', '~> #{version}', :require => 'memcache'
15
15
  # version lockdown for ZenTest that cooperates with all Rubies
16
16
  # and the build VMs
17
- gem 'ZenTest', '3.4.2'
17
+ gem 'ZenTest', '3.4.2' unless RUBY_VERSION >= '2.2.0'
18
18
  RB
19
19
  end
20
20
 
@@ -1,3 +1,10 @@
1
+ if RUBY_VERSION >= '1.9.3'
2
+ gemfile <<-RB
3
+ gem 'mongo', '~>2.0.1'
4
+ gem 'bson_ext', :platforms => :ruby
5
+ RB
6
+ end
7
+
1
8
  gemfile <<-RB
2
9
  gem 'mongo', '1.10.0'
3
10
  gem 'bson_ext', :platforms => :ruby
@@ -34,7 +41,7 @@ class PreExistingMongo
34
41
  end
35
42
  end
36
43
 
37
- $mongo = PreExistingMongo.new("localhost", 27017)
44
+ $mongo = PreExistingMongo.new("127.0.0.1", 27017)
38
45
 
39
46
  def mongo_running?
40
47
  Timeout::timeout(1) do
@@ -305,12 +305,12 @@ module MongoOperationTests
305
305
  end
306
306
 
307
307
  def test_notices_nosql
308
- segment = nil
308
+ node = nil
309
309
 
310
310
  in_transaction do
311
311
  @collection.insert(@tribble)
312
312
 
313
- segment = find_last_transaction_segment
313
+ node = find_last_transaction_node
314
314
  end
315
315
 
316
316
  expected = {
@@ -319,114 +319,114 @@ module MongoOperationTests
319
319
  :operation => :insert
320
320
  }
321
321
 
322
- result = segment.params[:statement]
322
+ result = node.params[:statement]
323
323
  assert_equal expected, result
324
324
  end
325
325
 
326
326
  def test_noticed_nosql_includes_operation
327
- segment = nil
327
+ node = nil
328
328
 
329
329
  in_transaction do
330
330
  @collection.insert(@tribble)
331
- segment = find_last_transaction_segment
331
+ node = find_last_transaction_node
332
332
  end
333
333
 
334
- query = segment.params[:statement]
334
+ query = node.params[:statement]
335
335
 
336
336
  assert_equal :insert, query[:operation]
337
337
  end
338
338
 
339
339
  def test_noticed_nosql_includes_update_operation
340
- segment = nil
340
+ node = nil
341
341
 
342
342
  in_transaction do
343
343
  updated = @tribble.dup
344
344
  updated['name'] = 't-rex'
345
345
  @collection.update(@tribble, updated)
346
346
 
347
- segment = find_last_transaction_segment
347
+ node = find_last_transaction_node
348
348
  end
349
349
 
350
- query = segment.params[:statement]
350
+ query = node.params[:statement]
351
351
 
352
352
  assert_equal :update, query[:operation]
353
353
  end
354
354
 
355
355
  def test_noticed_nosql_includes_save_operation
356
- segment = nil
356
+ node = nil
357
357
 
358
358
  in_transaction do
359
359
  @collection.save(@tribble)
360
- segment = find_last_transaction_segment
360
+ node = find_last_transaction_node
361
361
  end
362
362
 
363
- query = segment.params[:statement]
363
+ query = node.params[:statement]
364
364
  assert_equal :save, query[:operation]
365
365
  end
366
366
 
367
367
  def test_noticed_nosql_includes_ensure_index_operation
368
- segment = nil
368
+ node = nil
369
369
 
370
370
  in_transaction do
371
371
  @collection.ensure_index([[unique_field_name, Mongo::ASCENDING]])
372
- segment = find_last_transaction_segment
372
+ node = find_last_transaction_node
373
373
  end
374
374
 
375
- assert_ensure_index_in_transaction_segment(segment)
375
+ assert_ensure_index_in_transaction_node(node)
376
376
  end
377
377
 
378
378
  def test_noticed_nosql_includes_ensure_index_operation_with_symbol
379
- segment = nil
379
+ node = nil
380
380
 
381
381
  in_transaction do
382
382
  @collection.ensure_index(unique_field_name.to_sym)
383
- segment = find_last_transaction_segment
383
+ node = find_last_transaction_node
384
384
  end
385
385
 
386
- assert_ensure_index_in_transaction_segment(segment)
386
+ assert_ensure_index_in_transaction_node(node)
387
387
  end
388
388
 
389
389
  def test_noticed_nosql_includes_ensure_index_operation_with_string
390
- segment = nil
390
+ node = nil
391
391
 
392
392
  in_transaction do
393
393
  @collection.ensure_index(unique_field_name)
394
- segment = find_last_transaction_segment
394
+ node = find_last_transaction_node
395
395
  end
396
396
 
397
- assert_ensure_index_in_transaction_segment(segment)
397
+ assert_ensure_index_in_transaction_node(node)
398
398
  end
399
399
 
400
- def assert_ensure_index_in_transaction_segment(segment)
401
- query = segment.params[:statement]
400
+ def assert_ensure_index_in_transaction_node(node)
401
+ query = node.params[:statement]
402
402
  result = query[:operation]
403
403
 
404
404
  assert_equal :ensureIndex, result
405
405
  end
406
406
 
407
407
  def test_noticed_nosql_does_not_contain_documents
408
- segment = nil
408
+ node = nil
409
409
 
410
410
  in_transaction do
411
411
  @collection.insert({'name' => 'soterios johnson'})
412
- segment = find_last_transaction_segment
412
+ node = find_last_transaction_node
413
413
  end
414
414
 
415
- statement = segment.params[:statement]
415
+ statement = node.params[:statement]
416
416
 
417
417
  refute statement.keys.include?(:documents), "Noticed NoSQL should not include documents: #{statement}"
418
418
  end
419
419
 
420
420
  def test_noticed_nosql_does_not_contain_selector_values
421
421
  @collection.insert({'password' => '$ecret'})
422
- segment = nil
422
+ node = nil
423
423
 
424
424
  in_transaction do
425
425
  @collection.remove({'password' => '$ecret'})
426
- segment = find_last_transaction_segment
426
+ node = find_last_transaction_node
427
427
  end
428
428
 
429
- statement = segment.params[:statement]
429
+ statement = node.params[:statement]
430
430
 
431
431
  refute statement.inspect.include?('$secret')
432
432
 
@@ -7,31 +7,66 @@ require 'newrelic_rpm'
7
7
  require 'new_relic/agent/datastores/mongo'
8
8
 
9
9
  if !NewRelic::Agent::Datastores::Mongo.is_supported_version?
10
- require File.join(File.dirname(__FILE__), 'helpers', 'mongo_server')
11
-
12
10
  class NewRelic::Agent::Instrumentation::MongoInstrumentationTest < Minitest::Test
13
11
  include Mongo
14
12
 
15
13
  def setup
16
- @client = Mongo::Connection.new($mongo.host, $mongo.port)
17
14
  @database_name = "multiverse"
18
- @database = @client.db(@database_name)
19
15
  @collection_name = "tribbles-#{SecureRandom.hex(16)}"
20
- @collection = @database.collection(@collection_name)
21
-
22
16
  @tribble = {'name' => 'soterios johnson'}
23
17
 
18
+ setup_collection
19
+
24
20
  NewRelic::Agent.drop_buffered_data
25
21
  end
26
22
 
27
23
  def teardown
28
24
  NewRelic::Agent.drop_buffered_data
29
- @database.drop_collection(@collection_name)
25
+ drop_collection
30
26
  end
31
27
 
32
28
  def test_records_metrics_for_insert
33
- @collection.insert(@tribble)
29
+ insert_to_collection
34
30
  assert_metrics_not_recorded(["Datastore/all", "Datastore/allWeb", "Datastore/allOther"])
35
31
  end
32
+
33
+ # API changes between 1.x and 2.x that we need to work around to make
34
+ # sure that we're testing unsupported versions properly
35
+ module Mongo1xUnsupported
36
+ def setup_collection
37
+ client = Mongo::Connection.new($mongo.host, $mongo.port)
38
+ @database = client.db(@database_name)
39
+ @collection = @database.collection(@collection_name)
40
+ end
41
+
42
+ def drop_collection
43
+ @database.drop_collection(@collection_name)
44
+ end
45
+
46
+ def insert_to_collection
47
+ @collection.insert(@tribble)
48
+ end
49
+ end
50
+
51
+ module Mongo2xUnsupported
52
+ def setup_collection
53
+ client = Mongo::Client.new(["#{$mongo.host}:#{$mongo.port}"], :database => @database_name, :connect => :direct)
54
+ @collection = client[@collection_name]
55
+ end
56
+
57
+ def drop_collection
58
+ @collection.drop
59
+ end
60
+
61
+ def insert_to_collection
62
+ @collection.insert_one(@tribble)
63
+ end
64
+ end
65
+
66
+ if NewRelic::Agent::Datastores::Mongo.is_version2?
67
+ include Mongo2xUnsupported
68
+ else
69
+ include Mongo1xUnsupported
70
+ end
36
71
  end
37
72
  end
@@ -24,7 +24,12 @@ if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
24
24
  :file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
25
25
  }
26
26
  post '/', params
27
- assert_equal({"title" => "blah", "file" => "[FILE]"}, last_transaction_trace_request_params)
27
+
28
+ expected = {
29
+ "request.parameters.title" => "blah",
30
+ "request.parameters.file" => "[FILE]"
31
+ }
32
+ assert_equal expected, last_transaction_trace_request_params
28
33
  end
29
34
  end
30
35
 
@@ -32,8 +37,13 @@ if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?
32
37
  with_config(:capture_params => true) do
33
38
  params = {"name" => "name", "password" => "mypass"}
34
39
  post '/', params
35
- assert_equal params, last_transaction_trace_request_params
40
+
41
+ expected = {
42
+ "request.parameters.name" => "name",
43
+ "request.parameters.password" => "mypass"
44
+ }
45
+ assert_equal expected, last_transaction_trace_request_params
36
46
  end
37
47
  end
38
48
  end
39
- end
49
+ end
@@ -1,12 +1,12 @@
1
1
  if RUBY_VERSION >= '1.9.3'
2
2
  gemfile <<-RB
3
- gem 'rails', '~>4.2.0'
3
+ gem 'rails', '~>4.2.1'
4
4
  gem 'haml', :require => false
5
5
  gem 'minitest', '5.2.3'
6
6
  RB
7
7
 
8
8
  gemfile <<-RB
9
- gem 'rails', '~>4.1.7'
9
+ gem 'rails', '~>4.1.10'
10
10
  # Multiverse has an incompatibility with Minitest 5.3.0, so lock here for
11
11
  # now
12
12
  gem 'minitest', '5.2.3'
@@ -16,7 +16,7 @@ if RUBY_VERSION >= '1.9.3'
16
16
  RB
17
17
 
18
18
  gemfile <<-RB
19
- gem 'rails', '~>4.0.11'
19
+ gem 'rails', '~>4.0.13'
20
20
  gem 'haml', '4.0.2' # Getting load issues with haml 4.0.3
21
21
  RB
22
22
  end
@@ -61,7 +61,7 @@ class ErrorController < ApplicationController
61
61
  end
62
62
 
63
63
  def error_with_custom_params
64
- NewRelic::Agent.add_custom_parameters(:texture => 'chunky')
64
+ NewRelic::Agent.add_custom_attributes(:texture => 'chunky')
65
65
  raise 'bad things'
66
66
  end
67
67
 
@@ -113,16 +113,17 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
113
113
 
114
114
  def test_should_capture_request_uri_and_params
115
115
  get '/error/controller_error?eat=static'
116
- assert_equal('/error/controller_error', last_error.params[:request_uri])
116
+ assert_equal('/error/controller_error', attributes_for_single_error_posted("request_uri"))
117
117
 
118
- expected_params = { 'eat' => 'static' }
118
+ expected_params = {
119
+ 'request.parameters.eat' => 'static',
120
+ 'httpResponseCode' => 500
121
+ }
119
122
 
120
- if Rails::VERSION::MAJOR == 3
121
- expected_params['action'] = 'controller_error'
122
- expected_params['controller'] = 'error'
123
+ attributes = agent_attributes_for_single_error_posted
124
+ expected_params.each do |key, value|
125
+ assert_equal value, attributes[key]
123
126
  end
124
-
125
- assert_equal(expected_params, last_error.params[:request_params])
126
127
  end
127
128
  end
128
129
 
@@ -181,16 +182,16 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
181
182
 
182
183
  def test_should_apply_parameter_filtering
183
184
  get '/error/controller_error?secret=shouldnotbecaptured&other=whatever'
184
- params = last_error.params[:request_params]
185
- assert_equal('[FILTERED]', params['secret'])
186
- assert_equal('whatever', params['other'])
185
+ attributes = agent_attributes_for_single_error_posted
186
+ assert_equal('[FILTERED]', attributes['request.parameters.secret'])
187
+ assert_equal('whatever', attributes['request.parameters.other'])
187
188
  end
188
189
 
189
190
  def test_should_apply_parameter_filtering_for_non_standard_errors
190
191
  get '/error/exception_error?secret=shouldnotbecaptured&other=whatever'
191
- params = last_error.params[:request_params]
192
- assert_equal('[FILTERED]', params['secret'])
193
- assert_equal('whatever', params['other'])
192
+ attributes = agent_attributes_for_single_error_posted
193
+ assert_equal('[FILTERED]', attributes['request.parameters.secret'])
194
+ assert_equal('whatever', attributes['request.parameters.other'])
194
195
  end
195
196
 
196
197
  def test_should_not_notice_errors_from_ignored_action
@@ -231,28 +232,47 @@ class ErrorsWithoutSSCTest < RailsMultiverseTest
231
232
  assert_error_reported_once('this is a server ignored error')
232
233
  end
233
234
 
234
- # These really shouldn't be skipped for Rails 4, see RUBY-1242
235
- if ::Rails::VERSION::MAJOR.to_i < 4
236
- def test_captured_errors_should_include_custom_params
235
+ def test_captured_errors_should_include_custom_params
236
+ with_config(:'error_collector.attributes.enabled' => true) do
237
237
  get '/error/error_with_custom_params'
238
238
  assert_error_reported_once('bad things')
239
- error = errors_with_message('bad things').first
240
- custom_params = error.params[:custom_params]
241
- assert_equal({:texture => 'chunky'}, custom_params)
239
+
240
+ attributes = user_attributes_for_single_error_posted
241
+ assert_equal({'texture' => 'chunky'}, attributes)
242
242
  end
243
+ end
243
244
 
244
- def test_captured_errors_should_not_include_custom_params_if_config_says_no
245
- with_config(:'error_collector.capture_attributes' => false) do
246
- get '/error/error_with_custom_params'
247
- end
245
+ def test_captured_errors_should_include_custom_params_with_legacy_setting
246
+ with_config(:'error_collector.capture_attributes' => true) do
247
+ get '/error/error_with_custom_params'
248
+ assert_error_reported_once('bad things')
249
+
250
+ attributes = user_attributes_for_single_error_posted
251
+ assert_equal({'texture' => 'chunky'}, attributes)
252
+ end
253
+ end
254
+
255
+ def test_captured_errors_should_not_include_custom_params_if_config_says_no
256
+ with_config(:'error_collector.attributes.enabled' => false) do
257
+ get '/error/error_with_custom_params'
248
258
  assert_error_reported_once('bad things')
249
- error = errors_with_message('bad things').first
250
- custom_params = error.params[:custom_params]
251
- assert_equal({}, custom_params)
259
+
260
+ attributes = user_attributes_for_single_error_posted
261
+ assert_empty attributes
262
+ end
263
+ end
264
+
265
+ def test_captured_errors_should_not_include_custom_params_if_legacy_setting_says_no
266
+ with_config(:'error_collector.capture_attributes' => false) do
267
+ get '/error/error_with_custom_params'
268
+ assert_error_reported_once('bad things')
269
+
270
+ attributes = user_attributes_for_single_error_posted
271
+ assert_empty attributes
252
272
  end
253
273
  end
254
274
 
255
- protected
275
+ protected
256
276
 
257
277
  def errors_with_message(message)
258
278
  @error_collector.errors.select{|error| error.message == message}
@@ -280,10 +300,11 @@ end
280
300
  class ErrorsWithSSCTest < ErrorsWithoutSSCTest
281
301
  def setup_collector_mocks
282
302
  $collector.stub('connect', {
283
- "listen_to_server_config" => true,
284
303
  "agent_run_id" => 1,
285
- "error_collector.ignore_errors" => 'NewRelic::TestHelpers::Exceptions::IgnoredError,NewRelic::TestHelpers::Exceptions::ServerIgnoredError',
286
- "error_collector.enabled" => true,
304
+ "agent_config" => {
305
+ "error_collector.ignore_errors" => 'NewRelic::TestHelpers::Exceptions::IgnoredError,NewRelic::TestHelpers::Exceptions::ServerIgnoredError',
306
+ "error_collector.enabled" => true,
307
+ },
287
308
  "collect_errors" => true
288
309
  }, 200)
289
310
  end