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
@@ -49,7 +49,7 @@ class ResqueTest < Minitest::Test
49
49
  end
50
50
  end
51
51
 
52
- NewRelic::Agent.instance.send(:transmit_data)
52
+ run_harvest
53
53
  end
54
54
 
55
55
  def test_all_jobs_ran
@@ -70,14 +70,17 @@ class ResqueTest < Minitest::Test
70
70
 
71
71
  def test_doesnt_capture_args_by_default
72
72
  run_jobs
73
- assert_no_params_on_jobs
73
+ refute_attributes_on_transaction_traces
74
+ refute_attributes_on_events
74
75
  end
75
76
 
76
77
  def test_isnt_influenced_by_global_capture_params
77
78
  with_config(:capture_params => true) do
78
79
  run_jobs
79
80
  end
80
- assert_no_params_on_jobs
81
+
82
+ refute_attributes_on_transaction_traces
83
+ refute_attributes_on_events
81
84
  end
82
85
 
83
86
  def test_agent_posts_captured_args_to_job
@@ -85,15 +88,16 @@ class ResqueTest < Minitest::Test
85
88
  run_jobs
86
89
  end
87
90
 
88
- transaction_samples = $collector.calls_for('transaction_sample_data')
89
- assert_false transaction_samples.empty?
91
+ assert_attributes_on_transaction_traces
92
+ refute_attributes_on_events
93
+ end
90
94
 
91
- transaction_samples.each do |post|
92
- post.samples.each do |sample|
93
- assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
94
- assert_equal sample.tree.custom_params["job_arguments"], ["testing"]
95
- end
95
+ def test_arguments_are_captured_on_transaction_events_when_enabled
96
+ with_config(:'attributes.include' => 'job.resque.args.*') do
97
+ run_jobs
96
98
  end
99
+
100
+ assert_attributes_on_events
97
101
  end
98
102
 
99
103
  def assert_metric_and_call_count(name, expected_call_count)
@@ -107,14 +111,44 @@ class ResqueTest < Minitest::Test
107
111
  assert_equal(expected_call_count, call_count)
108
112
  end
109
113
 
110
- def assert_no_params_on_jobs
114
+ def assert_attributes_on_transaction_traces
115
+ transaction_samples = $collector.calls_for('transaction_sample_data')
116
+ assert_false transaction_samples.empty?
117
+
118
+ transaction_samples.each do |post|
119
+ post.samples.each do |sample|
120
+ assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
121
+ assert_equal 'testing', sample.agent_attributes["job.resque.args.0"]
122
+ end
123
+ end
124
+ end
125
+
126
+ def refute_attributes_on_transaction_traces
111
127
  transaction_samples = $collector.calls_for('transaction_sample_data')
112
128
  assert_false transaction_samples.empty?
113
129
 
114
130
  transaction_samples.each do |post|
115
131
  post.samples.each do |sample|
116
132
  assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
117
- assert_nil sample.tree.custom_params["job_arguments"]
133
+ assert sample.agent_attributes.keys.none? { |k| k =~ /^job.resque.args.*/ }
134
+ end
135
+ end
136
+ end
137
+
138
+ def assert_attributes_on_events
139
+ event_posts = $collector.calls_for('analytic_event_data')
140
+ event_posts.each do |post|
141
+ post.events.each do |event|
142
+ assert_equal ["job.resque.args.0"], event[2].keys
143
+ end
144
+ end
145
+ end
146
+
147
+ def refute_attributes_on_events
148
+ event_posts = $collector.calls_for('analytic_event_data')
149
+ event_posts.each do |post|
150
+ post.events.each do |event|
151
+ assert event[2].keys.none? { |k| k.start_with?("job.resque.args") }, "Found unexpected resque arguments"
118
152
  end
119
153
  end
120
154
  end
@@ -92,20 +92,20 @@ class SequelExtensionTest < Minitest::Test
92
92
  def test_slow_queries_get_an_explain_plan
