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
@@ -152,7 +152,7 @@ class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < Minitest::Tes
152
152
  assert_metrics_not_recorded('View/model/_user.html.erb/Partial')
153
153
  end
154
154
 
155
- def test_creates_txn_segment_for_simple_render
155
+ def test_creates_txn_node_for_simple_render
156
156
  params = { :identifier => '/root/app/views/model/index.html.erb' }
157
157
 
158
158
  in_transaction do
@@ -164,16 +164,16 @@ class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < Minitest::Tes
164
164
  @subscriber.finish('render_template.action_view', :id, params)
165
165
  end
166
166
 
167
- last_segment = nil
167
+ last_node = nil
168
168
  sampler = NewRelic::Agent.instance.transaction_sampler
169
- sampler.last_sample.root_segment.each_segment{|s| last_segment = s }
169
+ sampler.last_sample.root_node.each_node{|s| last_node = s }
170
170
  NewRelic::Agent.shutdown
171
171
 
172
172
  assert_equal('View/model/index.html.erb/Rendering',
173
- last_segment.metric_name)
173
+ last_node.metric_name)
174
174
  end
175
175
 
176
- def test_creates_nested_partial_segment_within_render_segment
176
+ def test_creates_nested_partial_node_within_render_node
177
177
  in_transaction do
178
178
  @subscriber.start('render_template.action_view', :id,
179
179
  :identifier => 'model/index.html.erb')
@@ -194,13 +194,13 @@ class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < Minitest::Tes
194
194
  end
195
195
 
196
196
  sampler = NewRelic::Agent.instance.transaction_sampler
197
- template_segment = sampler.last_sample.root_segment.called_segments[0].called_segments[0]
198
- partial_segment = template_segment.called_segments[0]
197
+ template_node = sampler.last_sample.root_node.called_nodes[0].called_nodes[0]
198
+ partial_node = template_node.called_nodes[0]
199
199
 
200
200
  assert_equal('View/model/index.html.erb/Rendering',
201
- template_segment.metric_name)
201
+ template_node.metric_name)
202
202
  assert_equal('View/model/_list.html.erb/Partial',
203
- partial_segment.metric_name)
203
+ partial_node.metric_name)
204
204
  end
205
205
 
206
206
  def test_creates_nodes_for_each_in_a_collection_event
@@ -226,11 +226,11 @@ class NewRelic::Agent::Instrumentation::ActionViewSubscriberTest < Minitest::Tes
226
226
  end
227
227
 
228
228
  sampler = NewRelic::Agent.instance.transaction_sampler
229
- partial_segments = sampler.last_sample.root_segment.called_segments[0].called_segments
229
+ partial_nodes = sampler.last_sample.root_node.called_nodes[0].called_nodes
230
230
 
231
- assert_equal 3, partial_segments.size
231
+ assert_equal 3, partial_nodes.size
232
232
  assert_equal('View/model/_list.html.erb/Partial',
233
- partial_segments[0].metric_name)
233
+ partial_nodes[0].metric_name)
234
234
  end
235
235
  end if ::Rails::VERSION::MAJOR.to_i >= 4
236
236
 
@@ -73,21 +73,21 @@ class NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest < Minitest::T
73
73
  )
74
74
  end
75
75
 
76
- def test_creates_txn_segment
76
+ def test_creates_txn_node
77
77
  freeze_time
78
78
 
79
79
  in_transaction do
80
80
  simulate_query(2)
81
81
  end
82
82
 
83
- last_segment = nil
83
+ last_node = nil
84
84
  sampler = NewRelic::Agent.instance.transaction_sampler
85
- sampler.last_sample.root_segment.each_segment{|s| last_segment = s }
85
+ sampler.last_sample.root_node.each_node{|s| last_node = s }
86
86
 
87
87
  assert_equal('Datastore/statement/ActiveRecord/NewRelic::Agent::Instrumentation::ActiveRecordSubscriberTest::Order/find',
88
- last_segment.metric_name)
88
+ last_node.metric_name)
89
89
  assert_equal('SELECT * FROM sandwiches',
90
- last_segment.params[:sql])
90
+ last_node.params[:sql])
91
91
  end
92
92
 
93
93
  def test_creates_slow_sql_node
@@ -307,19 +307,19 @@ module NewRelic::Agent::Instrumentation
307
307
  end
308
308
  end
309
309
 
