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
@@ -23,61 +23,73 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
23
23
  NewRelic::Agent::TransactionState.tl_clear_for_testing
24
24
  end
25
25
 
26
- def test_request_parsing__none
26
+ def test_request_parsing_none
27
27
  in_transaction do |txn|
28
- assert_nil txn.uri
28
+ assert_nil txn.request_path
29
29
  assert_nil txn.referer
30
30
  end
31
31
  end
32
32
 
33
- def test_request_parsing__path
34
- in_transaction do |txn|
35
- request = stub(:path => '/path?hello=bob#none')
36
- txn.request = request
37
- assert_equal "/path", txn.uri
33
+ # note: technically this shouldn't happen if the request we are dealing with is
34
+ # a Rack::Request (or subclass such as ActionDispatch::Request or the old
35
+ # ActionController::AbstractRequest)
36
+ def test_request_with_path_with_query_string
37
+ request = stub(:path => '/path?hello=bob#none')
38
+ in_transaction(:request => request) do |txn|
39
+ assert_equal "/path", txn.request_path
38
40
  end
39
41
  end
40
42
 
41
- def test_request_parsing__fullpath
42
- in_transaction do |txn|
43
- request = stub(:fullpath => '/path?hello=bob#none')
44
- txn.request = request
45
- assert_equal "/path", txn.uri
43
+ def test_request_parsing_referer
44
+ request = stub(:referer => 'https://www.yahoo.com:8080/path/hello?bob=none&foo=bar', :path => "/")
45
+ in_transaction(:request => request) do |txn|
46
+ assert_equal "https://www.yahoo.com:8080/path/hello", txn.referer
46
47
  end
47
48
  end
48
49
 
49
- def test_request_parsing__referer
50
- in_transaction do |txn|
51
- request = stub(:referer => 'https://www.yahoo.com:8080/path/hello?bob=none&foo=bar')
52
- txn.request = request
53
- assert_nil txn.uri
54
- assert_equal "https://www.yahoo.com:8080/path/hello", txn.referer
50
+ def test_strips_query_string_from_path_and_referer
51
+ request = stub(:path => '/path?hello=bob#none', :referer => '/path/hello?bob=none&foo=bar')
52
+ in_transaction(:request => request) do |txn|
53
+ assert_equal "/path", txn.request_path
54
+ assert_equal "/path/hello", txn.referer
55
55
  end
56
56
  end
57
57
 
58
- def test_request_parsing__uri
59
- in_transaction do |txn|
60
- request = stub(:uri => 'http://creature.com/path?hello=bob#none', :referer => '/path/hello?bob=none&foo=bar')
61
- txn.request = request
62
- assert_equal "/path", txn.uri
63
- assert_equal "/path/hello", txn.referer
58
+ def test_transaction_referer_nil_if_request_referer_nil
59
+ request = stub(:path => '/path?hello=bob#none', :referer => nil)
60
+ in_transaction(:request => request) do |txn|
61
+ assert_nil txn.referer
64
62
  end
65
63
  end
66
64
 
67
- def test_request_parsing__hostname_only
68
- in_transaction do |txn|
69
- request = stub(:uri => 'http://creature.com')
70
- txn.request = request
71
- assert_equal "/", txn.uri
65
+ def test_request_with_normal_path
66
+ request = stub(:path => '/blogs')
67
+ in_transaction(:request => request) do |txn|
68
+ assert_equal "/blogs", txn.request_path
72
69
  assert_nil txn.referer
73
70
  end
74
71
  end
75
72
 
76
- def test_request_parsing__slash
77
- in_transaction do |txn|
78
- request = stub(:uri => 'http://creature.com/')
79
- txn.request = request
80
- assert_equal "/", txn.uri
73
+ def test_request_with_empty_path
74
+ request = stub(:path => '')
75
+ in_transaction(:request => request) do |txn|
76
+ assert_equal "/", txn.request_path
77
+ assert_nil txn.referer
78
+ end
79
+ end
80
+
81
+ def test_request_to_root_path
82
+ request = stub(:path => '/')
83
+ in_transaction(:request => request) do |txn|
84
+ assert_equal "/", txn.request_path
85
+ assert_nil txn.referer
86
+ end
87
+ end
88
+
89
+ def test_request_with_empty_path_with_query_string
90
+ request = stub(:path => '?k=v')
91
+ in_transaction(:request => request) do |txn|
92
+ assert_equal "/", txn.request_path
81
93
  assert_nil txn.referer
