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
@@ -29,22 +29,24 @@ module NewRelic
29
29
  class ExconHTTPRequest
30
30
  def initialize(datum)
31
31
  @datum = datum
32
- end
33
32
 
34
- def type
35
- "Excon"
36
- end
33
+ @method = @datum[:method].to_s.upcase
34
+ @scheme = @datum[:scheme]
35
+ @port = @datum[:port]
36
+ @path = @datum[:path]
37
37
 
38
- def host
39
- if hostname = (self['host'] || self['Host'])
40
- hostname.split(':').first
38
+ headers = @datum[:headers]
39
+ if hostname = (headers['host'] || headers['Host'])
40
+ @host = hostname.split(':').first
41
41
  else
42
- @datum[:host]
42
+ @host = @datum[:host]
43
43
  end
44
44
  end
45
45
 
46
- def method
47
- @datum[:method].to_s.upcase
46
+ attr_reader :host, :method
47
+
48
+ def type
49
+ "Excon"
48
50
  end
49
51
 
50
52
  def [](key)
@@ -57,7 +59,7 @@ module NewRelic
57
59
  end
58
60
 
59
61
  def uri
60
- URI.parse("#{@datum[:scheme]}://#{@datum[:host]}:#{@datum[:port]}#{@datum[:path]}")
62
+ URI.parse("#{@scheme}://#{@host}:#{@port}#{@path}")
61
63
  end
62
64
  end
63
65
  end
@@ -36,6 +36,15 @@ module NewRelic
36
36
  end
37
37
  end
38
38
 
39
+ QUESTION_MARK = "?".freeze
40
+
41
+ def self.strip_query_string(fragment)
42
+ if(fragment.include?(QUESTION_MARK))
43
+ fragment.split(QUESTION_MARK).first
44
+ else
45
+ fragment
46
+ end
47
+ end
39
48
  end
40
49
  end
41
50
  end
@@ -58,9 +58,7 @@ module NewRelic
58
58
  end
59
59
 
60
60
  def filter(params)
61
- munged_params = params.dup
62
- munged_params.delete('controller')
63
- munged_params.delete('action')
61
+ munged_params = NewRelic::Agent::ParameterFiltering.filter_rails_request_parameters(params)
64
62
  filters = Rails.application.config.filter_parameters
65
63
  ActionDispatch::Http::ParameterFilter.new(filters).filter(munged_params)
66
64
  end
@@ -4,7 +4,7 @@
4
4
  require 'new_relic/agent/instrumentation/evented_subscriber'
5
5
 
6
6
  # Listen for ActiveSupport::Notifications events for ActionView render
7
- # events. Write metric data and transaction trace segments for each event.
7
+ # events. Write metric data and transaction trace nodes for each event.
8
8
  module NewRelic
9
9
  module Agent
10
10
  module Instrumentation
@@ -27,7 +27,7 @@ module NewRelic
27
27
 
28
28
  # @deprecated
29
29
  def rollup_metrics_for(*_)
30
- NewRelic::Agent::Deprecator.deprecate("#{self.class}.rollup_metrics_for",
30
+ NewRelic::Agent::Deprecator.deprecate("ActiveRecordHelper.rollup_metrics_for",
31
31
  "NewRelic::Agent::Datastores::MetricHelper.metrics_for")
32
32
 
33
33
  rollup_metric = if NewRelic::Agent::Transaction.recording_web_transaction?
@@ -5,7 +5,7 @@ require 'new_relic/agent/instrumentation/active_record_helper'
5
5
  require 'new_relic/agent/instrumentation/evented_subscriber'
6
6
 
7
7
  # Listen for ActiveSupport::Notifications events for ActiveRecord query
8
- # events. Write metric data, transaction trace segments and slow sql
8
+ # events. Write metric data, transaction trace nodes and slow sql
9
9
  # nodes for each event.
10
10
  module NewRelic
11
11
  module Agent
@@ -13,6 +13,13 @@ module NewRelic
13
13
  class ActiveRecordSubscriber < EventedSubscriber
14
14
  CACHED_QUERY_NAME = 'CACHE'.freeze unless defined? CACHED_QUERY_NAME
15
15
 
16
+ def initialize
17
+ # We cache this in an instance variable to avoid re-calling method
18
+ # on each query.
19
+ @explainer = method(:get_explain_plan)
20
+ super
21
+ end
22
+
16
23
  def start(name, id, payload) #THREAD_LOCAL_ACCESS
17
24
  return if payload[:name] == CACHED_QUERY_NAME
18
25
  return unless NewRelic::Agent.tl_is_execution_traced?
@@ -46,20 +53,20 @@ module NewRelic
46
53
  def notice_sql(state, event, config, metric)
47
54
  stack = state.traced_method_stack
48
55
 
49
- # enter transaction trace segment
56
+ # enter transaction trace node
50
57
  frame = stack.push_frame(state, :active_record, event.time)
51
58
 
52
59
  NewRelic::Agent.instance.transaction_sampler \
53
60
  .notice_sql(event.payload[:sql], config,
54
61
  Helper.milliseconds_to_seconds(event.duration),
55
- state, &method(:get_explain_plan))
62
+ state, &@explainer)
56
63
 