310
- def test_should_not_set_request
310
+ def test_should_not_set_request_path
311
311
  clazz = Class.new do
312
312
  include ControllerInstrumentation
313
313
 
314
314
  def doit
315
315
  perform_action_with_newrelic_trace do
316
- NewRelic::Agent::TransactionState.tl_get.current_transaction.request
316
+ NewRelic::Agent::TransactionState.tl_get.current_transaction.request_path
317
317
  end
318
318
  end
319
319
  end
320
320
 
321
- request = clazz.new.doit
322
- assert_nil request
321
+ request_path = clazz.new.doit
322
+ assert_nil request_path
323
323
  end
324
324
  end
325
325
  end
@@ -20,7 +20,7 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Minitest::Test
20
20
  end
21
21
 
22
22
  def run_task_exception
23
- NewRelic::Agent.add_custom_parameters(:custom_one => 'one custom val')
23
+ NewRelic::Agent.add_custom_attributes(:custom_one => 'one custom val')
24
24
  assert_equal 1, NewRelic::Agent::BusyCalculator.busy_count
25
25
  raise "This is an error"
26
26
  end
@@ -120,7 +120,9 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Minitest::Test
120
120
  end
121
121
 
122
122
  def test_transaction
123
- run_task_outer(10)
123
+ with_config(:capture_params => true) do
124
+ run_task_outer(10)
125
+ end
124
126
 
125
127
  assert_metrics_recorded({
126
128
  'Nested/Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/outer_task' => { :call_count => 1 },
@@ -129,10 +131,13 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Minitest::Test
129
131
  assert_metrics_not_recorded(['Controller'])
130
132
 
131
133
  sample = @agent.transaction_sampler.last_sample
134
+
132
135
  refute_nil(sample)
133
- refute_nil(sample.params[:custom_params][:cpu_time], "cpu time nil: \n#{sample}")
134
- assert((sample.params[:custom_params][:cpu_time] >= 0), "cpu time: #{sample.params[:cpu_time]},\n#{sample}")
135
- assert_equal('10', sample.params[:request_params][:level])
136
+ cpu_time = attributes_for(sample, :intrinsic)[:cpu_time]
137
+
138
+ refute_nil(cpu_time, "cpu time nil: \n#{sample}")
139
+ assert(cpu_time >= 0, "cpu time: #{cpu_time},\n#{sample}")
140
+ assert_equal(10, attributes_for(sample, :agent)['request.parameters.level'])
136
141
  end
137
142
 
138
143
  def test_abort_transaction
@@ -147,15 +152,17 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Minitest::Test
147
152
 
148
153
  def test_perform_action_with_newrelic_trace_saves_params
149
154
  account = 'Redrocks'
150
- perform_action_with_newrelic_trace(:name => 'hello', :force => true,
151
- :params => { :account => account }) do
152
- self.class.inspect
155
+ with_config(:capture_params => true) do
156
+ perform_action_with_newrelic_trace(:name => 'hello', :force => true,
157
+ :params => { :account => account }) do
158
+ self.class.inspect
159
+ end
153
160
  end
154
161
 
155
162
  assert_metrics_recorded(['Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/hello'])
156
163
  sample = @agent.transaction_sampler.last_sample
157
164
  refute_nil(sample)
158
- assert_equal(account, sample.params[:request_params][:account])
165
+ assert_equal(account, attributes_for(sample, :agent)['request.parameters.account'])
159
166
  end
160
167
 
161
168
  def test_errors_are_noticed_and_not_swallowed
@@ -169,10 +176,13 @@ class NewRelic::Agent::Instrumentation::TaskInstrumentationTest < Minitest::Test
169
176
  errors = @agent.error_collector.harvest!
170
177
 
171
178
  assert_equal(1, errors.size)
179
+
172
180
  error = errors.first
173
181
  assert_equal("Controller/NewRelic::Agent::Instrumentation::TaskInstrumentationTest/run_task_exception", error.path)
174
- refute_nil(error.params[:stack_trace])
175
- refute_nil(error.params[:custom_params])
182
+ refute_nil(error.stack_trace)
183
+
184
+ result = error.attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
185
+ refute_nil(result["custom_one"])
176
186
  end
177
187
 
178
188
  def test_instrument_background_job
@@ -16,7 +16,8 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
16
16
  :browser_key => 'browserKey',
17
17
  :js_agent_loader => 'loader',
18
18
  :license_key => "\0", # no-op obfuscation key
19
- :'rum.enabled' => true
19
+ :'rum.enabled' => true,
20
+ :disable_harvest_thread => true
20
21
  }
21
22
  NewRelic::Agent.config.add_config_for_testing(@config)
22
23
 
@@ -58,8 +59,8 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
58
59
  end
59
60
 
60
61
  def test_browser_timing_scripts_with_rum_enabled_false
61
- in_transaction do
62
- with_config(:'rum.enabled' => false) do
62
+ with_config(:'rum.enabled' => false) do
63
+ in_transaction do
63
64
  assert_equal "", instrumentor.browser_timing_header
64
65
  end
65
66
  end
@@ -82,24 +83,24 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
82
83
  end
83
84
 
84
85
  def test_browser_timing_header_without_loader
85
- in_transaction do
86
- with_config(:js_agent_loader => '') do
86
+ with_config(:js_agent_loader => '') do
87
+ in_transaction do
87
88
  assert_equal "", instrumentor.browser_timing_header
88
89
  end
89
90
  end
90
91
  end
91
92
 
92
93
  def test_browser_timing_header_without_beacon
93
- in_transaction do
94
- with_config(:beacon => '') do
94
+ with_config(:beacon => '') do
95
+ in_transaction do
95
96
  assert_equal "", instrumentor.browser_timing_header
96
97
  end
97
98
  end
98
99
  end
99
100
 
100
101
  def test_browser_timing_header_without_browser_key
101
- in_transaction do
102
- with_config(:browser_key => '') do
102
+ with_config(:browser_key => '') do
103
+ in_transaction do
103
104
  assert_equal "", instrumentor.browser_timing_header
104
105
  end
105
106
  end
@@ -150,10 +151,8 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
150
151
 
151
152
  def test_config_data_for_js_agent
152
153
  freeze_time
153
- in_transaction('most recent transaction') do
154
- with_config(CAPTURE_ATTRIBUTES => true) do
155
- NewRelic::Agent.set_user_attributes(:user => "user")
156
-
154
+ with_config(CAPTURE_ATTRIBUTES => true) do
155
+ in_transaction('most recent transaction') do
157
156
  txn = NewRelic::Agent::Transaction.tl_current
158
157
  txn.stubs(:queue_time).returns(0)
159
158
  txn.stubs(:start_time).returns(Time.now - 10)
@@ -170,20 +169,39 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
170
169
  "transactionName" => pack("most recent transaction"),
171
170
  "queueTime" => 0,
172
171
  "applicationTime" => 10000,
173
- "agent" => "",
174
- "userAttributes" => pack('{"user":"user"}')
172
+ "agent" => ""
175
173
  }
