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
@@ -4,42 +4,34 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
 
7
- class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
7
+ class NewRelic::Agent::TransactionSampleBuilderTest < Minitest::Test
8
8
 
9
9
  def setup
10
10
  freeze_time
11
11
  @builder = NewRelic::Agent::TransactionSampleBuilder.new
12
12
  end
13
13
 
14
- # if it doesn't the core app tests will break. Not strictly necessary but
15
- # we'll enforce it with this test for now.
16
- def test_trace_entry_returns_segment
17
- segment = @builder.trace_entry(Time.now)
18
- assert segment, "Segment should not be nil"
19
- assert segment.is_a?(NewRelic::TransactionSample::Segment), "Segment should not be a #{segment.class.name}"
20
- end
21
-
22
14
  def test_build_sample
23
- build_segment("a") do
24
- build_segment("aa") do
25
- build_segment("aaa")
15
+ build_node("a") do
16
+ build_node("aa") do
17
+ build_node("aaa")
26
18
  end
27
- build_segment("ab") do
28
- build_segment("aba") do
29
- build_segment("abaa")
19
+ build_node("ab") do
20
+ build_node("aba") do
21
+ build_node("abaa")
30
22
  end
31
- build_segment("aba")
32
- build_segment("abc") do
33
- build_segment("abca")
34
- build_segment("abcd")
23
+ build_node("aba")
24
+ build_node("abc") do
25
+ build_node("abca")
26
+ build_node("abcd")
35
27
  end
36
28
  end
37
29
  end
38
- build_segment "b"
39
- build_segment "c" do
40
- build_segment "ca"
41
- build_segment "cb" do
42
- build_segment "cba"
30
+ build_node "b"
31
+ build_node "c" do
32
+ build_node "ca"
33
+ build_node "cb" do
34
+ build_node "cba"
43
35
  end
44
36
  end
45
37
 
@@ -48,101 +40,101 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
48
40
  end
49
41
 
50
42
  def test_freeze
51
- build_segment "a" do
52
- build_segment "aa"
43
+ build_node "a" do
44
+ build_node "aa"
53
45
  end
54
46
 
55
47
  @builder.finish_trace(Time.now.to_f)
56
48
 
57
49
  validate_builder
58
50
 
59
- assert_raises(TypeError) do
60
- build_segment "b"
51
+ assert_raises(NewRelic::Agent::Transaction::Trace::FinishedTraceError) do
52
+ build_node "b"
61
53
  end
62
54
  end
63
55
 
64
56
  def test_marshal
65
- build_segment "a" do
66
- build_segment "ab"
67
- end
68
- build_segment "b" do
69
- build_segment "ba"
70
- build_segment "bb"
71
- build_segment "bc" do
72
- build_segment "bca"
57
+ build_node "a" do
58
+ build_node "ab"
59
+ end
60
+ build_node "b" do
61
+ build_node "ba"
62
+ build_node "bb"
63
+ build_node "bc" do
64
+ build_node "bca"
73
65
  end
74
66
  end
75
- build_segment "c"
67
+ build_node "c"
76
68
 
77
69
  @builder.finish_trace(Time.now.to_f)
78
70
  validate_builder
79
71
 
80
72
  dump = Marshal.dump @builder.sample
81
73
  sample = Marshal.restore(dump)
82
- validate_segment(sample.root_segment)
74
+ validate_node(sample.root_node)
83
75
  end
84
76
 
85
- def test_parallel_first_level_segments
86
- build_segment "a" do
87
- build_segment "ab"
77
+ def test_parallel_first_level_nodes
78
+ build_node "a" do
79
+ build_node "ab"
88
80
  end
89
- build_segment "b"
90
- build_segment "c"
81
+ build_node "b"
82
+ build_node "c"
91
83
 
92
84
  @builder.finish_trace(Time.now.to_f)
93
85
  validate_builder
94
86
  end
95
87
 
96
- def test_trace_should_not_record_more_than_segment_limit
88
+ def test_trace_should_not_record_more_than_node_limit
97
89
  with_config(:'transaction_tracer.limit_segments' => 3) do
98
- 8.times {|i| build_segment i.to_s }
99
- assert_equal 3, @builder.sample.count_segments
90
+ 8.times {|i| build_node i.to_s }
91
+ assert_equal 3, @builder.sample.count_nodes
100
92
  end
101
93
  end
102
94
 