57
64
  NewRelic::Agent.instance.sql_sampler \
58
65
  .notice_sql(event.payload[:sql], metric, config,
59
66
  Helper.milliseconds_to_seconds(event.duration),
60
- state, &method(:get_explain_plan))
67
+ state, &@explainer)
61
68
 
62
- # exit transaction trace segment
69
+ # exit transaction trace node
63
70
  stack.pop_frame(state, frame, metric, event.end)
64
71
  end
65
72
 
@@ -11,16 +11,13 @@ module NewRelic
11
11
  module Instrumentation
12
12
  # == NewRelic instrumentation for controller actions and tasks
13
13
  #
14
- # This instrumentation is applied to the action controller to collect
15
- # metrics for every web request.
16
- #
17
- # It can also be used to capture performance information for
14
+ # This module can also be used to capture performance information for
18
15
  # background tasks and other non-web transactions, including
19
16
  # detailed transaction traces and traced errors.
20
17
  #
21
18
  # For details on how to instrument background tasks see
22
- # ClassMethods#add_transaction_tracer and
23
- # #perform_action_with_newrelic_trace
19
+ # {ClassMethods#add_transaction_tracer} and
20
+ # {#perform_action_with_newrelic_trace}
24
21
  #
25
22
  # @api public
26
23
  #
@@ -212,6 +209,8 @@ module NewRelic
212
209
  end
213
210
  end
214
211
 
212
+ # @!parse extend ClassMethods
213
+
215
214
  class TransactionNamer
216
215
  def self.name_for(txn, traced_obj, category, options={})
217
216
  "#{prefix_for_category(txn, category)}#{path_name(traced_obj, options)}"
@@ -323,7 +322,7 @@ module NewRelic
323
322
  # allows you to set the entire metric after the category part. Overrides
324
323
  # all the other options.
325
324
  # * <tt>:request => Rack::Request#new(env)</tt> is used to pass in a
326
- # request object that may respond to uri and referer.
325
+ # request object that may respond to path and referer.
327
326
  #
328
327
  # @api public
329
328
  #
@@ -124,13 +124,13 @@ DependencyDetection.defer do
124
124
  # tracing if it's enabled.
125
125
  def hook_pending_request(request) #THREAD_LOCAL_ACCESS
126
126
  wrapped_request, wrapped_response = wrap_request(request)
127
- state = NewRelic::Agent::TransactionState.tl_get
128
- t0 = Time.now
129
- segment = NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
127
+ state = NewRelic::Agent::TransactionState.tl_get
128
+ t0 = Time.now
129
+ node = NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
130
130
 
131
131
  unless request._nr_instrumented
132
132
  install_header_callback(request, wrapped_response)
133
- install_completion_callback(request, t0, segment, wrapped_request, wrapped_response)
133
+ install_completion_callback(request, t0, node, wrapped_request, wrapped_response)
134
134
  request._nr_instrumented = true
135
135
  end
136
136
  rescue => err
@@ -163,13 +163,13 @@ DependencyDetection.defer do
163
163
  end
164
164
 
165
165
  # Install a callback that will finish the trace.
166
- def install_completion_callback(request, t0, segment, wrapped_request, wrapped_response) #THREAD_LOCAL_ACCESS
166
+ def install_completion_callback(request, t0, node, wrapped_request, wrapped_response) #THREAD_LOCAL_ACCESS
167
167
  original_callback = request.on_complete