82
94
  end
83
95
  end
@@ -331,7 +343,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
331
343
  end
332
344
  end
333
345
 
334
- def test_set_default_transaction_name_with_category_and_segment_name
346
+ def test_set_default_transaction_name_with_category_and_node_name
335
347
  in_transaction('foo', :category => :controller) do |txn|
336
348
  NewRelic::Agent::Transaction.set_default_transaction_name('bar', :grape, 'baz')
337
349
  assert_equal("Controller/Grape/bar", txn.best_name)
@@ -395,17 +407,17 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
395
407
  assert_equal 2.1, options['HttpDispatcher'].total_call_time
396
408
  end
397
409
 
398
- def test_end_fires_a_transaction_finished_event_with_custom_params
399
- options = nil
410
+ def test_end_fires_a_transaction_finished_event_with_attributes_attached
411
+ attributes = nil
412
+
400
413
  NewRelic::Agent.subscribe(:transaction_finished) do |payload|
401
- options = payload[:custom_params]
414
+ attributes = payload[:attributes]
402
415
  end
403
416
 
404
- in_web_transaction('Controller/foo/1/bar/22') do
405
- NewRelic::Agent.add_custom_parameters('fooz' => 'barz')
417
+ txn = in_web_transaction('Controller/foo/1/bar/22') do
406
418
  end
407
419
 
408
- assert_equal 'barz', options['fooz']
420
+ assert_equal txn.attributes, attributes
409
421
  end
410
422
 
411
423
  def test_end_fires_a_transaction_finished_event_with_transaction_guid
@@ -651,18 +663,19 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
651
663
  refute_includes keys, :synthetics_job_id
652
664
  refute_includes keys, :synthetics_monitor_id
653
665
  end
654
- def test_logs_warning_if_a_non_hash_arg_is_passed_to_add_custom_params
655
- expects_logging(:warn, includes("add_custom_parameters"))
666
+
667
+ def test_logs_warning_if_a_non_hash_arg_is_passed_to_add_custom_attributes
668
+ expects_logging(:warn, includes("add_custom_attributes"))
656
669
  in_transaction do
657
- NewRelic::Agent.add_custom_parameters('fooz')
670
+ NewRelic::Agent.add_custom_attributes('fooz')
658
671
  end
659
672
  end
660
673
 
661
- def test_ignores_custom_parameters_when_in_high_security
674
+ def test_ignores_custom_attributes_when_in_high_security
662
675
  with_config(:high_security => true) do
663
676
  in_transaction do |txn|
664
- NewRelic::Agent.add_custom_parameters(:failure => "is an option")
665
- assert_empty txn.custom_parameters
677
+ NewRelic::Agent.add_custom_attributes(:failure => "is an option")
678
+ assert_empty attributes_for(txn, :custom)
666
679
  end
667
680
  end
668
681
  end
@@ -670,16 +683,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
670
683
  def test_user_attributes_alias_to_custom_parameters
671
684
  in_transaction('user_attributes') do |txn|
672
685
  txn.set_user_attributes(:set_instance => :set_instance)
673
- txn.user_attributes[:indexer_instance] = :indexer_instance
674
-
675
- txn.set_user_attributes(:set_class => :set_class)
676
- txn.user_attributes[:indexer_class] = :indexer_class
677
-
678
- assert_has_custom_parameter(txn, :set_instance)
679
- assert_has_custom_parameter(txn, :indexer_instance)
680
-
681
- assert_has_custom_parameter(txn, :set_class)
682
- assert_has_custom_parameter(txn, :indexer_class)
686
+ assert_has_custom_attribute(txn, "set_instance")
683
687
  end
684
688
  end
685
689
 
@@ -690,6 +694,15 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
690
694
  end
691
695
  end
