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
@@ -60,9 +60,9 @@ class ExconTest < Minitest::Test
60
60
  end
61
61
 
62
62
  tt = NewRelic::Agent.agent.transaction_sampler.last_sample
63
- segment = tt.root_segment.called_segments.first.called_segments.first
64
- assert_equal("External/localhost/Excon/GET", segment.metric_name)
65
- assert_equal(target_url, segment.params[:uri])
63
+ node = tt.root_node.called_nodes.first.called_nodes.first
64
+ assert_equal("External/localhost/Excon/GET", node.metric_name)
65
+ assert_equal(target_url, node.params[:uri])
66
66
  end
67
67
 
68
68
  def test_still_records_tt_node_when_request_expects_different_response_code
@@ -74,8 +74,8 @@ class ExconTest < Minitest::Test
74
74
  # meh
75
75
  end
76
76
 
77
- last_segment = find_last_transaction_segment()
78
- assert_equal("External/localhost/Excon/GET", last_segment.metric_name)
77
+ last_node = find_last_transaction_node()
78
+ assert_equal("External/localhost/Excon/GET", last_node.metric_name)
79
79
  end
80
80
  end
81
81
  end
@@ -10,6 +10,7 @@ development:
10
10
  app_name: test
11
11
  host: 127.0.0.1
12
12
  api_host: 127.0.0.1
13
+ port: <%= $collector && $collector.port %>
13
14
  transaction_tracer:
14
15
  record_sql: obfuscated
15
16
  enabled: true
@@ -59,7 +59,7 @@ class GrapeTest < Minitest::Test
59
59
 
60
60
  def test_transaction_renaming
61
61
  get '/grape_ape/renamed'
62
- # The second segment here is 'Rack' because of an idiosyncrasy of
62
+ # The second node here is 'Rack' because of an idiosyncrasy of
63
63
  # the set_transaction_name API: when you call set_transaction_name and
64
64
  # don't provide an explicit category, you lock in the category prefix
65
65
  # that was in use at the time you made the call.
@@ -69,34 +69,71 @@ class GrapeTest < Minitest::Test
69
69
  # truly separate entities.
70
70
  #
71
71
  assert_grape_metrics('Controller/Rack/RenamedTxn')
72
- #assert_metrics_recorded(['Controller/Rack/RenamedTxn'])
73
72
  end
74
73
 
75
74
  def test_params_are_not_captured_with_capture_params_disabled
76
75
  with_config(:capture_params => false) do
77
76
  get '/grape_ape/10'
78
- assert_equal({}, last_transaction_trace_request_params)
77
+
78
+ expected = {}
79
+ assert_equal expected, last_transaction_trace_request_params
79
80
  end
80
81
  end
81
82
 
82
83
  def test_route_params_are_captured
83
84
  with_config(:capture_params => true) do
84
85
  get '/grape_ape/10'
85
- assert_equal({"id" => "10"}, last_transaction_trace_request_params)
86
+
87
+ expected = {
88
+ "request.parameters.id" => "10"
89
+ }
90
+ assert_equal expected, last_transaction_trace_request_params
86
91
  end
87
92
  end
88
93
 
89
94
  def test_query_params_are_captured
90
95
  with_config(:capture_params => true) do
91
96
  get '/grape_ape?q=1234&foo=bar'
92
- assert_equal({'q' => '1234', 'foo' => 'bar'}, last_transaction_trace_request_params)
97
+
98
+ expected = {
99
+ 'request.parameters.q' => '1234',
100
+ 'request.parameters.foo' => 'bar'
101
+ }
102
+ assert_equal expected, last_transaction_trace_request_params
93
103
  end
94
104
  end
95
105
 
96
106
  def test_post_body_params_are_captured
97
107
  with_config(:capture_params => true) do
98
108
  post '/grape_ape', {'q' => '1234', 'foo' => 'bar'}.to_json, "CONTENT_TYPE" => "application/json"