168
168
  request._nr_original_on_complete = original_callback
169
169
  request.on_complete do |finished_request|
170
170
  begin
171
171
  state = NewRelic::Agent::TransactionState.tl_get
172
- NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
172
+ NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, node, wrapped_request, wrapped_response)
173
173
  ensure
174
174
  # Make sure the existing completion callback is run, and restore the
175
175
  # on_complete callback to how it was before.
@@ -21,8 +21,8 @@ module ::Excon
21
21
  wrapped_request = ::NewRelic::Agent::HTTPClients::ExconHTTPRequest.new(datum)
22
22
  state = ::NewRelic::Agent::TransactionState.tl_get
23
23
  t0 = Time.now
24
- segment = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
25
- datum[:connection].instance_variable_set(TRACE_DATA_IVAR, [t0, segment, wrapped_request])
24
+ node = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
25
+ datum[:connection].instance_variable_set(TRACE_DATA_IVAR, [t0, node, wrapped_request])
26
26
  end
27
27
  rescue => e
28
28
  NewRelic::Agent.logger.debug(e)
@@ -44,12 +44,12 @@ module ::Excon
44
44
  trace_data = datum[:connection] && datum[:connection].instance_variable_get(TRACE_DATA_IVAR)
45
45
  if trace_data
46
46
  datum[:connection].instance_variable_set(TRACE_DATA_IVAR, nil)
47
- t0, segment, wrapped_request = trace_data
47
+ t0, node, wrapped_request = trace_data
48
48
  if datum[:response]
49
49
  wrapped_response = ::NewRelic::Agent::HTTPClients::ExconHTTPResponse.new(datum[:response])
50
50
  end
51
51
  state = ::NewRelic::Agent::TransactionState.tl_get
52
- ::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
52
+ ::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, node, wrapped_request, wrapped_response)
53
53
  end
54
54
  end
55
55
  end
@@ -19,13 +19,13 @@ module NewRelic
19
19
  def handle_transaction(endpoint, class_name)
20
20
  return unless endpoint && route = endpoint.route
21
21
  name_transaction(route, class_name)
22
- capture_params(endpoint) if Agent.config[:capture_params]
22
+ capture_params(endpoint)
23
23
  end
24
24
 
25
25
  def name_transaction(route, class_name)
26
26
  txn_name = name_for_transaction(route, class_name)
27
- segment_name = "Middleware/Grape/#{class_name}/call"
28
- Transaction.set_default_transaction_name(txn_name, :grape, segment_name)
27
+ node_name = "Middleware/Grape/#{class_name}/call"
28
+ Transaction.set_default_transaction_name(txn_name, :grape, node_name)
29
29
  end
30
30
 
31
31
  def name_for_transaction(route, class_name)
@@ -46,6 +46,7 @@ module NewRelic
46
46
  params = ParameterFiltering::apply_filters(env, endpoint.params)
47
47
  params.delete("route_info")
48
48
  txn.filtered_params = params
49
+ txn.merge_request_parameters(params)
49
50
  end
50
51
  end
51
52
  end
@@ -96,9 +96,12 @@ DependencyDetection.defer do
96
96
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
97
97
 
98
98
  def perform_action_with_newrelic_trace_wrapper
99
- options = {}
100
- options[:params] = (respond_to?(:filter_parameters)) ? filter_parameters(params) : params
101
- perform_action_with_newrelic_trace(options) { perform_action_without_newrelic_trace }
99
+ munged_params = (respond_to?(:filter_parameters)) ? filter_parameters(params) : params
100
+ munged_params = NewRelic::Agent::ParameterFiltering.filter_rails_request_parameters(munged_params)
101
+
102
+ perform_action_with_newrelic_trace(:params => munged_params) do
103
+ perform_action_without_newrelic_trace
104
+ end
102
105
  end
103
106
 
104
107
  alias_method :perform_action_without_newrelic_trace, :perform_action
@@ -24,14 +24,20 @@ DependencyDetection.defer do
24
24
  # Make a note of an exception associated with the currently executing
25
25
  # controller action. Note that this used to be available on Object
26
26
  # but we replaced that global method with NewRelic::Agent#notice_error.