103
- def test_trace_has_valid_durations_when_segments_limited
95
+ def test_trace_has_valid_durations_when_nodes_limited
104
96
  with_config(:'transaction_tracer.limit_segments' => 3) do
105
- build_segment "parent" do
97
+ build_node "parent" do
106
98
  advance_time 1
107
- build_segment "child-0.0" do
99
+ build_node "child-0.0" do
108
100
  advance_time 1
109
- build_segment "child-0.1" do
101
+ build_node "child-0.1" do
110
102
  advance_time 1
111
103
  end
112
104
  end
113
105
  advance_time 1
114
- build_segment "child-1.0" do
106
+ build_node "child-1.0" do
115
107
  advance_time 1
116
- build_segment "child-1.1" do
108
+ build_node "child-1.1" do
117
109
  advance_time 1
118
110
  end
119
111
  end
120
112
  end
121
113
 
122
114
  sample = @builder.sample
123
- assert_equal(3, sample.count_segments)
124
-
125
- segment_names = []
126
- segment_durations = []
127
- sample.each_segment do |s|
128
- if s != sample.root_segment
129
- segment_names << s.metric_name
130
- segment_durations << s.duration
115
+ assert_equal(3, sample.count_nodes)
116
+
117
+ node_names = []
118
+ node_durations = []
119
+ sample.each_node do |s|
120
+ if s != sample.root_node
121
+ node_names << s.metric_name
122
+ node_durations << s.duration
131
123
  end
132
124
  end
133
125
 
134
- assert_equal(["parent", "child-0.0", "child-0.1"], segment_names)
135
- assert_equal([6.0, 2.0, 1.0], segment_durations)
126
+ assert_equal(["parent", "child-0.0", "child-0.1"], node_names)
127
+ assert_equal([6.0, 2.0, 1.0], node_durations)
136
128
  end
137
129
  end
138
130
 
139
- def test_attaching_params_doesnt_raise_when_segments_are_limited
131
+ def test_attaching_params_doesnt_raise_when_nodes_are_limited
140
132
  with_config(:'transaction_tracer.limit_segments' => 5) do
141
- 6.times { |i| build_segment "s#{i}" }
142
- # now we should have a placeholder segment
143
- build_segment "this-should-be-truncated" do
144
- @builder.current_segment['eggs'] = 'ham'
145
- @builder.current_segment.params.merge!('foo' => 'bar')
133
+ 6.times { |i| build_node "s#{i}" }
134
+ # now we should have a placeholder node
135
+ build_node "this-should-be-truncated" do
136
+ @builder.current_node['eggs'] = 'ham'
137
+ @builder.current_node.params.merge!('foo' => 'bar')
146
138
  end
147
139
  end
148
140
  end
@@ -155,10 +147,10 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
155
147
  end
156
148
 
157
149
  # regression
158
- def test_trace_should_log_segment_reached_once
150
+ def test_trace_should_log_node_reached_once
159
151
  with_config(:'transaction_tracer.limit_segments' => 3) do
160
- expects_logging(:debug, includes("Segment limit"))
161
- 8.times {|i| build_segment i.to_s }
152
+ expects_logging(:debug, includes("Node limit"))
153
+ 8.times {|i| build_node i.to_s }
162
154
  end
163
155
  end
164
156
 
@@ -186,14 +178,14 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
186
178
  end
187
179
 
188
180
  def validate_builder(check_names = true)
189
- validate_segment @builder.sample.root_segment, check_names
181
+ validate_node @builder.sample.root_node, check_names
190
182
  end
191
183
 
192
- def validate_segment(s, check_names = true)
193
- p = s.parent_segment
184
+ def validate_node(s, check_names = true)
185
+ p = s.parent_node
194
186
 
195
187
  unless p.nil? || p.metric_name == 'ROOT'
196
- assert p.called_segments.include?(s)
188
+ assert p.called_nodes.include?(s)
197
189
  assert_equal p.metric_name.length, s.metric_name.length - 1, "p: #{p.metric_name}, s: #{s.metric_name}" if check_names
198
190
  assert p.metric_name < s.metric_name if check_names
199
191
  assert p.entry_timestamp <= s.entry_timestamp
@@ -201,7 +193,7 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
201
193
 
202
194
  assert s.exit_timestamp >= s.entry_timestamp
203
195
 
204
- children = s.called_segments
196
+ children = s.called_nodes
205
197
  parent = s