99
- assert_equal({'q' => '1234', 'foo' => 'bar'}, last_transaction_trace_request_params)
109
+
110
+ expected = {
111
+ 'request.parameters.q' => '1234',
112
+ 'request.parameters.foo' => 'bar'
113
+ }
114
+ assert_equal expected, last_transaction_trace_request_params
115
+ end
116
+ end
117
+
118
+ def test_post_body_params_are_captured_with_error
119
+ with_config(:capture_params => true) do
120
+ assert_raises(GrapeTestApiError) do
121
+ post '/grape_ape_fail', {'q' => '1234', 'foo' => 'fail'}.to_json, "CONTENT_TYPE" => "application/json"
122
+ end
123
+
124
+ agent_attributes = attributes_for(last_traced_error, :agent)
125
+ assert_equal('1234', agent_attributes['request.parameters.q'])
126
+ assert_equal('fail', agent_attributes['request.parameters.foo'])
127
+ end
128
+ end
129
+
130
+ def test_post_body_params_are_captured_with_rescue_from
131
+ with_config(:capture_params => true) do
132
+ post '/grape_ape_fail_rescue', {'q' => '1234', 'foo' => 'fail'}.to_json, "CONTENT_TYPE" => "application/json"
133
+
134
+ agent_attributes = attributes_for(last_traced_error, :agent)
135
+ assert_equal('1234', agent_attributes['request.parameters.q'])
136
+ assert_equal('fail', agent_attributes['request.parameters.foo'])
100
137
  end
101
138
  end
102
139
 
@@ -104,7 +141,12 @@ class GrapeTest < Minitest::Test
104
141
  with_config(:capture_params => true) do
105
142
  params = {"ape" => {"first_name" => "koko", "last_name" => "gorilla"}}
106
143
  post '/grape_ape', params.to_json, "CONTENT_TYPE" => "application/json"
107
- assert_equal(params, last_transaction_trace_request_params)
144
+
145
+ expected = {
146
+ "request.parameters.ape.first_name" => "koko",
147
+ "request.parameters.ape.last_name" => "gorilla"
148
+ }
149
+ assert_equal expected, last_transaction_trace_request_params
108
150
  end
109
151
  end
110
152
 
@@ -115,22 +157,44 @@ class GrapeTest < Minitest::Test
115
157
  :file => Rack::Test::UploadedFile.new(__FILE__, 'text/plain')
116
158
  }
117
159
  post '/grape_ape', params
118
- assert_equal({"title" => "blah", "file" => "[FILE]"}, last_transaction_trace_request_params)
160
+
161
+ expected = {
162
+ "request.parameters.title" => "blah",
163
+ "request.parameters.file" => "[FILE]"
164
+ }
165
+ assert_equal expected, last_transaction_trace_request_params
119
166
  end
120
167
  end
121
168
 
122
169
  def test_404_with_params_does_not_capture_them
123
170
  with_config(:capture_params => true) do
124
171
  post '/grape_catfish', {"foo" => "bar"}
125
- assert_equal({}, last_transaction_trace_request_params)
172
+ expected = {}
173
+ assert_equal expected, last_transaction_trace_request_params
174
+ end
175
+ end
176
+
177
+ def test_params_are_captured_on_transaction_events
178
+ with_config(:'attributes.include' => 'request.parameters.*') do
179
+ json = {
180
+ :foo => "bar",
181
+ :bar => "baz"
182
+ }.to_json
183
+
184
+ post '/grape_ape', json, {"CONTENT_TYPE" => "application/json"}
185
+
186
+ expected = {"request.parameters.foo" => "bar", "request.parameters.bar" => "baz"}
187
+ actual = agent_attributes_for_single_event_posted_without_ignored_attributes
188
+
189
+ assert_equal(expected, actual)
126
190
  end
127
191
  end
128
192
 
129
193
  def assert_grape_metrics(expected_txn_name)
130
- expected_segment_name = 'Middleware/Grape/GrapeTestApi/call'
194
+ expected_node_name = 'Middleware/Grape/GrapeTestApi/call'
131
195
  assert_metrics_recorded([
132
- expected_segment_name,
133
- [expected_segment_name, expected_txn_name],
196
+ expected_node_name,
197
+ [expected_node_name, expected_txn_name],
134
198
  expected_txn_name
135
199
  ])
136
200
  end
@@ -45,4 +45,20 @@ class GrapeTestApi < Grape::API
45
45
  'Destroy grape ape!'
46
46
  end
47
47
  end
48
+
49
+ resource :grape_ape_fail do
50
+ post do
51
+ raise GrapeTestApiError.new("I'm sorry Dave, I'm afraid I can't do that.")
52
+ end
53
+ end
54
+
55
+ resource :grape_ape_fail_rescue do
56
+ rescue_from :all do |e|
57
+ error_response({ message: "rescued from #{e.class.name}" })
58
+ end
59
+
60
+ post do
61
+ raise GrapeTestApiError.new("I'm sorry Dave, I'm afraid I can't do that.")
62
+ end
63
+ end
48
64
  end