27
- # Use that one outside of controller actions.
27
+ # Use that one instead.
28
+ #
29
+ # @api public
30
+ # @deprecated
28
31
  def newrelic_notice_error(exception, custom_params = {})
29
- NewRelic::Agent::Transaction.notice_error exception, :custom_params => custom_params, :request => request
32
+ NewRelic::Agent::Deprecator.deprecate("ActionController#newrelic_notice_error",
33
+ "NewRelic::Agent#notice_error")
34
+
35
+ NewRelic::Agent::Transaction.notice_error exception, :custom_params => custom_params
30
36
  end
31
37
 
32
38
  def rescue_action_with_newrelic_trace(exception)
33
39
  rescue_action_without_newrelic_trace exception
34
- NewRelic::Agent::Transaction.notice_error exception, :request => request
40
+ NewRelic::Agent::Transaction.notice_error exception
35
41
  end
36
42
 
37
43
  # Compare with #alias_method_chain, which is not available in
@@ -19,7 +19,12 @@ module NewRelic
19
19
  end
20
20
 
21
21
  def process_action(*args) #THREAD_LOCAL_ACCESS
22
- perform_action_with_newrelic_trace(:category => :controller, :name => self.action_name, :path => newrelic_metric_path, :params => request.filtered_parameters, :class_name => self.class.name) do
22
+ munged_params = NewRelic::Agent::ParameterFiltering.filter_rails_request_parameters(request.filtered_parameters)
23
+ perform_action_with_newrelic_trace(:category => :controller,
24
+ :name => self.action_name,
25
+ :path => newrelic_metric_path,
26
+ :params => munged_params,
27
+ :class_name => self.class.name) do
23
28
  super
24
29
  end
25
30
  end
@@ -7,14 +7,16 @@ module NewRelic
7
7
  module Instrumentation
8
8
  module Rails3
9
9
  module Errors
10
+
11
+ # @api public
12
+ # @deprecated
10
13
  def newrelic_notice_error(exception, custom_params = {})
11
- filtered_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
12
- filtered_params.merge!(custom_params)
13
- NewRelic::Agent::Transaction.notice_error( \
14
- exception, \
15
- :request => request, \
16
- :metric => newrelic_metric_path, \
17
- :custom_params => filtered_params)
14
+ NewRelic::Agent::Deprecator.deprecate("ActionController#newrelic_notice_error",
15
+ "NewRelic::Agent#notice_error")
16
+
17
+ NewRelic::Agent::Transaction.notice_error(exception,
18
+ :metric => newrelic_metric_path,
19
+ :custom_params => custom_params)
18
20
  end
19
21
  end
20
22
  end
@@ -7,13 +7,15 @@ module NewRelic
7
7
  module Instrumentation
8
8
  module Rails4
9
9
  module Errors
10
+
11
+ # @api public
12
+ # @deprecated
10
13
  def newrelic_notice_error(exception, custom_params = {})
11
- filtered_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
12
- filtered_params.merge!(custom_params)
13
- NewRelic::Agent::Transaction.notice_error( \
14
- exception, \
15
- :request => request, \
16
- :custom_params => filtered_params)
14
+ NewRelic::Agent::Deprecator.deprecate("ActionController#newrelic_notice_error",
15
+ "NewRelic::Agent#notice_error")
16
+
17
+ NewRelic::Agent::Transaction.notice_error(exception,
18
+ :custom_params => custom_params)
17
19
  end
18
20
  end
19
21
  end
@@ -27,9 +27,8 @@ DependencyDetection.defer do
27
27
  :class_name => self.name,
28
28
  :category => 'OtherTransaction/ResqueJob') do
29
29
 
30
- if NewRelic::Agent.config[:'resque.capture_params']
31
- NewRelic::Agent.add_custom_parameters(:job_arguments => args)
32
- end
30
+ NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(args, :'job.resque.args',
31
+ NewRelic::Agent::AttributeFilter::DST_NONE)
33
32
 
34
33
  yield(*args)
35
34
  end
@@ -27,9 +27,9 @@ DependencyDetection.defer do
27
27
  end
28
28
 
29
29
  perform_action_with_newrelic_trace(trace_args) do