176
174
 
177
- assert_equal(expected, data)
178
-
179
175
  js = instrumentor.browser_timing_config(state)
180
176
  expected.each do |key, value|
177
+ assert_equal(value, data[key])
181
178
  assert_match(/"#{key.to_s}":#{formatted_for_matching(value)}/, js)
182
179
  end
183
180
  end
184
181
  end
185
182
  end
186
183
 
184
+ def test_config_data_for_js_agent_attributes
185
+ freeze_time
186
+ with_config(CAPTURE_ATTRIBUTES => true) do
187
+ in_transaction('most recent transaction') do
188
+ NewRelic::Agent.add_custom_attributes(:user => "user")
189
+ NewRelic::Agent::Transaction.add_agent_attribute(:agent, "attribute", NewRelic::Agent::AttributeFilter::DST_ALL)
190
+
191
+ state = NewRelic::Agent::TransactionState.tl_get
192
+ data = instrumentor.data_for_js_agent(state)
193
+
194
+ # Handle packed atts key specially since it's obfuscated
195
+ actual = unpack_to_object(data["atts"])
196
+ expected = {
197
+ "u" => {"user" => "user"},
198
+ "a" => {"agent" => "attribute"}
199
+ }
200
+ assert_equal expected, actual
201
+ end
202
+ end
203
+ end
204
+
187
205
  def test_ssl_for_http_not_included_by_default
188
206
  state = NewRelic::Agent::TransactionState.tl_get
189
207
  data = instrumentor.data_for_js_agent(state)
@@ -206,48 +224,49 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
206
224
  end
207
225
  end
208
226
 
227
+ ATTRIBUTES_ENABLED = :'browser_monitoring.attributes.enabled'
209
228
  CAPTURE_ATTRIBUTES = :'browser_monitoring.capture_attributes'
210
- CAPTURE_ATTRIBUTES_DEPRECATED = :'capture_attributes.page_view_events'
211
229
 
212
- def test_data_for_js_agent_doesnt_get_custom_parameters_by_default
213
- in_transaction do
214
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
215
- assert_user_attributes_missing
230
+ def test_data_for_js_agent_doesnt_get_custom_attributes_by_default
231
+ with_config({}) do
232
+ in_transaction do
233
+ NewRelic::Agent.add_custom_attributes({:boo => "hoo"})
234
+ assert_attributes_missing
235
+ end
216
236
  end
217
237
  end
218
238
 
219
- def test_data_for_js_agent_doesnt_get_custom_parameters_outside_transaction
239
+ def test_data_for_js_agent_doesnt_get_custom_attributes_outside_transaction
220
240
  with_config(CAPTURE_ATTRIBUTES => true) do
221
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
222
- assert_user_attributes_missing
241
+ NewRelic::Agent.add_custom_attributes({:boo => "hoo"})
242
+ assert_attributes_missing
223
243
  end
224
244
  end
225
245
 
226
246
 
227
- def test_data_for_js_agent_gets_custom_parameters_when_configured
228
- in_transaction do
229
- with_config(CAPTURE_ATTRIBUTES => true) do
230
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
231
- assert_user_attributes_are('{"boo":"hoo"}')
247
+ def test_data_for_js_agent_gets_custom_attributes_with_old_config
248
+ with_config(CAPTURE_ATTRIBUTES => true) do
249
+ in_transaction do
250
+ NewRelic::Agent.add_custom_attributes({:boo => "hoo"})
251
+ assert_attributes_are('{"u":{"boo":"hoo"}}')
232
252
  end
233
253
  end
234
254
  end
235
255
 
236
- def test_data_for_js_agent_ignores_custom_parameters_by_config
237
- in_transaction do
238
- with_config(CAPTURE_ATTRIBUTES => false) do
239
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
240
- assert_user_attributes_missing
256
+ def test_data_for_js_agent_gets_custom_attributes_when_configured
257
+ with_config(ATTRIBUTES_ENABLED => true) do
258
+ in_transaction do
259
+ NewRelic::Agent.add_custom_attributes({:boo => "hoo"})
260
+ assert_attributes_are('{"u":{"boo":"hoo"}}')
241
261
  end
242
262
  end
243
263
  end
244
264
 
245
- def test_data_for_js_agent_gets_custom_parameters_with_deprecated_key
246
- in_transaction do
247
- with_config(CAPTURE_ATTRIBUTES => false,
248
- CAPTURE_ATTRIBUTES_DEPRECATED => true) do
249
- NewRelic::Agent.add_custom_parameters({:boo => "hoo"})
250
- assert_user_attributes_are('{"boo":"hoo"}')
265
+ def test_data_for_js_agent_ignores_custom_attributes_by_config
266
+ with_config(CAPTURE_ATTRIBUTES => false) do
267
+ in_transaction do
268
+ NewRelic::Agent.add_custom_attributes({:boo => "hoo"})
269
+ assert_attributes_missing
251
270
  end
252
271
  end
253
272
  end
@@ -286,22 +305,27 @@ class NewRelic::Agent::JavascriptInstrumentorTest < Minitest::Test
286
305
  assert(footer.include?(snippet), "Expected footer to include snippet: #{snippet}, but instead was #{footer}")
287
306
  end
288
307
 
289
- def assert_user_attributes_are(expected)
308
+ def assert_attributes_are(expected)
290
309
  state = NewRelic::Agent::TransactionState.tl_get
291
310
  data = instrumentor.data_for_js_agent(state)
292
- assert_equal pack(expected), data["userAttributes"]
311
+ assert_equal pack(expected), data["atts"]
293
312
  end
294
313
 
295
- def assert_user_attributes_missing
314
+ def assert_attributes_missing
296
315
  state = NewRelic::Agent::TransactionState.tl_get
297
316
  data = instrumentor.data_for_js_agent(state)
298
- assert_not_includes data, "userAttributes"
317
+ assert_not_includes data, "atts"
299
318
  end
300
319
 
301
320
  def pack(text)
302
321
  [text].pack("m0").gsub("\n", "")
303
322
  end
304
323
 
324
+ def unpack_to_object(text)
325
+ unpacked_atts = instrumentor.obfuscator.deobfuscate(text)
326
+ NewRelic::JSONWrapper.load(unpacked_atts)
327
+ end
328
+
305
329
  def formatted_for_matching(value)
306
330
  case value
307
331
  when String
@@ -45,7 +45,7 @@ class PipeServiceTest < Minitest::Test
45
45
  @service.metric_data(metric_data0)
46
46
  end
47
47
 
48
- assert_equal 'Custom/something', received_data[:metric_data].keys.sort[0].name
48
+ assert_equal 'Custom/something', received_data[:metric_data].to_h.keys.sort[0].name
49
49
  end
50
50
 
51
51
  def test_transaction_sample_data
@@ -105,7 +105,7 @@ class PipeServiceTest < Minitest::Test
105
105
 
106
106
  received_data = read_from_pipe
107
107
 
108
- assert_equal 'Custom/something', received_data[:metric_data].keys.sort[0].name
108
+ assert_equal 'Custom/something', received_data[:metric_data].to_h.keys.sort[0].name
109
109
  assert_equal ['txn0'], received_data[:transaction_sample_data]
110
110
  assert_equal ['err0'], received_data[:error_data].sort
111
111
  end
@@ -126,7 +126,7 @@ class NewRelic::Agent::StatsEngine
126
126
  assert_metrics_not_recorded(GCProfiler::GC_WEB)
127
127
 
128
128
  tracer = NewRelic::Agent.instance.transaction_sampler
129
- assert_equal(3.0, tracer.last_sample.params[:custom_params][:gc_time])
129
+ assert_equal(3.0, attributes_for(tracer.last_sample, :intrinsic)[:gc_time])
130
130
  end
131
131
 
132
132
  def test_collect_gc_data_web
@@ -231,7 +231,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
231
231
  assert_equal 2, @engine.get_stats("c").call_count
232
232
  assert_equal 4, @engine.get_stats("c").total_call_time
233
233
 
234
- harvested = @engine.harvest!
234
+ harvested = @engine.harvest!.to_h
235
235
 
236
236
  # after harvest, all the metrics should be reset
237
237
  assert_equal 0, @engine.get_stats("a").call_count
@@ -240,6 +240,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
240
240
  assert_equal 0, @engine.get_stats("c").total_call_time
241
241
 
242
242
  spec_a = NewRelic::MetricSpec.new('a')
243
+
243
244
  assert(harvested.has_key?(spec_a))
244
245
  assert_equal(1, harvested[spec_a].call_count)
245
246
  assert_equal(10, harvested[spec_a].total_call_time)
@@ -258,11 +259,11 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
258
259
  @engine.get_stats_no_scope('Custom/foo/3/bar/44').record_data_point(1)
259
260
  @engine.get_stats_no_scope('Custom/foo/5/bar/66').record_data_point(1)
260
261
 
261
- harvested = @engine.harvest!
262
+ harvested = @engine.harvest!.to_h
262
263
 
263
- assert !harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/1/bar/22'))
264
- assert !harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/3/bar/44'))
265
- assert !harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/5/bar/66'))
264
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/1/bar/22'))
265
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/3/bar/44'))
266
+ refute harvested.has_key?(NewRelic::MetricSpec.new('Custom/foo/5/bar/66'))
266
267
  merged = harvested[NewRelic::MetricSpec.new('Custom/foo/*/bar/*')]
267
268
  assert_equal(3, merged.call_count)
268
269
  end
@@ -282,7 +283,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
282
283
  renamed = @engine.apply_rules_to_metric_data(rules_engine, stats_hash)
283
284
 
284
285
  assert_equal(1 , renamed.size)
285
- assert_equal('foo', renamed.keys.first.name)
286
+ assert_equal('foo', renamed.to_h.keys.first.name)
286
287
  end
287
288
 
288
289
  def test_harvest_with_merge
@@ -301,7 +302,7 @@ class NewRelic::Agent::MetricStatsTest < Minitest::Test
301
302
  # so the stats for metric "a" should have 2 data points
302
303
  @engine.merge!(harvest)
303
304
  harvest = @engine.harvest!
304
- stats = harvest.fetch(NewRelic::MetricSpec.new("a"))
305
+ stats = harvest[NewRelic::MetricSpec.new("a")]
305
306
  assert_equal 2, stats.call_count
306
307
  assert_equal 3, stats.total_call_time
307
308
  end