692
696
 
697
+ def test_notice_error_in_transaction_sends_attributes_along
698
+ txn = in_transaction('oops') do
699
+ NewRelic::Agent::Transaction.notice_error("wat?")
700
+ end
701
+
702
+ error = NewRelic::Agent.instance.error_collector.errors.first
703
+ assert_equal txn.attributes, error.attributes
704
+ end
705
+
693
706
  def test_notice_error_after_current_transaction_notifies_error_collector
694
707
  in_transaction('failing') do
695
708
  # no-op
@@ -704,6 +717,17 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
704
717
  assert_equal 1, NewRelic::Agent.instance.error_collector.errors.count
705
718
  end
706
719
 
720
+ def test_notice_error_sends_uri_and_referer_from_request
721
+ request = stub(:path => "/here")
722
+ in_transaction(:request => request) do |txn|
723
+ NewRelic::Agent::Transaction.notice_error("wat")
724
+ end
725
+
726
+ assert_equal 1, NewRelic::Agent.instance.error_collector.errors.count
727
+ error = NewRelic::Agent.instance.error_collector.errors.first
728
+ assert_equal "/here", error.request_uri
729
+ end
730
+
707
731
  def test_records_gc_time
708
732
  gc_start = mock('gc start')
709
733
  gc_end = mock('gc end')
@@ -715,7 +739,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
715
739
  end
716
740
 
717
741
  trace = txn.transaction_trace
718
- assert_equal(42, trace.params[:custom_params][:gc_time])
742
+ assert_equal(42, attributes_for(trace, :intrinsic)[:gc_time])
719
743
  end
720
744
 
721
745
  def test_freeze_name_and_execute_if_not_ignored_executes_given_block_if_not_ignored
@@ -744,29 +768,10 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
744
768
  end
745
769
  end
746
770
 
747
- def test_record_transaction_cpu_positive
748
- in_transaction do |txn|
749
- state = NewRelic::Agent::TransactionState.tl_get
750
- txn.expects(:cpu_burn).twice.returns(1.0)
751
- NewRelic::Agent.instance.transaction_sampler.expects(:notice_transaction_cpu_time).twice.with(state, 1.0)
752
- txn.record_transaction_cpu(state)
753
- end
754
- end
755
-
756
- def test_record_transaction_cpu_negative
757
- in_transaction do |txn|
758
- state = NewRelic::Agent::TransactionState.tl_get
759
- txn.expects(:cpu_burn).twice.returns(nil)
760
- # should not be called for the nil case
761
- NewRelic::Agent.instance.transaction_sampler.expects(:notice_transaction_cpu_time).never
762
- txn.record_transaction_cpu(state)
763
- end
764
- end
765
-
766
771
  def test_normal_cpu_burn_positive
767
772
  in_transaction do |txn|
768
773
  txn.instance_variable_set(:@process_cpu_start, 3)
769
- txn.expects(:process_cpu).twice.returns(4)
774
+ txn.stubs(:process_cpu).returns(4)
770
775
  assert_equal 1, txn.normal_cpu_burn
771
776
  end
772
777
  end
@@ -885,7 +890,7 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
885
890
 
886
891
  def test_cpu_burn_normal
887
892
  in_transaction do |txn|
888
- txn.expects(:normal_cpu_burn).twice.returns(1)
893
+ txn.stubs(:normal_cpu_burn).returns(1)
889
894
  txn.expects(:jruby_cpu_burn).never
890
895
  assert_equal 1, txn.cpu_burn
891
896
  end
@@ -893,8 +898,8 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
893
898
 
894
899
  def test_cpu_burn_jruby
895
900
  in_transaction do |txn|
896
- txn.expects(:normal_cpu_burn).twice.returns(nil)
897
- txn.expects(:jruby_cpu_burn).twice.returns(2)
901
+ txn.stubs(:normal_cpu_burn).returns(nil)
902
+ txn.stubs(:jruby_cpu_burn).returns(2)
898
903
  assert_equal 2, txn.cpu_burn
899
904
  end
900
905
  end
@@ -1071,71 +1076,25 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
1071
1076
  NewRelic::Agent::Transaction.stop(state)
