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
@@ -129,17 +129,6 @@ module SinatraTestCases
129
129
  get '/pass'
130
130
  end
131
131
 
132
- def test_file_upload_params_are_filtered
133
- with_config(:capture_params => true) do
134
- params = {
135
- :title => "blah",
136
- :file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
137
- }
138
- post '/files', params
139
- assert_equal({"title" => "blah", "file" => "[FILE]"}, last_transaction_trace_request_params)
140
- end
141
- end
142
-
143
132
  def fail_on_second_params_call
144
133
  Sinatra::Request.any_instance.
145
134
  stubs(:params).returns({}).
@@ -7,7 +7,7 @@ suite_condition("Typhoeus excluded on 1.8.7") do
7
7
  end
8
8
 
9
9
  gemfile <<-RB
10
- gem 'typhoeus', '~> 0.6.5'
10
+ gem 'typhoeus', '~> 0.7.1'
11
11
  gem 'rack'
12
12
  gem 'json', :platforms => [:rbx, :mri_18]
13
13
 
@@ -16,7 +16,13 @@ gemfile <<-RB
16
16
  RB
17
17
 
18
18
  gemfile <<-RB
19
- gem 'typhoeus', '~> 0.6.5'
19
+ gem 'typhoeus', '~> 0.7.1'
20
+ gem 'rack'
21
+ gem 'json', :platforms => [:rbx, :mri_18]
22
+ RB
23
+
24
+ gemfile <<-RB
25
+ gem 'typhoeus', '~> 0.6.9'
20
26
  gem 'rack'
21
27
  gem 'json', :platforms => [:rbx, :mri_18]
22
28
  RB
@@ -96,8 +96,8 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
96
96
  refute_nil(caught_exception)
97
97
  assert_equal('noodle', caught_exception.message)
98
98
 
99
- last_segment = find_last_transaction_segment
100
- assert_equal "External/localhost/Typhoeus/GET", last_segment.metric_name
99
+ last_node = find_last_transaction_node
100
+ assert_equal "External/localhost/Typhoeus/GET", last_node.metric_name
101
101
  end
102
102
  end
103
103
 
@@ -117,8 +117,8 @@ if NewRelic::Agent::Instrumentation::TyphoeusTracing.is_supported_version?
117
117
  5.times { hydra.queue(Typhoeus::Request.new(default_url, ssl_option)) }
118
118
  hydra.run
119
119
 
120
- last_segment = find_last_transaction_segment()
121
- assert_equal "External/Multiple/Typhoeus::Hydra/run", last_segment.metric_name
120
+ last_node = find_last_transaction_node()
121
+ assert_equal "External/Multiple/Typhoeus::Hydra/run", last_node.metric_name
122
122
  end
123
123
  end
124
124
 
@@ -134,10 +134,11 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
134
134
  end
135
135
 
136
136
  def test_configure_transaction_tracer_server_disabled
137
- config = NewRelic::Agent::Configuration::ServerSource.new('collect_traces' => false,
138
- 'developer_mode' => false)
139
- with_config(config) do
140
- assert !@transaction_sampler.enabled?
137
+ config = NewRelic::Agent::Configuration::ServerSource.new('collect_traces' => false)
138
+ with_config(:developer_mode => false) do
139
+ with_config(config) do
140
+ refute @transaction_sampler.enabled?
141
+ end
141
142
  end
142
143
  end
143
144
 
@@ -260,11 +261,14 @@ class NewRelic::Agent::Agent::ConnectTest < Minitest::Test
260
261
  end
261
262
 
262
263
  def test_finish_setup_replaces_server_config