206
198
  children.each do |child|
207
199
  if check_names
@@ -211,11 +203,11 @@ class NewRelic::Agent::TransationSampleBuilderTest < Minitest::Test
211
203
  assert(child.entry_timestamp >= parent.entry_timestamp,
212
204
  "#{child.entry_timestamp} !>= #{parent.entry_timestamp}")
213
205
 
214
- validate_segment(child, check_names)
206
+ validate_node(child, check_names)
215
207
  end
216
208
  end
217
209
 
218
- def build_segment(metric, time = 0, &proc)
210
+ def build_node(metric, time = 0, &proc)
219
211
  @builder.trace_entry(Time.now.to_f)
220
212
  proc.call if proc
221
213
  @builder.trace_exit(metric, Time.now.to_f)
@@ -36,14 +36,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
36
36
  NewRelic::Agent.instance.instance_variable_set(:@transaction_sampler, @sampler)
37
37
  @test_config = { :'transaction_tracer.enabled' => true }
38
38
  NewRelic::Agent.config.add_config_for_testing(@test_config)
39
+
40
+ attributes = NewRelic::Agent::Transaction::Attributes.new(NewRelic::Agent.instance.attribute_filter)
39
41
  @txn = stub('txn',
40
42
  :best_name => '/path',
43
+ :request_path => '/request_path',
41
44
  :guid => 'a guid',
42
- :custom_parameters => {},
45
+ :ignore_trace? => false,
43
46
  :cat_trip_id => '',
44
47
  :cat_path_hash => '',
45
48
  :is_synthetics_request? => false,
46
- :filtered_params => {} )
49
+ :filtered_params => {},
50
+ :attributes => attributes
51
+ )
47
52
  end
48
53
 
49
54
  def teardown
@@ -61,7 +66,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
61
66
 
62
67
  def populate_container(sampler, n)
63
68
  n.times do |i|
64
- sample = sample_with(:duration => 1, :transaction_name => "t#{i}", :force_persist => true)
69
+ sample = sample_with(:duration => 1, :transaction_name => "t#{i}", :synthetics_resource_id => 1)
65
70
  @sampler.store_sample(sample)
66
71
  end
67
72
  end
@@ -125,30 +130,12 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
125
130
  assert_equal('a guid', @sampler.last_sample.guid)
126
131
  end
127
132
 
128
- def test_ignore_transaction_no_builder
129
- ret = @sampler.ignore_transaction(@state)
130
- assert_nil ret
131
- end
132
-
133
- def test_ignore_transaction_with_builder
134
- in_transaction do
135
- @sampler.ignore_transaction(@state)
136
- end
137
-
138
- assert_nil(@sampler.last_sample)
139
- end
140
-
141
- def test_notice_transaction_cpu_time_no_builder_does_not_crash
142
- @state.transaction_sample_builder = nil
143
- @sampler.notice_transaction_cpu_time(@state, 0.0)
144
- end
145
-
146
133
  def test_records_cpu_time_on_transaction_samples
147
134
  in_transaction do |txn|
148
135
  txn.stubs(:cpu_burn).returns(42)
149
136
  end
150
137
 
151
- assert_equal(42, @sampler.last_sample.params[:custom_params][:cpu_time])
138
+ assert_equal(42, attributes_for(@sampler.last_sample, :intrinsic)[:cpu_time])
152
139
  end
153
140
 
154
141
  def test_notice_extra_data_no_builder
@@ -156,43 +143,43 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
156
143
  assert_nil ret
157
144
  end
158
145
 
159
- def test_notice_extra_data_no_segment
146
+ def test_notice_extra_data_no_node
160
147
  mock_builder = mock('builder')
161
148
  @sampler.expects(:tl_builder).returns(mock_builder).once
162
- mock_builder.expects(:current_segment).returns(nil)
149
+ mock_builder.expects(:current_node).returns(nil)
163
150
  builder = @sampler.tl_builder
164
151
  @sampler.send(:notice_extra_data, builder, nil, nil, nil)
165
152
  end
166
153
 
167
- def test_notice_extra_data_with_segment_no_old_message_no_config_key
154
+ def test_notice_extra_data_with_node_no_old_message_no_config_key
168
155
  key = :a_key
169
156
  mock_builder = mock('builder')
170
- segment = mock('segment')
157
+ node = mock('node')
171
158
  @sampler.expects(:tl_builder).returns(mock_builder).once