@@ -5,16 +5,56 @@ development:
5
5
  # Settings known to be overridden by high security, purposefully set wrong
6
6
  # in local configuration for testing purposes!
7
7
  ssl: false
8
+ capture_params: true
9
+
10
+ attributes:
11
+ enabled: true
12
+ include:
13
+ - "*"
14
+ - "request.parameters.*"
15
+
8
16
  transaction_tracer:
9
17
  record_sql: raw
10
18
  enabled: true
11
19
  stack_trace_threshold: 0.5
12
- slow_sql:
13
- record_sql: obfuscated
14
- capture_params: true
20
+
21
+ capture_attributes: true,
22
+ attributes:
23
+ enabled: true,
24
+ include:
25
+ - "*"
26
+ - "request.parameters.*"
15
27
 
16
28
  error_collector:
17
29
  enabled: true
30
+ capture_attributes: true,
31
+ attributes:
32
+ enabled: true,
33
+ include:
34
+ - "*"
35
+ - "request.parameters.*"
36
+
37
+ analytics_events:
38
+ capture_attributes: true
39
+
40
+ transaction_events:
41
+ attributes:
42
+ enabled: true
43
+ include:
44
+ - "*"
45
+ - "request.parameters.*"
46
+
47
+ browser_monitoring:
48
+ capture_attributes: true
49
+ attributes:
50
+ enabled: true
51
+ include:
52
+ - "*"
53
+ - "request.parameters.*"
54
+
55
+ slow_sql:
56
+ record_sql: obfuscated
57
+
18
58
  apdex_t: 0.24
19
59
  monitor_mode: true
20
60
  license_key: bootstrap_newrelic_admin_license_key_000
@@ -17,7 +17,32 @@ class HighSecurityTest < Minitest::Test
17
17
  collector.stub('connect', {
18
18
  "agent_run_id" => 1,
19
19
  "agent_config" => {
20
+ # Make sure that we take TT's all the time for testing purposes
21
+ "transaction_tracer.transaction_threshold" => -10,
22
+
23
+ # Really, really try to get us to allow things that we shouldn't when
24
+ # in high security mode
20
25
  "capture_params" => true,
26
+
27
+ "transaction_tracer.capture_attributes" => true,
28
+ "error_collector.capture_attributes" => true,
29
+ "browser_monitoring.capture_attributes" => true,
30
+ "analytics_events.capture_attributes" => true,
31
+
32
+ "attributes.enabled" => true,
33
+ "attributes.include" => ["*", "request.parameters.*"],
34
+
35
+ "transaction_tracer.attributes.enabled" => true,
36
+ "transaction_tracer.attributes.include" => ["*", "request.parameters.*"],
37
+
38
+ "transaction_events.attributes.enabled" => true,
39
+ "transaction_events.attributes.include" => ["*", "request.parameters.*"],
40
+
41
+ "error_collector.attributes.enabled" => true,
42
+ "error_collector.attributes.include" => ["*", "request.parameters.*"],
43
+
44
+ "browser_monitoring.attributes.enabled" => true,
45
+ "browser_monitoring.attributes.include" => ["*", "request.parameters.*"],
21
46
  }
22
47
  }, 200)
23
48
  end
@@ -37,22 +62,153 @@ class HighSecurityTest < Minitest::Test
37
62
  refute NewRelic::Agent.config[:capture_params]
38
63
  end
39
64
 
40
- def test_doesnt_capture_params
65
+ def test_doesnt_capture_params_to_transaction_traces
41
66
  in_transaction(:filtered_params => { "loose" => "params" }) do
42
- # no-op
43
67
  end
44
- assert_empty last_transaction_trace_request_params
68
+
69
+ run_harvest
70
+
71
+ trace = single_transaction_trace_posted
72
+ assert_empty trace.custom_attributes
73
+ assert_empty trace.agent_attributes
45
74
  end
46
75
 