93
93
  with_config( :'transaction_tracer.explain_threshold' => -0.01,
94
94
  :'transaction_tracer.record_sql' => 'raw' ) do
95
- segment = last_segment_for do
95
+ node = last_node_for do
96
96
  @posts[:id => 11]
97
97
  end
98
- assert_match %r{select \* from `posts` where \(?`id` = 11\)?( limit 1)?}i, segment.params[:sql]
99
- assert_segment_has_explain_plan( segment )
98
+ assert_match %r{select \* from `posts` where \(?`id` = 11\)?( limit 1)?}i, node.params[:sql]
99
+ assert_node_has_explain_plan( node )
100
100
  end
101
101
  end
102
102
 
103
103
  def test_sql_is_recorded_in_tt_for_non_select
104
104
  with_config(:'transaction_tracer.record_sql' => 'raw') do
105
- segment = last_segment_for do
105
+ node = last_node_for do
106
106
  @posts.insert(:title => 'title', :content => 'content')
107
107
  end
108
- assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, segment.params[:sql]
108
+ assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, node.params[:sql]
109
109
  end
110
110
  end
111
111
 
@@ -115,11 +115,11 @@ class SequelExtensionTest < Minitest::Test
115
115
  :'transaction_tracer.record_sql' => 'obfuscated'
116
116
  }
117
117
  with_config(config) do
118
- segment = last_segment_for(:record_sql => :obfuscated) do
118
+ node = last_node_for(:record_sql => :obfuscated) do
119
119
  @posts[:id => 11]
120
120
  end
121
- assert_match %r{select \* from `posts` where \(?`id` = \?\)?}i, segment.params[:sql]
122
- assert_segment_has_explain_plan( segment )
121
+ assert_match %r{select \* from `posts` where \(?`id` = \?\)?}i, node.params[:sql]
122
+ assert_node_has_explain_plan( node )
123
123
  end
124
124
  end
125
125
 
@@ -26,26 +26,26 @@ module SequelHelpers
26
26
 
27
27
  # This is particular to sqlite plans currently. To abstract it up, we'd need to
28
28
  # be able to specify a flavor (e.g., :sqlite, :postgres, :mysql, etc.)
29
- def assert_segment_has_explain_plan( segment, msg=nil )
30
- msg = "Expected #{segment.inspect} to have an explain plan"
31
- assert_block( msg ) { segment.params[:explain_plan].join =~ SQLITE_EXPLAIN_PLAN_COLUMNS_RE }
29
+ def assert_node_has_explain_plan( node, msg=nil )
30
+ msg = "Expected #{node.inspect} to have an explain plan"
31
+ assert_block( msg ) { node.params[:explain_plan].join =~ SQLITE_EXPLAIN_PLAN_COLUMNS_RE }
32
32
  end
33
33
 
34
- def last_segment_for(options={})
34
+ def last_node_for(options={})
35
35
  in_transaction('sandwiches/index') do
36
36
  yield
37
37
  end
38
38
  sample = NewRelic::Agent.instance.transaction_sampler.last_sample
39
39
  sample.prepare_to_send!
40
- last_segment(sample)
40
+ last_node(sample)
41
41
  end
42
42
 
43
- def last_segment(txn_sample)
44
- l_segment = nil
45
- txn_sample.root_segment.each_segment do |segment|
46
- l_segment = segment
43
+ def last_node(txn_sample)
44
+ l_node = nil
45
+ txn_sample.root_node.each_node do |node|
46
+ l_node = node
47
47
  end
48
- l_segment
48
+ l_node
49
49
  end
50
50
 
51
51
  def product_name
@@ -59,4 +59,4 @@ module SequelHelpers
59
59
  def assert_datastore_metrics_recorded_exclusive(metrics, options = {})
60
60
  assert_metrics_recorded_exclusive(metrics, {:filter => /^Datastores/}.update(options))
61
61
  end
62
- end
62
+ end
@@ -164,20 +164,20 @@ class SequelPluginTest < Minitest::Test
164
164
  def test_slow_queries_get_an_explain_plan