172
- mock_builder.expects(:current_segment).returns(segment)
159
+ mock_builder.expects(:current_node).returns(node)
173
160
  NewRelic::Agent::TransactionSampler.expects(:truncate_message) \
174
161
  .with('a message').returns('truncated_message')
175
- segment.expects(:[]=).with(key, 'truncated_message')
176
- @sampler.expects(:append_backtrace).with(segment, 1.0)
162
+ node.expects(:[]=).with(key, 'truncated_message')
163
+ @sampler.expects(:append_backtrace).with(node, 1.0)
177
164
  builder = @sampler.tl_builder
178
165
  @sampler.send(:notice_extra_data, builder, 'a message', 1.0, key)
179
166
  end
180
167
 
181
168
  def test_append_backtrace_under_duration
182
169
  with_config(:'transaction_tracer.stack_trace_threshold' => 2.0) do
183
- segment = mock('segment')
184
- segment.expects(:[]=).with(:backtrace, any_parameters).never
185
- @sampler.append_backtrace(mock('segment'), 1.0)
170
+ node = mock('node')
171
+ node.expects(:[]=).with(:backtrace, any_parameters).never
172
+ @sampler.append_backtrace(mock('node'), 1.0)
186
173
  end
187
174
  end
188
175
 
189
176
  def test_append_backtrace_over_duration
190
177
  with_config(:'transaction_tracer.stack_trace_threshold' => 2.0) do
191
- segment = mock('segment')
178
+ node = mock('node')
192
179
  # note the mocha expectation matcher - you can't hardcode a
193
180
  # backtrace so we match on any string, which should be okay.
194
- segment.expects(:[]=).with(:backtrace, instance_of(String))
195
- @sampler.append_backtrace(segment, 2.5)
181
+ node.expects(:[]=).with(:backtrace, instance_of(String))
182
+ @sampler.append_backtrace(node, 2.5)
196
183
  end
197
184
  end
198
185
 
@@ -258,21 +245,15 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
258
245
  end
259
246
 
260
247
  def test_harvest_avoids_dups_from_harvested_samples
261
- sample = sample_with(:duration => 2.5, :force_persist => false)
248
+ sample = sample_with(:duration => 2.5)
262
249
  @sampler.store_sample(sample)
263
250
  @sampler.store_sample(sample)
264
251
 
265
252
  assert_equal([sample], @sampler.harvest!)
266
253
  end
267
254
 
268
- def test_merge_avoids_dups_from_forced
269
- sample = sample_with(:duration => 1, :force_persist => true)
270
- @sampler.merge!([sample, sample])
271
- assert_equal([sample], @sampler.harvest!)
272
- end
273
-
274
255
  def test_harvest_adding_slowest
275
- sample = sample_with(:duration => 2.5, :force_persist => false)
256
+ sample = sample_with(:duration => 2.5)
276
257
  @sampler.store_sample(sample)
277
258
 
278
259
  assert_equal([sample], @sampler.harvest!)
@@ -298,44 +279,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
298
279
  assert_equal([slower_sample], @sampler.harvest!)
299
280
  end
300
281
 
301
- def test_harvest_keep_force_persist_in_previous_results
302
- unforced_sample = sample_with(:duration => 10, :force_persist => false)
303
- forced_sample = sample_with(:duration => 1, :force_persist => true)
304
-
305
- @sampler.merge!([unforced_sample, forced_sample])
306
- result = @sampler.harvest!
307
-
308
- assert_includes(result, unforced_sample)
309
- assert_includes(result, forced_sample)
310
- end
311
-
312
- def test_harvest_keeps_force_persist_in_new_results
313
- forced_sample = sample_with(:duration => 1, :force_persist => true)
314
- @sampler.store_sample(forced_sample)
315
-
316
- unforced_sample = sample_with(:duration => 10, :force_persist => false)
317
- @sampler.store_sample(unforced_sample)
318
-
319
- result = @sampler.harvest!
320
-
321
- assert_includes(result, unforced_sample)
322
- assert_includes(result, forced_sample)
323
- end
324
-
325
- def test_harvest_keeps_forced_from_new_and_previous_results
326
- new_forced = sample_with(:duration => 1, :force_persist => true)
327
- @sampler.store_sample(new_forced)
328
-
329
- old_forced = sample_with(:duration => 1, :force_persist => true)
330
-
331
- @sampler.merge!([old_forced])
332
- result = @sampler.harvest!
333
-
334
- assert_includes(result, new_forced)
335
- assert_includes(result, old_forced)
336
- end
337
-
338
- FORCE_PERSIST_MAX = NewRelic::Agent::Transaction::ForcePersistSampleBuffer::CAPACITY
339
282
  SLOWEST_SAMPLE_MAX = NewRelic::Agent::Transaction::SlowestSampleBuffer::CAPACITY