30
- if NewRelic::Agent.config[:'sidekiq.capture_params']
31
- NewRelic::Agent.add_custom_parameters(:job_arguments => msg['args'])
32
- end
30
+ NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(msg['args'], :'job.sidekiq.args',
31
+ NewRelic::Agent::AttributeFilter::DST_NONE)
32
+
33
33
  yield
34
34
  end
35
35
  end
@@ -65,10 +65,10 @@ module NewRelic::Agent::Instrumentation::TyphoeusTracing
65
65
  if state.is_execution_traced? && !request_is_hydra_enabled?(request)
66
66
  wrapped_request = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPRequest.new(request)
67
67
  t0 = Time.now
68
- segment = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
68
+ node = ::NewRelic::Agent::CrossAppTracing.start_trace(state, t0, wrapped_request)
69
69
  callback = Proc.new do
70
70
  wrapped_response = ::NewRelic::Agent::HTTPClients::TyphoeusHTTPResponse.new(request.response)
71
- ::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, segment, wrapped_request, wrapped_response)
71
+ ::NewRelic::Agent::CrossAppTracing.finish_trace(state, t0, node, wrapped_request, wrapped_response)
72
72
  end
73
73
  request.on_complete.unshift(callback)
74
74
  end
@@ -127,8 +127,10 @@ module NewRelic
127
127
  QUEUE_TIME_KEY = "queueTime".freeze
128
128
  APPLICATION_TIME_KEY = "applicationTime".freeze
129
129
  AGENT_KEY = "agent".freeze
130
- USER_ATTRIBUTES_KEY = "userAttributes".freeze
131
130
  SSL_FOR_HTTP_KEY = "sslForHttp".freeze
131
+ ATTS_KEY = "atts".freeze
132
+ ATTS_USER_SUBKEY = "u".freeze
133
+ ATTS_AGENT_SUBKEY = "a".freeze
132
134
 
133
135
  # NOTE: Internal prototyping may override this, so leave name stable!
134
136
  def data_for_js_agent(state)
@@ -146,7 +148,7 @@ module NewRelic
146
148
  }
147
149
 
148
150
  add_ssl_for_http(data)
149
- add_user_attributes(data, state.current_transaction)
151
+ add_attributes(data, state.current_transaction)
150
152
 
151
153
  data
152
154
  end
@@ -158,25 +160,31 @@ module NewRelic
158
160
  end
159
161
  end
160
162
 
161
- def add_user_attributes(data, txn)
162
- return unless include_custom_parameters?(txn)
163
+ def add_attributes(data, txn)
164
+ return unless txn
163
165
 
164
- params = event_params(txn.custom_parameters)
165
- json = NewRelic::JSONWrapper.dump(params)
166
- data[USER_ATTRIBUTES_KEY] = obfuscator.obfuscate(json)
166
+ atts = {}
167
+ append_custom_attributes!(txn, atts)
168
+ append_agent_attributes!(txn, atts)
169
+
170
+ unless atts.empty?
171
+ json = NewRelic::JSONWrapper.dump(atts)
172
+ data[ATTS_KEY] = obfuscator.obfuscate(json)
173
+ end
167
174
  end
168
175
 
169
- # Still support deprecated capture_attributes.page_view_events for
170
- # clients that use it. Could potentially be removed if we don't have
171
- # anymore users with it set according to zeitgeist.
172
- def include_custom_parameters?(txn)
173
- has_custom_parameters?(txn) &&
174
- (NewRelic::Agent.config[:'browser_monitoring.capture_attributes'] ||
175
- NewRelic::Agent.config[:'capture_attributes.page_view_events'])
176
+ def append_custom_attributes!(txn, atts)
177
+ custom_attributes = txn.attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_BROWSER_MONITORING)
178
+ unless custom_attributes.empty?
179
+ atts[ATTS_USER_SUBKEY] = custom_attributes
180
+ end
176
181
  end
177
182
 
178
- def has_custom_parameters?(txn)
179
- txn && txn.custom_parameters && !txn.custom_parameters.empty?
183
+ def append_agent_attributes!(txn, atts)
184
+ agent_attributes = txn.attributes.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_BROWSER_MONITORING)
185
+ unless agent_attributes.empty?
186
+ atts[ATTS_AGENT_SUBKEY] = agent_attributes
187
+ end
180
188
  end
181
189
 
182
190
  def html_safe_if_needed(string)