1072
1077
  end
1073
1078
 
1074
- def test_user_defined_rules_ignore_returns_true_for_matched_uri
1079
+ def test_user_defined_rules_ignore_returns_true_for_matched_path
1075
1080
  rule = 'ignored'
1076
1081
  with_config(:rules => { :ignore_url_regexes => [rule] }) do
1077
1082
  in_transaction do |txn|
1078
- txn.stubs(:uri).returns(rule + '/uri')
1079
- assert txn.user_defined_rules_ignore?, "URIs should be ignored based on user defined rules. Rule: '#{rule}', URI: '#{txn.uri}'."
1083
+ txn.stubs(:request_path).returns(rule + '/path')
1084
+ assert txn.user_defined_rules_ignore?, "Paths should be ignored based on user defined rules. Rule: '#{rule}', Path: '#{txn.request_path}'."
1080
1085
  end
1081
1086
  end
1082
1087
  end
1083
1088
 
1084
- def test_stop_ignores_transactions_from_ignored_uris
1085
- with_config(:rules => { :ignore_url_regexes => ['ignored/uri'] }) do
1089
+ def test_stop_ignores_transactions_from_ignored_paths
1090
+ with_config(:rules => { :ignore_url_regexes => ['ignored/path'] }) do
1086
1091
  in_transaction do |txn|
1087
- txn.stubs(:uri).returns('ignored/uri')
1092
+ txn.stubs(:request_path).returns('ignored/path')
1088
1093
  txn.expects(:ignore!)
1089
1094
  end
1090
1095
  end
1091
1096
  end
1092
1097
 
1093
- def test_transactions_are_not_ignored_if_rules_match_http_auth
1094
- with_config(:rules => { :ignore_url_regexes => ['ignored'] }) do
1095
- in_transaction do |txn|
1096
- txn.stubs(:uri).returns('http://ignored_user:ignored_pass@foo.com/bar/baz')
1097
- txn.expects(:ignore!).never
1098
- end
1099
- end
1100
- end
1101
-
1102
- def test_transactions_are_not_ignored_if_rules_match_query_string
1103
- with_config(:rules => { :ignore_url_regexes => ['ignored'] }) do
1104
- in_transaction do |txn|
1105
- txn.stubs(:uri).returns('http://foo.com/bar/baz/?ignored=1')
1106
- txn.expects(:ignore!).never
1107
- end
1108
- end
1109
- end
1110
-
1111
- def test_user_defined_rules_ignore_does_not_parse_the_uri_if_rules_are_empty
1112
- with_config(:rules => { :ignore_url_regexes => [] }) do
1113
- in_transaction do |txn|
1114
- txn.stubs(:uri).returns('http://foo.com/bar/baz')
1115
- NewRelic::Agent::HTTPClients::URIUtil.expects(:parse_url).never
1116
- end
1117
- end
1118
- end
1119
-
1120
- def test_user_defined_rules_ignore_does_not_filter_the_uri_if_rules_are_empty
1121
- with_config(:rules => { :ignore_url_regexes => [] }) do
1122
- in_transaction do |txn|
1123
- txn.stubs(:uri).returns('http://foo.com/bar/baz')
1124
- NewRelic::Agent::HTTPClients::URIUtil.expects(:filter_uri).never
1125
- end
1126
- end
1127
- end
1128
-
1129
- def test_user_defined_rules_ignore_logs_uri_parsing_failures
1130
- with_config(:rules => { :ignore_url_regexes => ['notempty'] }) do
1131
- in_transaction do |txn|
1132
- txn.stubs(:uri).returns('http://foo bar.com')
1133
- NewRelic::Agent.logger.expects(:debug)
1134
- NewRelic::Agent.logger.expects(:debug).with(regexp_matches(/foo bar.com/), anything).at_least_once
1135
- end
1136
- end
1137
- end
1138
-
1139
1098
  def test_user_defined_rules_ignore_returns_false_if_cannot_parse_uri
1140
1099
  with_config(:rules => { :ignore_url_regexes => ['notempty'] }) do
1141
1100
  in_transaction do |txn|