340
283
  XRAY_SAMPLE_MAX = NewRelic::Agent.config[:'xray_session.max_samples']
341
284
 
@@ -343,9 +286,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
343
286
  slowest = sample_with(:duration => 10.0)
344
287
  previous = [slowest]
345
288
 
346
- forced_samples = generate_samples(100, :force_persist => true)
347
- previous.concat(forced_samples)
348
-
349
289
  xray_samples = generate_samples(100, :transaction_name => "Active/xray")
350
290
  previous.concat(xray_samples)
351
291
 
@@ -356,7 +296,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
356
296
  end
357
297
 
358
298
  expected = [slowest]
359
- expected = expected.concat(forced_samples.last(FORCE_PERSIST_MAX))
360
299
  expected = expected.concat(xray_samples.first(XRAY_SAMPLE_MAX))
361
300
 
362
301
  assert_equal_unordered(expected, result)
@@ -366,11 +305,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
366
305
  slowest = sample_with(:duration => 10.0)
367
306
  @sampler.store_sample(slowest)
368
307
 
369
- forced_samples = generate_samples(100, :force_persist => true)
370
- forced_samples.each do |forced|
371
- @sampler.store_sample(forced)
372
- end
373
-
374
308
  xray_samples = generate_samples(100, :transaction_name => "Active/xray")
375
309
  with_active_xray_session("Active/xray") do
376
310
  xray_samples.each do |xrayed|
@@ -381,7 +315,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
381
315
  result = @sampler.harvest!
382
316
 
383
317
  expected = [slowest]
384
- expected = expected.concat(forced_samples.last(FORCE_PERSIST_MAX))
385
318
  expected = expected.concat(xray_samples.first(XRAY_SAMPLE_MAX))
386
319
  assert_equal_unordered(expected, result)
387
320
  end
@@ -447,7 +380,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
447
380
 
448
381
  def test_sample_tree
449
382
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
450
- @sampler.on_start_transaction(@state, Time.now, nil)
383
+ @sampler.on_start_transaction(@state, Time.now)
451
384
  @sampler.notice_push_frame(@state)
452
385
 
453
386
  @sampler.notice_push_frame(@state)
@@ -472,7 +405,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
472
405
  MockGCStats.mock_values = [0,0,0,1,0,0,1,0,0,0,0,0,0,0,0]
473
406
 
474
407
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
475
- @sampler.on_start_transaction(@state, Time.now, nil)
408
+ @sampler.on_start_transaction(@state, Time.now)
476
409
  @sampler.notice_push_frame(@state)
477
410
 
478
411
  @sampler.notice_push_frame(@state)
@@ -556,7 +489,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
556
489
 
557
490
  def test_sample_with_parallel_paths
558
491
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
559
- @sampler.on_start_transaction(@state, Time.now, nil)
492
+ @sampler.on_start_transaction(@state, Time.now)
560
493
  @sampler.notice_push_frame(@state)
561
494
 
562
495
  assert_equal 1, @sampler.tl_builder.scope_depth
@@ -566,7 +499,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
566
499
 
567
500
  assert_nil @sampler.tl_builder
568
501
 
569
- @sampler.on_start_transaction(@state, Time.now, nil)
502
+ @sampler.on_start_transaction(@state, Time.now)
570
503
  @sampler.notice_push_frame(@state)
571
504
  @sampler.notice_pop_frame(@state, "a")
572
505
  @sampler.on_finishing_transaction(@state, @txn)
@@ -579,7 +512,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
579
512
 
580
513
  def test_double_traced_method_stack_empty
581
514
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
582
- @sampler.on_start_transaction(@state, Time.now, nil)
515
+ @sampler.on_start_transaction(@state, Time.now)
583
516
  @sampler.notice_push_frame(@state)
584
517
  @sampler.notice_pop_frame(@state, "a")
585
518
  @sampler.on_finishing_transaction(@state, @txn)
@@ -599,19 +532,19 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
599
532
 