47
- def test_doesnt_record_custom_parameters
76
+ def test_doesnt_capture_params_to_errors
77
+ assert_raises(RuntimeError) do
78
+ in_transaction(:filtered_params => { "loose" => "params" }) do
79
+ raise "O_o"
80
+ end
81
+ end
82
+
83
+ run_harvest
84
+
85
+ error = single_error_posted
86
+ assert_empty error.agent_attributes
87
+ assert_empty error.custom_attributes
88
+ end
89
+
90
+ def test_doesnt_capture_params_to_events
91
+ in_transaction(:filtered_params => { "loose" => "params" }) do
92
+ end
93
+
94
+ run_harvest
95
+
96
+ event = single_event_posted
97
+ assert_empty event[1]
98
+ assert_empty event[2]
99
+ end
100
+
101
+ def test_doesnt_capture_params_to_browser
102
+ in_transaction(:filtered_params => { "loose" => "params" }) do
103
+ capture_js_data
104
+ end
105
+
106
+ run_harvest
107
+
108
+ refute_browser_monitoring_has_any_attributes
109
+ end
110
+
111
+ def test_disallows_custom_attributes_to_transaction_traces
112
+ in_transaction do
113
+ NewRelic::Agent.add_custom_attributes(:not => "allowed")
114
+ end
115
+
116
+ run_harvest
117
+
118
+ trace = single_transaction_trace_posted
119
+ assert_empty trace.custom_attributes
120
+ assert_empty trace.agent_attributes
121
+ end
122
+
123
+ def test_disallows_custom_attributes_on_errors
124
+ assert_raises(RuntimeError) do
125
+ in_transaction do
126
+ NewRelic::Agent.add_custom_attributes(:not => "allowed")
127
+ raise "O_o"
128
+ end
129
+ end
130
+
131
+ run_harvest
132
+
133
+ error = single_error_posted
134
+ assert_empty error.agent_attributes
135
+ assert_empty error.custom_attributes
136
+ end
137
+
138
+ def test_disallows_custom_attributes_on_events
139
+ in_transaction do
140
+ NewRelic::Agent.add_custom_attributes(:not => "allowed")
141
+ end
142
+
143
+ run_harvest
144
+
145
+ event = single_event_posted
146
+ assert_empty event[1]
147
+ assert_empty event[2]
148
+ end
149
+
150
+ def test_disallows_custom_attributes_on_browser
151
+ in_transaction do
152
+ NewRelic::Agent.add_custom_attributes(:not => "allowed")
153
+ capture_js_data
154
+ end
155
+
156
+ run_harvest
157
+
158
+ refute_browser_monitoring_has_any_attributes
159
+ end
160
+
161
+ def test_doesnt_block_agent_attributes_to_transaction_traces
162
+ in_transaction do |txn|
163
+ txn.http_response_code = 200
164
+ end
165
+
166
+ run_harvest
167
+
168
+ expected = { "httpResponseCode" => 200 }
169
+ assert_equal expected, single_transaction_trace_posted.agent_attributes
170
+ end
171
+
172
+ def test_doesnt_block_agent_attributes_to_errors
173
+ assert_raises(RuntimeError) do
174
+ in_transaction do |txn|
175
+ txn.http_response_code = 500
176
+ raise "O_o"
177
+ end
178
+ end
179
+
180
+ run_harvest
181
+
182
+ expected = { "httpResponseCode" => 500 }
183
+ assert_equal expected, single_error_posted.agent_attributes
184
+ end
185
+
186
+ def test_doesnt_block_intrinsic_attributes_on_transaction_traces
48
187
  in_transaction do
49
188
  NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = true
50
- NewRelic::Agent.add_custom_parameters(:not => "allowed")
51
189
  end
52
190
 
53
- assert_nil last_transaction_trace.params[:custom_params][:not]
54
- refute_nil last_transaction_trace.params[:custom_params][:cpu_time]
55
- refute_nil last_transaction_trace.params[:custom_params][:'nr.trip_id']
56
- refute_nil last_transaction_trace.params[:custom_params][:'nr.path_hash']
191
+ run_harvest
192
+
193
+ intrinsic_attributes = single_transaction_trace_posted.intrinsic_attributes
194
+ refute_nil intrinsic_attributes['cpu_time']
195
+ refute_nil intrinsic_attributes['trip_id']
196
+ refute_nil intrinsic_attributes['path_hash']
197
+ end
198
+
199
+ def test_doesnt_block_intrinsic_attributes_on_errors
200
+ assert_raises(RuntimeError) do
201
+ in_transaction do
202
+ NewRelic::Agent::TransactionState.tl_get.is_cross_app_caller = true
203
+ raise "O_o"
204
+ end
205
+ end
206
+
207
+ run_harvest
208
+
209
+ intrinsic_attributes = single_error_posted.intrinsic_attributes
210
+ refute_nil intrinsic_attributes['cpu_time']
211
+ refute_nil intrinsic_attributes['trip_id']
212
+ refute_nil intrinsic_attributes['path_hash']
57
213
  end
58
214
  end