263
- finish_setup(:boo => "boo")
264
- finish_setup(:hoo => true)
265
-
266
- assert NewRelic::Agent.config[:hoo]
267
- assert_nil NewRelic::Agent.config[:boo]
264
+ finish_setup('apdex_t' => 42)
265
+ assert_equal 42, NewRelic::Agent.config[:apdex_t]
266
+ assert_kind_of NewRelic::Agent::Configuration::ServerSource, NewRelic::Agent.config.source(:apdex_t)
267
+
268
+ # this should create a new server source that replaces the existing one that
269
+ # had apdex_t specified, rather than layering on top of the existing one.
270
+ finish_setup('data_report_period' => 12)
271
+ assert_kind_of NewRelic::Agent::Configuration::DefaultSource, NewRelic::Agent.config.source(:apdex_t)
268
272
  end
269
273
 
270
274
  def test_logging_collector_messages
@@ -11,7 +11,10 @@ module NewRelic
11
11
 
12
12
  def setup
13
13
  super
14
+ @original_agent = NewRelic::Agent.agent
14
15
  @agent = NewRelic::Agent::Agent.new
16
+ NewRelic::Agent.agent = @agent
17
+
15
18
  @agent.service = default_service
16
19
  @agent.agent_command_router.stubs(:new_relic_service).returns(@agent.service)
17
20
  @agent.stubs(:start_worker_thread)
@@ -21,6 +24,7 @@ module NewRelic
21
24
  end
22
25
 
23
26
  def teardown
27
+ NewRelic::Agent.agent = @original_agent
24
28
  NewRelic::Agent.config.reset_to_defaults
25
29
  end
26
30
 
@@ -338,6 +342,36 @@ module NewRelic
338
342
  end
339
343
  end
340
344
 
345
+ def test_connect_replaces_attribute_filter
346
+ old_filter = @agent.attribute_filter
347
+
348
+ @agent.stubs(:connected?).returns(true)
349
+ @agent.service.expects(:connect).returns({})
350
+ @agent.send(:connect, :force_reconnect => true)
351
+
352
+ refute old_filter == @agent.attribute_filter, "#{@agent.attribute_filter} should not be equal to\n#{old_filter}"
353
+ end
354
+
355
+ def test_connect_replaces_transaction_rules
356
+ old_rules = @agent.transaction_rules
357
+
358
+ @agent.stubs(:connected?).returns(true)
359
+ @agent.service.expects(:connect).returns({})
360
+ @agent.send(:connect, :force_reconnect => true)
361
+
362
+ refute old_rules == @agent.transaction_rules, "#{@agent.transaction_rules} should not be equal to\n#{old_rules}"
363
+ end
364
+
365
+ def test_connect_replaces_stats_engine_metric_rules
366
+ old_rules = @agent.stats_engine.metric_rules
367
+
368
+ @agent.stubs(:connected?).returns(true)
369
+ @agent.service.expects(:connect).returns({})
370
+ @agent.send(:connect, :force_reconnect => true)
371
+
372
+ refute old_rules == @agent.stats_engine.metric_rules, "#{@agent.stats_engine.metric_rules} should not be equal to\n#{old_rules}"
373
+ end
374
+
341
375
  def test_connect_settings