600
533
  @sampler.notice_sql("test", {}, 0, @state)
601
534
 
602
- segment = @sampler.send(:tl_builder).current_segment
535
+ node = @sampler.send(:tl_builder).current_node
603
536
 
604
- assert_nil segment[:sql]
537
+ assert_nil node[:sql]
605
538
  end
606
539
 
607
540
  def test_stack_trace_sql
608
541
  with_config(:'transaction_tracer.stack_trace_threshold' => 0) do
609
542
  @sampler.on_start_transaction(@state, Time.now.to_f)
610
543
  @sampler.notice_sql("test", {}, 1, @state)
611
- segment = @sampler.send(:tl_builder).current_segment
544
+ node = @sampler.send(:tl_builder).current_node
612
545
 
613
- assert segment[:sql]
614
- assert segment[:backtrace]
546
+ assert node[:sql]
547
+ assert node[:backtrace]
615
548
  end
616
549
  end
617
550
 
@@ -619,10 +552,10 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
619
552
  with_config(:'transaction_tracer.stack_trace_threshold' => 2) do
620
553
  @sampler.on_start_transaction(@state, Time.now.to_f)
621
554
  @sampler.notice_sql("test", {}, 1, @state)
622
- segment = @sampler.send(:tl_builder).current_segment
555
+ node = @sampler.send(:tl_builder).current_node
623
556
 
624
- assert segment[:sql]
625
- assert_nil segment[:backtrace]
557
+ assert node[:sql]
558
+ assert_nil node[:backtrace]
626
559
  end
627
560
  end
628
561
 
@@ -637,14 +570,14 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
637
570
  len += sql.length
638
571
  end
639
572
 
640
- segment = @sampler.send(:tl_builder).current_segment
573
+ node = @sampler.send(:tl_builder).current_node
641
574
 
642
- sql = segment[:sql]
575
+ sql = node[:sql]
643
576
 
644
577
  assert sql.length <= 16384
645
578
  end
646
579
 
647
- def test_segment_obfuscated
580
+ def test_node_obfuscated
648
581
  @sampler.on_start_transaction(@state, Time.now.to_f)
649
582
  @sampler.notice_push_frame(@state)
650
583
 
@@ -652,29 +585,14 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
652
585
 
653
586
  @sampler.notice_sql(orig_sql, {}, 0, @state)
654
587
 
655
- segment = @sampler.send(:tl_builder).current_segment
588
+ node = @sampler.send(:tl_builder).current_node
656
589
 
657
- assert_equal orig_sql, segment[:sql]
658
- assert_equal "SELECT * from Jim where id=?", segment.obfuscated_sql
590
+ assert_equal orig_sql, node[:sql]
591
+ assert_equal "SELECT * from Jim where id=?", node.obfuscated_sql
659
592
  @sampler.notice_pop_frame(@state, "foo")
660
593
  end
661
594
 
662
- def test_param_capture
663
- [true, false].each do |capture|
664
- with_config(:capture_params => capture) do
665
- tt = with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
666
- @sampler.on_start_transaction(@state, Time.now, nil)
667
- @txn.filtered_params[:param] = 'hi'
668
- @sampler.on_finishing_transaction(@state, @txn)
669
- @sampler.harvest![0]
670
- end
671
-
672
- assert_equal (capture ? 1 : 0), tt.params[:request_params].length
673
- end
674
- end
675
- end
676
-
677
- def test_should_not_collect_segments_beyond_limit
595
+ def test_should_not_collect_nodes_beyond_limit
678
596
  with_config(:'transaction_tracer.limit_segments' => 3) do
679
597
  run_sample_trace do
680
598
  @sampler.notice_push_frame(@state)
@@ -684,27 +602,27 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
684
602
  @sampler.notice_pop_frame(@state, "a11")
685
603
  @sampler.notice_pop_frame(@state, "a1")
686
604
  end
687
- assert_equal 3, @sampler.last_sample.count_segments
605
+ assert_equal 3, @sampler.last_sample.count_nodes
688
606
 
689
607
  expected_sql = "SELECT * FROM sandwiches WHERE bread = 'challah'"
690
- deepest_segment = find_last_transaction_segment(@sampler.last_sample)
691
- assert_equal([], deepest_segment.called_segments)
692
- assert_equal(expected_sql, deepest_segment[:sql])
608
+ deepest_node = find_last_transaction_node(@sampler.last_sample)
609
+ assert_equal([], deepest_node.called_nodes)
610
+ assert_equal(expected_sql, deepest_node[:sql])
693
611
  end