@@ -1233,8 +1192,8 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
1233
1192
  end
1234
1193
  end
1235
1194
 
1236
- def assert_has_custom_parameter(txn, key, value = key)
1237
- assert_equal(value, txn.custom_parameters[key])
1195
+ def assert_has_custom_attribute(txn, key, value = key)
1196
+ assert_equal(value, attributes_for(txn, :custom)[key])
1238
1197
  end
1239
1198
 
1240
1199
  def test_wrap_transaction
@@ -1284,4 +1243,193 @@ class NewRelic::Agent::TransactionTest < Minitest::Test
1284
1243
  assert_equal(42, txn.instrumentation_state[:a])
1285
1244
  end
1286
1245
  end
1246
+
1247
+ def test_adding_custom_attributes
1248
+ with_config(:'transaction_tracer.attributes.enabled' => true) do
1249
+ in_transaction do |txn|
1250
+ NewRelic::Agent.add_custom_attributes(:foo => "bar")
1251
+ actual = txn.attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1252
+ assert_equal({"foo" => "bar"}, actual)
1253
+ end
1254
+ end
1255
+ end
1256
+
1257
+ def test_adding_agent_attributes
1258
+ with_config(:'transaction_tracer.attributes.enabled' => true) do
1259
+ in_transaction do |txn|
1260
+ txn.add_agent_attribute(:foo, "bar", NewRelic::Agent::AttributeFilter::DST_ALL)
1261
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1262
+ assert_equal({:foo => "bar"}, actual)
1263
+ end
1264
+ end
1265
+ end
1266
+
1267
+ def test_adding_agent_attributes_via_class
1268
+ with_config(:'transaction_tracer.attributes.enabled' => true) do
1269
+ in_transaction do |txn|
1270
+ NewRelic::Agent::Transaction.add_agent_attribute(:foo, "bar", NewRelic::Agent::AttributeFilter::DST_ALL)
1271
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1272
+ assert_equal({:foo => "bar"}, actual)
1273
+ end
1274
+ end
1275
+ end
1276
+
1277
+ def test_adding_agent_attributes_via_class_outside_of_txn_is_safe
1278
+ expects_logging(:debug, includes("foo"))
1279
+ NewRelic::Agent::Transaction.add_agent_attribute(:foo, "bar", NewRelic::Agent::AttributeFilter::DST_ALL)
1280
+ end
1281
+
1282
+ def test_adding_intrinsic_attributes
1283
+ in_transaction do |txn|
1284
+ txn.attributes.add_intrinsic_attribute(:foo, "bar")
1285
+
1286
+ actual = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1287
+ assert_equal({:foo => "bar"}, actual)
1288
+ end
1289
+ end
1290
+
1291
+ def test_assigns_synthetics_to_intrinsic_attributes
1292
+ txn = in_transaction do |txn|
1293
+ txn.raw_synthetics_header = ""
1294
+ txn.synthetics_payload = [1, 1, 100, 200, 300]
1295
+ txn
1296
+ end
1297
+
1298
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1299
+ assert_equal 100, result[:synthetics_resource_id]
1300
+ assert_equal 200, result[:synthetics_job_id]
1301
+ assert_equal 300, result[:synthetics_monitor_id]
1302
+ end
1303
+
1304
+
1305
+ def test_intrinsic_attributes_include_gc_time
1306
+ txn = in_transaction do |txn|
1307
+ NewRelic::Agent::StatsEngine::GCProfiler.stubs(:record_delta).returns(10.0)
1308
+ end
1309
+
1310
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1311
+ assert_equal 10.0, result[:gc_time]
1312
+ end
1313
+
1314
+ def test_intrinsic_attributes_include_tripid
1315
+ guid = nil
1316
+
1317
+ NewRelic::Agent.instance.cross_app_monitor.stubs(:client_referring_transaction_trip_id).returns('PDX-NRT')
1318
+
1319
+ txn = in_transaction do |txn|
1320
+ NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = true
1321
+ guid = txn.guid
1322
+ end
1323
+
1324
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1325
+ assert_equal 'PDX-NRT', result[:trip_id]
1326
+ end
1327
+
1328
+ def test_intrinsic_attributes_dont_include_tripid_if_not_cross_app_transaction
1329
+ NewRelic::Agent.instance.cross_app_monitor.stubs(:client_referring_transaction_trip_id).returns('PDX-NRT')
1330
+
1331
+ txn = in_transaction do
1332
+ NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = false
1333
+ end
1334
+
1335
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1336
+ assert_nil result[:trip_id]
1337
+ end
1338
+
1339
+ def test_intrinsic_attributes_include_path_hash
1340
+ path_hash = nil
1341
+
1342
+ txn = in_transaction do |txn|
1343
+ state = NewRelic::Agent::TransactionState.tl_get
1344
+ state.is_cross_app_caller = true
1345
+ path_hash = txn.cat_path_hash(state)
1346
+ end
1347
+
1348
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1349
+ assert_equal path_hash, result[:path_hash]
1350
+ end
1351
+
1352
+ def test_synthetics_attributes_not_included_if_not_valid_synthetics_request
1353
+ txn = in_transaction do |txn|
1354
+ txn.raw_synthetics_header = nil
1355
+ txn.synthetics_payload = nil
1356
+ end
1357
+
1358
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1359
+ assert_nil result[:synthetics_resource_id]
1360
+ assert_nil result[:synthetics_job_id]
1361
+ assert_nil result[:synthetics_monitor_id]
1362
+ end
1363
+
1364
+ def test_intrinsic_attributes_include_cpu_time
1365
+ txn = in_transaction do |txn|
1366
+ txn.stubs(:cpu_burn).returns(22.0)
1367
+ end
1368
+
1369
+ result = txn.attributes.intrinsic_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1370
+ assert_equal 22.0, result[:cpu_time]
1371
+ end
1372
+
1373
+ def test_request_params_included_in_agent_attributes
1374
+ txn = with_config(:capture_params => true) do
1375
+ in_transaction(:filtered_params => {:foo => "bar"}) do
1376
+ end
1377
+ end
1378
+
1379
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1380
+ assert_equal "bar", actual['request.parameters.foo']
1381
+ end
1382
+
1383
+ def test_request_params_included_in_agent_attributes_in_nested_txn
1384
+ txn = with_config(:capture_params => true) do
1385
+ in_transaction(:filtered_params => {:foo => "bar", :bar => "baz"}) do
1386
+ in_transaction(:filtered_params => {:bar => "qux"}) do
1387
+ end
1388
+ end
1389
+ end
1390
+
1391
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1392
+ assert_equal "bar", actual['request.parameters.foo']
1393
+ assert_equal "qux", actual['request.parameters.bar']
1394
+ end
1395
+
1396
+ def test_request_params_get_key_length_limits
1397
+ key = "x" * 1000
1398
+ expects_logging(:debug, includes(key))
1399
+
1400
+ txn = with_config(:capture_params => true) do
1401
+ in_transaction(:filtered_params => {key => "bar"}) do
1402
+ end
1403
+ end
1404
+
1405
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1406
+ assert_empty actual
1407
+ end
1408
+
1409
+ def test_http_response_code_included_in_agent_attributes
1410
+ txn = in_transaction do |txn|
1411
+ txn.http_response_code = 418
1412
+ end
1413
+
1414
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1415
+ assert_equal 418, actual[:'httpResponseCode']
1416
+ end
1417
+
1418
+ def test_referer_in_agent_attributes
1419
+ request = stub('request', :referer => "/referered", :path => "/")
1420
+ txn = in_transaction(:request => request) do |txn|
1421
+ end
1422
+
1423
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_ERROR_COLLECTOR)
1424
+ assert_equal "/referered", actual[:'request.headers.referer']
1425
+ end
1426
+
1427
+ def test_referer_omitted_if_not_on_request
1428
+ request = stub('request', :path => "/")
1429
+ txn = in_transaction(:request => request) do |txn|
1430
+ end
1431
+
1432
+ actual = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_TRANSACTION_TRACER)
1433
+ refute_includes actual, :'request.headers.referer'
1434
+ end
1287
1435
  end