342
376
  expected = [
343
377
  :pid,
@@ -564,30 +598,6 @@ module NewRelic
564
598
  end
565
599
  end
566
600
 
567
- def test_stop_event_loop_runs_loop_before_exit_with_force_send_config
568
- fake_loop = mock
569
- fake_loop.expects(:run_once)
570
- fake_loop.stubs(:stop)
571
-
572
- @agent.instance_variable_set(:@event_loop, fake_loop)
573
-
574
- with_config(:force_send => true) do
575
- @agent.stop_event_loop
576
- end
577
- end
578
-
579
- def test_stop_event_loop_doesnt_run_loop_if_force_send_is_false
580
- fake_loop = mock
581
- fake_loop.expects(:run_once).never
582
- fake_loop.stubs(:stop)
583
-
584
- @agent.instance_variable_set(:@event_loop, fake_loop)
585
-
586
- with_config(:force_send => false) do
587
- @agent.stop_event_loop
588
- end
589
- end
590
-
591
601
  def test_stop_event_loop_stops_the_loop
592
602
  fake_loop = mock
593
603
  fake_loop.expects(:stop)
@@ -0,0 +1,218 @@
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 File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
+
7
+ require 'new_relic/agent/attribute_filter'
8
+ require 'pp'
9
+
10
+ module NewRelic::Agent
11
+ class AttributeFilterTest < Minitest::Test
12
+ test_cases = load_cross_agent_test("attribute_configuration")
13
+ test_cases.each do |test_case|
14
+ define_method("test_#{test_case['testname'].gsub(/\W/, "_")}") do
15
+ with_config(test_case['config']) do
16
+ filter = AttributeFilter.new(NewRelic::Agent.config)
17
+
18
+ attribute_name = test_case['input_key']
19
+ desired_destination_names = test_case['input_default_destinations']
20
+
21
+ desired_destinations = to_bitfield(desired_destination_names)
22
+ actual_destinations = filter.apply(attribute_name, desired_destinations)
23
+ expected_destinations = to_bitfield(test_case['expected_destinations'])
24
+
25
+ assert_equal(to_names(expected_destinations), to_names(actual_destinations),
26
+ PP.pp(test_case, "") + PP.pp(filter.rules, ""))
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_allows?
32
+ with_all_enabled do
33
+ filter = AttributeFilter.new(NewRelic::Agent.config)
34
+ default_destination = AttributeFilter::DST_ALL
35
+
36
+ assert filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_EVENTS)
37
+ assert filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_TRACER)
38
+ assert filter.allows?(default_destination, AttributeFilter::DST_ERROR_COLLECTOR)
39
+ assert filter.allows?(default_destination, AttributeFilter::DST_BROWSER_MONITORING)
40
+ end
41
+ end
42
+
43
+ def test_allows_with_restricted_default_destination
44
+ with_all_enabled do
45
+ filter = AttributeFilter.new(NewRelic::Agent.config)
46
+ default_destination = AttributeFilter::DST_ERROR_COLLECTOR
47
+
48
+ assert filter.allows?(default_destination, AttributeFilter::DST_ERROR_COLLECTOR)
49
+
50
+ refute filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_EVENTS)
51
+ refute filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_TRACER)
52
+ refute filter.allows?(default_destination, AttributeFilter::DST_BROWSER_MONITORING)
53
+ end
54
+ end
55
+
56
+
57
+ def test_allows_with_multiple_default_destinations
58
+ with_all_enabled do
59
+ filter = AttributeFilter.new(NewRelic::Agent.config)
60
+ default_destination = AttributeFilter::DST_ERROR_COLLECTOR|AttributeFilter::DST_TRANSACTION_TRACER
61
+
62
+ assert filter.allows?(default_destination, AttributeFilter::DST_ERROR_COLLECTOR)
63
+ assert filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_TRACER)
64
+
65
+ refute filter.allows?(default_destination, AttributeFilter::DST_TRANSACTION_EVENTS)
66
+ refute filter.allows?(default_destination, AttributeFilter::DST_BROWSER_MONITORING)
67
+ end
68
+ end
69
+
70
+ def test_capture_params_false_adds_exclude_rule_for_request_parameters
71
+ with_config(:capture_params => false) do
72
+ filter = AttributeFilter.new(NewRelic::Agent.config)
73
+ result = filter.apply 'request.parameters.muggle', AttributeFilter::DST_NONE
74
+
75
+ assert_destinations [], result
76
+ end
77
+ end
78
+
79
+ def test_capture_params_true_allows_request_params_for_traces_and_errors
80
+ with_config(:capture_params => true) do
81
+ filter = AttributeFilter.new(NewRelic::Agent.config)
82
+ result = filter.apply 'request.parameters.muggle', AttributeFilter::DST_NONE
83
+
84
+ assert_destinations ['transaction_tracer', 'error_collector'], result
85
+ end
86
+ end
87
+
88
+ def test_resque_capture_params_false_adds_exclude_rule_for_request_parameters
89
+ with_config(:'resque.capture_params' => false) do
90
+ filter = AttributeFilter.new(NewRelic::Agent.config)
91
+ result = filter.apply 'job.resque.args.*', AttributeFilter::DST_NONE
92
+
93
+ assert_destinations [], result
94
+ end
95
+ end
96
+
97
+ def test_resque_capture_params_true_allows_request_params_for_traces_and_errors
98
+ with_config(:'resque.capture_params' => true) do
99
+ filter = AttributeFilter.new(NewRelic::Agent.config)
100
+ result = filter.apply 'job.resque.args.*', AttributeFilter::DST_NONE
101
+
102
+ assert_destinations ['transaction_tracer', 'error_collector'], result
103
+ end
104
+ end
105
+
106
+ def test_sidekiq_capture_params_false_adds_exclude_rule_for_request_parameters
107
+ with_config(:'sidekiq.capture_params' => false) do
108
+ filter = AttributeFilter.new(NewRelic::Agent.config)
109
+ result = filter.apply 'job.sidekiq.args.*', AttributeFilter::DST_NONE
110
+
111
+ assert_destinations [], result
112
+ end
113
+ end
114
+
115
+ def test_sidekiq_capture_params_true_allows_request_params_for_traces_and_errors
116
+ with_config(:'sidekiq.capture_params' => true) do
117
+ filter = AttributeFilter.new(NewRelic::Agent.config)
118
+ result = filter.apply 'job.sidekiq.args.*', AttributeFilter::DST_NONE
119
+
120
+ assert_destinations ['transaction_tracer', 'error_collector'], result
121
+ end
122
+ end
123
+
124
+ def test_might_allow_prefix_default_case
125
+ filter = AttributeFilter.new(NewRelic::Agent.config)
126
+ refute filter.might_allow_prefix?(:'request.parameters')
127
+ end
128
+
129
+ def test_might_allow_prefix_blanket_include
130
+ with_config(:'attributes.include' => '*') do
131
+ filter = AttributeFilter.new(NewRelic::Agent.config)
132
+ assert filter.might_allow_prefix?(:'request.parameters')
133
+ end
134
+ end
135
+
136
+ def test_might_allow_prefix_general_include
137
+ with_config(:'attributes.include' => 'request.*') do
138
+ filter = AttributeFilter.new(NewRelic::Agent.config)
139
+ assert filter.might_allow_prefix?(:'request.parameters')
140
+ end
141
+ end
142
+
143
+ def test_might_allow_prefix_prefix_include
144
+ with_config(:'attributes.include' => 'request.parameters.*') do
145
+ filter = AttributeFilter.new(NewRelic::Agent.config)
146
+ assert filter.might_allow_prefix?(:'request.parameters')
147
+ end
148
+ end
149
+
150
+ def test_might_allow_prefix_prefix_include_tt_only
151
+ with_config(:'transaction_tracer.attributes.include' => 'request.parameters.*') do
152
+ filter = AttributeFilter.new(NewRelic::Agent.config)
153
+ assert filter.might_allow_prefix?(:'request.parameters')
154
+ end
155
+ end
156
+
157
+ def test_might_allow_prefix_non_matching_include
158
+ with_config(:'transaction_tracer.attributes.include' => 'otherthing') do
159
+ filter = AttributeFilter.new(NewRelic::Agent.config)
160
+ refute filter.might_allow_prefix?(:'request.parameters')
161
+ end
162
+ end
163
+
164
+ def test_might_allow_prefix_more_specific_rule
165
+ with_config(:'attributes.include' => 'request.parameters.lolz') do
166
+ filter = AttributeFilter.new(NewRelic::Agent.config)
167
+ assert filter.might_allow_prefix?(:'request.parameters')
168
+ end
169
+ end
170
+
171
+ def test_might_allow_prefix_more_specific_rule_with_wildcard
172
+ with_config(:'attributes.include' => 'request.parameters.lolz.*') do
173
+ filter = AttributeFilter.new(NewRelic::Agent.config)
174
+ assert filter.might_allow_prefix?(:'request.parameters')
175
+ end
176
+ end
177
+
178
+ def assert_destinations(expected, result)
179
+ assert_equal to_bitfield(expected), result, "Expected #{expected}, got #{to_names(result)}"
180
+ end
181
+
182
+ def to_names(bitfield)
183
+ names = []
184
+
185
+ names << 'transaction_events' if (bitfield & AttributeFilter::DST_TRANSACTION_EVENTS) != 0
186
+ names << 'transaction_tracer' if (bitfield & AttributeFilter::DST_TRANSACTION_TRACER) != 0
187
+ names << 'error_collector' if (bitfield & AttributeFilter::DST_ERROR_COLLECTOR) != 0
188
+ names << 'browser_monitoring' if (bitfield & AttributeFilter::DST_BROWSER_MONITORING) != 0
189
+
190
+ names
191
+ end
192
+
193
+ def to_bitfield(destination_names)
194
+ bitfield = AttributeFilter::DST_NONE
195
+
196
+ destination_names.each do |name|
197
+ case name
198
+ when 'transaction_events' then bitfield |= AttributeFilter::DST_TRANSACTION_EVENTS
199
+ when 'transaction_tracer' then bitfield |= AttributeFilter::DST_TRANSACTION_TRACER
200
+ when 'error_collector' then bitfield |= AttributeFilter::DST_ERROR_COLLECTOR
201
+ when 'browser_monitoring' then bitfield |= AttributeFilter::DST_BROWSER_MONITORING
202
+ end
203
+ end
204
+
205
+ bitfield
206
+ end
207
+
208
+ def with_all_enabled
209
+ with_config(
210
+ :'transaction_tracer.attributes.enabled' => true,
211
+ :'transaction_events.attributes.enabled' => true,
212
+ :'error_collector.attributes.enabled' => true,
213
+ :'browser_monitoring.attributes.enabled' => true) do
214
+ yield
215
+ end
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,160 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', '..','test_helper'))
6
+ require 'new_relic/agent/attribute_processing'
7
+
8
+ class AttributeProcessingTest < Minitest::Test
9
+ def test_flatten_and_coerce_handles_nested_hashes
10
+ params = {"user" =>
11
+ {"addresses" =>
12
+ [
13
+ {"street" => "123 Street", "city" => "City", "state" => "ST", "zip" => "12345"},
14
+ {"street" => "123 Blvd", "city" => "City2", "state" => "ST2", "zip" => "54321"}
15
+ ]
16
+ }
17
+ }
18
+
19
+ expected = {
20
+ "request.parameters.user.addresses.0.street" => "123 Street",
21
+ "request.parameters.user.addresses.0.city" => "City",
22
+ "request.parameters.user.addresses.0.state" => "ST",
23
+ "request.parameters.user.addresses.0.zip" => "12345",
24
+ "request.parameters.user.addresses.1.street" => "123 Blvd",
25
+ "request.parameters.user.addresses.1.city" => "City2",
26
+ "request.parameters.user.addresses.1.state" => "ST2",
27
+ "request.parameters.user.addresses.1.zip" => "54321"
28
+ }
29
+
30
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params, 'request.parameters')
31
+
32
+ assert_equal(expected, actual)
33
+ end
34
+
35
+ def test_flatten_and_coerce_coerces_values
36
+ params = {
37
+ "v1" => Class.new,
38
+ "v2" => :symbol,
39
+ "v3" => 1.01
40
+ }
41
+
42
+ expected = {
43
+ "request.parameters.v1" => "#<Class>",
44
+ "request.parameters.v2" => "symbol",
45
+ "request.parameters.v3" => 1.01
46
+ }
47
+
48
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params, 'request.parameters')
49
+
50
+ assert_equal(expected, actual)
51
+ end
52
+
53
+ def test_prefix_optional_for_flatten_and_coerce
54
+ params = {:foo => {:bar => ["v1", "v2"]}}
55
+
56
+ expected = {
57
+ "foo.bar.0" => "v1",
58
+ "foo.bar.1" => "v2"
59
+ }
60
+
61
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params)
62
+
63
+ assert_equal(expected, actual)
64
+ end
65
+
66
+ def test_prefix_optional_for_flatten_and_coerce_with_initial_array_argument
67
+ params = [:foo => {:bar => ["v1", "v2"]}]
68
+
69
+ expected = {
70
+ "0.foo.bar.0" => "v1",
71
+ "0.foo.bar.1" => "v2"
72
+ }
73
+
74
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params)
75
+
76
+ assert_equal(expected, actual)
77
+ end
78
+
79
+ def test_flatten_and_coerce_replaces_empty_hash_with_string_representation
80
+ params = {:foo => {:bar => {}}}
81
+
82
+ expected = { "foo.bar" => "{}" }
83
+
84
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params)
85
+
86
+ assert_equal(expected, actual)
87
+ end
88
+
89
+ def test_flatten_and_coerce_replaces_empty_array_with_string_representation
90
+ params = {:foo => {:bar => []}}
91
+
92
+ expected = { "foo.bar" => "[]" }
93
+
94
+ actual = NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params)
95
+
96
+ assert_equal(expected, actual)
97
+ end
98
+
99
+ def test_flatten_and_coerce_coerce_handles_values_mixed_and_complex_types_properly
100
+ assert_equal(
101
+ {
102
+ 'foo' => 1.0,
103
+ 'bar' => 2,
104
+ 'bang' => 'woot',
105
+ 'ok' => 'dokey',
106
+ 'yes' => '[]',
107
+ 'yup' => '{}',
108
+ 'yayuh' => '#<Rational>',
109
+ 'truthy' => true,
110
+ 'falsy' => false
111
+ },
112
+ NewRelic::Agent::AttributeProcessing.flatten_and_coerce(
113
+ {
114
+ 'foo' => 1.0,
115
+ 'bar' => 2,
116
+ 'bang' => 'woot',
117
+ 'ok' => :dokey,
118
+ 'yes' => [],
119
+ 'yup' => {},
120
+ 'yayuh' => Rational(1),
121
+ 'truthy' => true,
122
+ 'falsy' => false
123
+ }
124
+ )
125
+ )
126
+ end
127
+
128
+ def test_flatten_and_coerce_turns_nan_or_infinity_into_null
129
+ assert_equal(
130
+ {
131
+ 'nan' => nil,
132
+ 'inf' => nil,
133
+ 'ninf' => nil
134
+ },
135
+ NewRelic::Agent::AttributeProcessing.flatten_and_coerce(
136
+ {
137
+ # Ruby 1.8.7 doesn't have Float::NAN, INFINITY so we have to hack it
138
+ 'nan' => 0.0 / 0.0,
139
+ 'inf' => 1.0 / 0.0,
140
+ 'ninf' => -1.0 / 0.0
141
+ }
142
+ )
143
+ )
144
+ end
145
+
146
+ def test_flatten_and_coerce_logs_warning_with_unexpected_arguments
147
+ expects_logging(:warn, all_of(includes("Unexpected object"), includes("flatten_and_coerce")))
148
+ NewRelic::Agent::AttributeProcessing.flatten_and_coerce(Object.new)
149
+ end
150
+
151
+ def test_flatten_and_coerce_calls_a_block_key_and_value_when_provided
152
+ params = {:foo => {:bar => ["qux", "quux"]}}
153
+ yielded = {}
154
+
155
+ NewRelic::Agent::AttributeProcessing.flatten_and_coerce(params) { |k, v| yielded[k] = v}
156
+
157
+ expected = {"foo.bar.0" => "qux", "foo.bar.1" => "quux"}
158
+ assert_equal expected, yielded
159
+ end
160
+ end