694
612
  end
695
613
 
696
- def test_renaming_current_segment_midflight
614
+ def test_renaming_current_node_midflight
697
615
  @sampler.start_builder(@state)
698
- segment = @sampler.notice_push_frame(@state)
699
- segment.metric_name = 'External/www.google.com/Net::HTTP/GET'
616
+ node = @sampler.notice_push_frame(@state)
617
+ node.metric_name = 'External/www.google.com/Net::HTTP/GET'
700
618
  @sampler.notice_pop_frame(@state, 'External/www.google.com/Net::HTTP/GET')
701
619
  end
702
620
 
703
- def test_adding_segment_parameters
621
+ def test_adding_node_parameters
704
622
  @sampler.start_builder(@state)
705
623
  @sampler.notice_push_frame(@state)
706
- @sampler.add_segment_parameters(:transaction_guid => '97612F92E6194080')
707
- assert_equal '97612F92E6194080', @sampler.tl_builder.current_segment[:transaction_guid]
624
+ @sampler.add_node_parameters(:transaction_guid => '97612F92E6194080')
625
+ assert_equal '97612F92E6194080', @sampler.tl_builder.current_node[:transaction_guid]
708
626
  end
709
627
 
710
628
  def test_large_transaction_trace_harvest
@@ -720,7 +638,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
720
638
  assert_equal(1, samples.size)
721
639
 
722
640
  # Verify that the TT stopped recording after 100 nodes
723
- assert_equal(100, samples.first.count_segments)
641
+ assert_equal(100, samples.first.count_nodes)
724
642
  end
725
643
  end
726
644
 
@@ -749,35 +667,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
749
667
  assert_equal([samples[1]], prepared)
750
668
  end
751
669
 
752
- def test_custom_params_omitted_if_config_says_so
753
- config = {
754
- :'transaction_tracer.transaction_threshold' => 0.0,
755
- :'transaction_tracer.capture_attributes' => false
756
- }
757
- with_config(config) do
758
- in_transaction do
759
- NewRelic::Agent.add_custom_parameters(:foo => 'bar')
760
- end
761
- end
762
- sample = NewRelic::Agent.agent.transaction_sampler.harvest![0]
763
- custom_params = sample.params[:custom_params]
764
- assert_false(custom_params.keys.include?(:foo))
765
- end
766
-
767
- def test_custom_params_included_if_config_says_so
768
- config = {
769
- :'transaction_tracer.transaction_threshold' => 0.0,
770
- :'transaction_tracer.capture_attributes' => true
771
- }
772
- with_config(config) do
773
- in_transaction do
774
- NewRelic::Agent.add_custom_parameters(:foo => 'bar')
775
- end
776
- end
777
- custom_params = custom_params_from_last_sample
778
- assert_includes custom_params.keys, :foo
779
- end
780
-
781
670
  def test_custom_params_include_gc_time
782
671
  with_config(:'transaction_tracer.transaction_threshold' => 0.0) do
783
672
  in_transaction do
@@ -785,7 +674,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
785
674
  end
786
675
  end
787
676
 
788
- assert_equal 10.0, custom_params_from_last_sample[:gc_time]
677
+ assert_equal 10.0, intrinsic_attributes_from_last_sample[:gc_time]
789
678
  end
790
679
 
791
680
  def test_custom_params_include_tripid
@@ -800,7 +689,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
800
689
  end
801
690
  end
802
691
 
803
- assert_equal 'PDX-NRT', custom_params_from_last_sample[:'nr.trip_id']
692
+ assert_equal 'PDX-NRT', intrinsic_attributes_from_last_sample[:trip_id]
804
693
  end
805
694
 
806
695
  def test_custom_params_dont_include_tripid_if_not_cross_app_transaction
@@ -812,7 +701,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
812
701
  end
813
702
  end
814
703
 
815
- assert_nil custom_params_from_last_sample[:'nr.trip_id']
704
+ assert_nil intrinsic_attributes_from_last_sample[:trip_id]
816
705
  end
817
706
 
818
707
  def test_custom_params_include_path_hash
@@ -826,7 +715,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
826
715
  end
827
716
  end
828
717
 
829
- assert_equal path_hash, custom_params_from_last_sample[:'nr.path_hash']
718
+ assert_equal path_hash, intrinsic_attributes_from_last_sample[:path_hash]
830
719
  end