165
165
  with_config( :'transaction_tracer.explain_threshold' => -0.01,
166
166
  :'transaction_tracer.record_sql' => 'raw' ) do
167
- segment = last_segment_for do
167
+ node = last_node_for do
168
168
  Post[11]
169
169
  end
170
- assert_match %r{select \* from `posts` where `id` = 11}i, segment.params[:sql]
171
- assert_segment_has_explain_plan( segment )
170
+ assert_match %r{select \* from `posts` where `id` = 11}i, node.params[:sql]
171
+ assert_node_has_explain_plan( node )
172
172
  end
173
173
  end
174
174
 
175
175
  def test_sql_is_recorded_in_tt_for_non_select
176
176
  with_config(:'transaction_tracer.record_sql' => 'raw') do
177
- segment = last_segment_for do
177
+ node = last_node_for do
178
178
  Post.create(:title => 'title', :content => 'content')
179
179
  end
180
- assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, segment.params[:sql]
180
+ assert_match %r{insert into `posts` \([^\)]*\) values \([^\)]*\)}i, node.params[:sql]
181
181
  end
182
182
  end
183
183
 
@@ -189,11 +189,11 @@ class SequelPluginTest < Minitest::Test
189
189
 
190
190
  with_config(:'transaction_tracer.explain_threshold' => -0.01,
191
191
  :'transaction_tracer.record_sql' => 'raw') do
192
- segment = last_segment_for do
192
+ node = last_node_for do
193
193
  model_class[11]
194
194
  end
195
- assert_match %r{select \* from `posts` where `id` = 11}i, segment.params[:sql]
196
- assert_equal([], segment.params[:explain_plan], "Should not capture explain plan with single-threaded connection pool")
195
+ assert_match %r{select \* from `posts` where `id` = 11}i, node.params[:sql]
196
+ assert_equal([], node.params[:explain_plan], "Should not capture explain plan with single-threaded connection pool")
197
197
  end
198
198
  end
199
199
 
@@ -203,11 +203,11 @@ class SequelPluginTest < Minitest::Test
203
203
  :'transaction_tracer.record_sql' => 'obfuscated'
204
204
  }
205
205
  with_config(config) do
206
- segment = last_segment_for(:record_sql => :obfuscated) do
206
+ node = last_node_for(:record_sql => :obfuscated) do
207
207
  Post[11]
208
208
  end
209
- assert_match %r{select \* from `posts` where `id` = \?}i, segment.params[:sql]
210
- assert_segment_has_explain_plan( segment )
209
+ assert_match %r{select \* from `posts` where `id` = \?}i, node.params[:sql]
210
+ assert_node_has_explain_plan( node )
211
211
  end
212
212
  end
213
213
 
@@ -6,12 +6,9 @@ end
6
6
  if RUBY_VERSION >= '2.0.0' || (RUBY_PLATFORM == 'java')
7
7
  gemfile <<-RB
8
8
  gem 'json'
9
- gem 'sidekiq', '~> 3.2.0'
9
+ gem 'sidekiq', '~> 3.3.4'
10
10
  gem 'rack'
11
11
 
12
- # Work around for https://github.com/celluloid/celluloid/issues/457
13
- gem 'celluloid', '0.15.2'
14
-
15
12
  gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
16
13
  RB
17
14
  end
@@ -2,6 +2,15 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
+ module Sidekiq
6
+ class CLI
7
+ def exit(*args)
8
+ # No-op Sidekiq's exit since we don't want it shutting us down and eating
9
+ # our exit code
10
+ end
11
+ end
12
+ end
13
+
5
14
  if defined?(SidekiqServer)
6
15
  SidekiqServer.instance.stop
7
16
  end
@@ -51,7 +51,7 @@ class SidekiqTest < Minitest::Test
51
51
 
52
52
  def run_delayed
53
53
  run_and_transmit do |i|
54
- TestWorker.delay(:queue => SidekiqServer.instance.queue_name).record('jobs_completed', i + 1)
54
+ TestWorker.delay(:queue => SidekiqServer.instance.queue_name, :retry => false).record('jobs_completed', i + 1)
55
55
  end
56
56
  end
57
57
 
@@ -62,7 +62,7 @@ class SidekiqTest < Minitest::Test
62
62
  end
63
63
  end
64
64
 
65
- NewRelic::Agent.instance.send(:transmit_data)
65
+ run_harvest
66
66
  end
67
67
 
68
68
  def test_delayed
@@ -93,14 +93,16 @@ class SidekiqTest < Minitest::Test
93
93
 
94
94
  def test_doesnt_capture_args_by_default
95
95
  run_jobs
96
- assert_no_params_on_jobs
96
+ refute_attributes_on_transaction_trace
97
+ refute_attributes_on_events
97
98
  end
98
99
 
99
100
  def test_isnt_influenced_by_global_capture_params
100
101
  with_config(:capture_params => true) do
101
102
  run_jobs
102
103
  end
103
- assert_no_params_on_jobs
104
+ refute_attributes_on_transaction_trace
105
+ refute_attributes_on_events
104
106
  end
105
107
 
106
108
  def test_agent_posts_captured_args_to_job
@@ -108,18 +110,16 @@ class SidekiqTest < Minitest::Test
108
110
  run_jobs
109
111
  end
110
112
 
111
- transaction_samples = $collector.calls_for('transaction_sample_data')
112
- refute transaction_samples.empty?, "Expected a transaction trace"
113
-
114
- transaction_samples.each do |post|
115
- post.samples.each do |sample|
116
- assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
113
+ assert_attributes_on_transaction_trace
114
+ refute_attributes_on_events
115
+ end
117
116
 
118
- args = sample.tree.custom_params["job_arguments"]
119
- assert_equal args.length, 2
120
- assert_equal args[0], "jobs_completed"
121
- end
117
+ def test_arguments_are_captured_on_transaction_events_when_enabled
118
+ with_config(:'attributes.include' => 'job.sidekiq.args.*') do
119
+ run_jobs
122
120
  end
121
+
122
+ assert_attributes_on_events
123
123
  end
124
124
 
125
125
  def assert_metric_and_call_count(name, expected_call_count)
@@ -134,14 +134,47 @@ class SidekiqTest < Minitest::Test
134
134
  assert_equal(expected_call_count, call_count)
135
135
  end
136
136
 
137
- def assert_no_params_on_jobs
137
+ def assert_attributes_on_transaction_trace
138
+ transaction_samples = $collector.calls_for('transaction_sample_data')
139
+ refute transaction_samples.empty?, "Expected a transaction trace"
140
+
141
+ transaction_samples.each do |post|
142
+ post.samples.each do |sample|
143
+ assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
144
+
145
+ actual = sample.agent_attributes.keys.to_set
146
+ expected = Set.new ["job.sidekiq.args.0", "job.sidekiq.args.1"]
147
+ assert_equal expected, actual
148
+ end
149
+ end
150
+ end
151
+
152
+ def refute_attributes_on_transaction_trace
138
153
  transaction_samples = $collector.calls_for('transaction_sample_data')
139
154
  refute transaction_samples.empty?, "Didn't find any transaction samples!"
140
155
 
141
156
  transaction_samples.each do |post|
142
157
  post.samples.each do |sample|
143
158
  assert_equal sample.metric_name, TRANSACTION_NAME, "Huh, that transaction shouldn't be in there!"
144
- assert_nil sample.tree.custom_params["job_arguments"]
159
+ assert sample.agent_attributes.keys.none? { |k| k =~ /^job.sidekiq.args.*/ }
160
+ end
161
+ end
162
+ end
163
+
164
+ def assert_attributes_on_events
165
+ event_posts = $collector.calls_for('analytic_event_data')
166
+ event_posts.each do |post|
167
+ post.events.each do |event|
168
+ assert_equal Set.new(["job.sidekiq.args.0", "job.sidekiq.args.1"]), event[2].keys.to_set
169
+ end
170
+ end
171
+ end
172
+
173
+ def refute_attributes_on_events
174
+ event_posts = $collector.calls_for('analytic_event_data')
175
+ event_posts.each do |post|
176
+ post.events.each do |event|
177
+ assert event[2].keys.none? { |k| k.start_with?("job.sidekiq.args") }, "Found unexpected sidekiq arguments"
145
178
  end