831
720
 
832
721
  def test_synthetics_parameters_not_included_if_not_valid_synthetics_request
@@ -839,11 +728,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
839
728
 
840
729
  sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
841
730
 
842
- custom_params = sample.params[:custom_params]
731
+ intrinsic_attributes = attributes_for(sample, :intrinsic)
843
732
  assert_nil sample.synthetics_resource_id
844
- assert_nil custom_params[:'nr.synthetics_resource_id']
845
- assert_nil custom_params[:'nr.synthetics_job_id']
846
- assert_nil custom_params[:'nr.synthetics_monitor_id']
733
+ assert_nil intrinsic_attributes[:synthetics_resource_id]
734
+ assert_nil intrinsic_attributes[:synthetics_job_id]
735
+ assert_nil intrinsic_attributes[:synthetics_monitor_id]
847
736
  end
848
737
 
849
738
  def test_synthetics_parameters_included
@@ -854,11 +743,11 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
854
743
 
855
744
  sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
856
745
 
857
- custom_params = sample.params[:custom_params]
746
+ intrinsic_attributes = attributes_for(sample, :intrinsic)
858
747
  assert_equal 100, sample.synthetics_resource_id
859
- assert_equal 100, custom_params[:'nr.synthetics_resource_id']
860
- assert_equal 200, custom_params[:'nr.synthetics_job_id']
861
- assert_equal 300, custom_params[:'nr.synthetics_monitor_id']
748
+ assert_equal 100, intrinsic_attributes[:synthetics_resource_id]
749
+ assert_equal 200, intrinsic_attributes[:synthetics_job_id]
750
+ assert_equal 300, intrinsic_attributes[:synthetics_monitor_id]
862
751
  end
863
752
 
864
753
  class Dummy
@@ -887,7 +776,6 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
887
776
 
888
777
  SAMPLE_DEFAULTS = {
889
778
  :threshold => 1.0,
890
- :force_persist => false,
891
779
  :transaction_name => nil
892
780
  }
893
781
 
@@ -895,9 +783,12 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
895
783
  opts = SAMPLE_DEFAULTS.dup
896
784
  opts.merge!(incoming_opts)
897
785
 
898
- sample = NewRelic::TransactionSample.new
786
+ attributes = NewRelic::Agent::Transaction::Attributes.new(NewRelic::Agent.instance.attribute_filter)
787
+ attributes.add_intrinsic_attribute(:synthetics_resource_id, opts[:synthetics_resource_id])
788
+
789
+ sample = NewRelic::Agent::Transaction::Trace.new(Time.now)
790
+ sample.attributes = attributes
899
791
  sample.threshold = opts[:threshold]
900
- sample.force_persist = opts[:force_persist]
901
792
  sample.transaction_name = opts[:transaction_name]
902
793
  sample.stubs(:duration).returns(opts[:duration])
903
794
  sample
@@ -927,7 +818,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
927
818
  end
928
819
 
929
820
  def run_long_sample_trace(n)
930
- @sampler.on_start_transaction(@state, Time.now, nil)
821
+ @sampler.on_start_transaction(@state, Time.now)
931
822
  n.times do |i|
932
823
  @sampler.notice_push_frame(@state)
933
824
  yield if block_given?
@@ -937,7 +828,7 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
937
828
  end
938
829
 
939
830
  def run_sample_trace(start = Time.now.to_f, stop = nil, state = @state)
940
- @sampler.on_start_transaction(state, start, nil)
831
+ @sampler.on_start_transaction(state, start)
941
832
  @sampler.notice_push_frame(state)
942
833
  @sampler.notice_sql("SELECT * FROM sandwiches WHERE bread = 'wheat'", {}, 0, state)
943
834
  @sampler.notice_push_frame(state)
@@ -951,8 +842,8 @@ class NewRelic::Agent::TransactionSamplerTest < Minitest::Test
951
842
  @sampler.on_finishing_transaction(state, @txn, (stop || Time.now.to_f))
952
843
  end
953
844
 
954
- def custom_params_from_last_sample
845
+ def intrinsic_attributes_from_last_sample
955
846
  sample = NewRelic::Agent.agent.transaction_sampler.harvest!.first
956
- sample.params[:custom_params]
847
+ attributes_for(sample, :intrinsic)
957
848
  end
958
849
  end