146
179
  end
147
180
  end
@@ -5,8 +5,7 @@
5
5
  class TestWorker
6
6
  include Sidekiq::Worker
7
7
 
8
- sidekiq_options :queue => SidekiqServer.instance.queue_name
9
-
8
+ sidekiq_options :queue => SidekiqServer.instance.queue_name, :retry => false
10
9
  @jobs = {}
11
10
  @jobs_mutex = Mutex.new
12
11
 
@@ -1,5 +1,5 @@
1
1
  gemfile <<-RB
2
- gem 'sinatra', '~> 1.4.5'
2
+ gem 'sinatra', '~> 1.4.6'
3
3
  gem 'rack', '~> 1.5.0'
4
4
  gem 'rack-test', :require => 'rack/test'
5
5
  RB
@@ -11,6 +11,7 @@ development:
11
11
  app_name: test
12
12
  host: 127.0.0.1
13
13
  api_host: 127.0.0.1
14
+ port: <%= $collector && $collector.port %>
14
15
  transaction_tracer:
15
16
  record_sql: obfuscated
16
17
  enabled: true
@@ -83,10 +83,6 @@ get(/\/regex.*/) do
83
83
  "Yeah, regex's!"
84
84
  end
85
85
 
86
- post '/files' do
87
- "file uploaded"
88
- end
89
-
90
86
  module Sinatra
91
87
  class Application < Base
92
88
  # Override to not accidentally start the app in at_exit handler
@@ -78,10 +78,6 @@ class SinatraModularTestApp < Sinatra::Base
78
78
  get(/\/regex.*/) do
79
79
  "Yeah, regex's!"
80
80
  end
81
-
82
- post '/files' do
83
- "file uploaded"
84
- end
85
81
  end
86
82
 
87
83
  class SinatraModularTest < Minitest::Test
@@ -0,0 +1,65 @@
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
+ class SinatraParameterCaptureTestApp < Sinatra::Base
6
+ post "/capture_test" do
7
+ "capture test"
8
+ end
9
+
10
+ post '/files' do
11
+ "file uploaded"
12
+ end
13
+ end
14
+
15
+
16
+ class SinatraParameterCaptureTest < Minitest::Test
17
+ include Rack::Test::Methods
18
+ include MultiverseHelpers
19
+
20
+ setup_and_teardown_agent
21
+
22
+ def app
23
+ SinatraParameterCaptureTestApp
24
+ end
25
+
26
+ def app_name
27
+ app.to_s
28
+ end
29
+
30
+ def test_request_params_are_captured_for_transaction_events
31
+ with_config(:'attributes.include' => 'request.parameters.*') do
32
+ params = {
33
+ :foo => "bar",
34
+ :bar => "baz"
35
+ }
36
+ post '/capture_test', params
37
+ end
38
+
39
+ expected = {
40
+ "request.parameters.foo" => "bar",
41
+ "request.parameters.bar" => "baz"
42
+ }
43
+
44
+ actual = agent_attributes_for_single_event_posted_without_ignored_attributes
45
+
46
+ assert_equal(expected, actual)
47
+ end
48
+
49
+ def test_file_upload_params_are_filtered
50
+ with_config(:capture_params => true) do
51
+ params = {
52
+ :title => "blah",
53
+ :file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
54
+ }
55
+ post '/files', params
56
+
57
+ expected = {
58
+ "request.parameters.title" => "blah",
59
+ "request.parameters.file" => "[FILE]"
60
+ }
61
+
62
+ assert_equal(expected, last_transaction_trace_request_params)
63
+ end
64
+ end
65
+ end