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
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+ # This file is distributed under New Relic's license terms.
3
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+
5
+ # summarizes performance data for all calls to segments
6
+ # with the same metric_name
7
+ module NewRelic
8
+ module Rack
9
+ class DeveloperMode
10
+ class SegmentSummary
11
+ attr_accessor :metric_name, :total_time, :exclusive_time, :call_count, :current_nest_count
12
+
13
+ def initialize(metric_name, sample)
14
+ @metric_name = metric_name
15
+ @total_time, @exclusive_time, @call_count = 0,0,0
16
+ @sample = sample
17
+ @current_nest_count = 0
18
+ end
19
+
20
+ def <<(segment)
21
+ if metric_name != segment.metric_name
22
+ raise ArgumentError, "Metric Name Mismatch: #{segment.metric_name} != #{metric_name}"
23
+ end
24
+
25
+ # a nested segment should use the sum of the top level totals
26
+ @total_time += segment.duration if current_nest_count == 0
27
+ @exclusive_time += segment.exclusive_duration
28
+ @call_count += 1
29
+ end
30
+
31
+ def average_time
32
+ @total_time / @call_count
33
+ end
34
+
35
+ def average_exclusive_time
36
+ @exclusive_time / @call_count
37
+ end
38
+
39
+ def exclusive_time_percentage
40
+ return 0 unless @exclusive_time && @sample.duration && @sample.duration > 0
41
+ @exclusive_time / @sample.duration
42
+ end
43
+
44
+ def total_time_percentage
45
+ return 0 unless @total_time && @sample.duration && @sample.duration > 0
46
+ @total_time / @sample.duration
47
+ end
48
+
49
+ def ui_name
50
+ return @metric_name if @metric_name == 'Remainder'
51
+ NewRelic::MetricParser::MetricParser.parse(@metric_name).developer_name
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -11,8 +11,8 @@ module NewRelic
11
11
  end
12
12
 
13
13
  MAJOR = 3
14
- MINOR = 11
15
- TINY = 2
14
+ MINOR = 12
15
+ TINY = 0
16
16
 
17
17
  begin
18
18
  require File.join(File.dirname(__FILE__), 'build')
@@ -3,222 +3,45 @@
3
3
  # .NET, PHP, Python and Node applications with deep visibility and low
4
4
  # overhead. For more information, visit www.newrelic.com.
5
5
  #
6
- # Generated <%= Time.now.strftime('%B %d, %Y') %>, for version <%= NewRelic::VERSION::STRING %>
7
- #
8
- # <%= generated_for_user %>
9
-
6
+ # Generated <%= Time.now.strftime('%B %d, %Y') %><%= ", for version #{@agent_version}" if @agent_version %>
7
+ # <%= "\n# #{generated_for_user}\n#" if generated_for_user %>
8
+ # For full documentation of agent configuration options, please refer to
9
+ # https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
10
10
 
11
- # Here are the settings that are common to all environments
12
11
  common: &default_settings
13
- # ============================== LICENSE KEY ===============================
14
-
15
- # You must specify the license key associated with your New Relic
16
- # account. This key binds your Agent's data to your account in the
17
- # New Relic service.
18
- license_key: '<%= license_key %>'
19
-
20
- # Agent Enabled (Ruby/Rails Only)
21
- # Use this setting to force the agent to run or not run.
22
- # Default is 'auto' which means the agent will install and run only
23
- # if a valid dispatcher such as Mongrel is running. This prevents
24
- # it from running with Rake or the console. Set to false to
25
- # completely turn the agent off regardless of the other settings.
26
- # Valid values are true, false and auto.
27
- #
28
- # agent_enabled: auto
12
+ # Required license key associated with your New Relic account.
13
+ license_key: <%= license_key %>
29
14
 
30
- # Application Name Set this to be the name of your application as
31
- # you'd like it show up in New Relic. The service will then auto-map
32
- # instances of your application into an "application" on your
33
- # dashboard page. If you want to map this instance into multiple
34
- # apps, like "AJAX Requests" and "All UI" then specify a semicolon
35
- # separated list of up to three distinct names, or a yaml list.
36
- # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
37
- # Production, Staging, etc)
38
- #
39
- # Example:
40
- #
41
- # app_name:
42
- # - Ajax Service
43
- # - All Services
44
- #
45
- # Caution: If you change this name, a new application will appear in the New
46
- # Relic user interface with the new name, and data will stop reporting to the
47
- # app with the old name.
48
- #
49
- # See https://newrelic.com/docs/site/renaming-applications for more details
50
- # on renaming your New Relic applications.
51
- #
52
- app_name: <%= @app_name %>
15
+ # Your application name. Renaming here affects where data displays in New
16
+ # Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
17
+ app_name: <%= app_name %>
53
18
 
54
- # When "true", the agent collects performance data about your
55
- # application and reports this data to the New Relic service at
56
- # newrelic.com. This global switch is normally overridden for each
57
- # environment below. (formerly called 'enabled')
58
- monitor_mode: true
19
+ # To disable the agent regardless of other settings, uncomment the following:
20
+ # agent_enabled: false
59
21
 
60
- # Developer mode should be off in every environment but
61
- # development as it has very high overhead in memory.
62
- developer_mode: false
63
-
64
- # The newrelic agent generates its own log file to keep its logging
65
- # information separate from that of your application. Specify its
66
- # log level here.
22
+ # Logging level for log/newrelic_agent.log
67
23
  log_level: info
68
24
 
69
- # Optionally set the path to the log file This is expanded from the
70
- # root directory (may be relative or absolute, e.g. 'log/' or
71
- # '/var/log/') The agent will attempt to create this directory if it
72
- # does not exist.
73
- # log_file_path: 'log'
74
-
75
- # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
76
- # log_file_name: 'newrelic_agent.log'
77
-
78
- # The newrelic agent communicates with the service via https by default. This
79
- # prevents eavesdropping on the performance metrics transmitted by the agent.
80
- # The encryption required by SSL introduces a nominal amount of CPU overhead,
81
- # which is performed asynchronously in a background thread. If you'd prefer
82
- # to send your metrics over http uncomment the following line.
83
- # ssl: false
84
-
85
- #============================== Browser Monitoring ===============================
86
- # New Relic Real User Monitoring gives you insight into the performance real users are
87
- # experiencing with your website. This is accomplished by measuring the time it takes for
88
- # your users' browsers to download and render your web pages by injecting a small amount
89
- # of JavaScript code into the header and footer of each page.
90
- browser_monitoring:
91
- # By default the agent automatically injects the monitoring JavaScript
92
- # into web pages. Set this attribute to false to turn off this behavior.
93
- auto_instrument: true
94
-
95
- # Proxy settings for connecting to the New Relic server.
96
- #
97
- # If a proxy is used, the host setting is required. Other settings
98
- # are optional. Default port is 8080.
99
- #
100
- # proxy_host: hostname
101
- # proxy_port: 8080
102
- # proxy_user:
103
- # proxy_pass:
104
-
105
- # The agent can optionally log all data it sends to New Relic servers to a
106
- # separate log file for human inspection and auditing purposes. To enable this
107
- # feature, change 'enabled' below to true.
108
- # See: https://newrelic.com/docs/ruby/audit-log
109
- audit_log:
110
- enabled: false
111
-
112
- # Tells transaction tracer and error collector (when enabled)
113
- # whether or not to capture HTTP params. When true, frameworks can
114
- # exclude HTTP parameters from being captured.
115
- # Rails: the RoR filter_parameter_logging excludes parameters
116
- # Java: create a config setting called "ignored_params" and set it to
117
- # a comma separated list of HTTP parameter names.
118
- # ex: ignored_params: credit_card, ssn, password
119
- capture_params: false
120
-
121
- # Transaction tracer captures deep information about slow
122
- # transactions and sends this to the New Relic service once a
123
- # minute. Included in the transaction is the exact call sequence of
124
- # the transactions including any SQL statements issued.
125
- transaction_tracer:
126
-
127
- # Transaction tracer is enabled by default. Set this to false to
128
- # turn it off. This feature is only available at the Professional
129
- # and above product levels.
130
- enabled: true
131
-
132
- # Threshold in seconds for when to collect a transaction
133
- # trace. When the response time of a controller action exceeds
134
- # this threshold, a transaction trace will be recorded and sent to
135
- # New Relic. Valid values are any float value, or (default) "apdex_f",
136
- # which will use the threshold for an dissatisfying Apdex
137
- # controller action - four times the Apdex T value.
138
- transaction_threshold: apdex_f
139
25
 
140
- # When transaction tracer is on, SQL statements can optionally be
141
- # recorded. The recorder has three modes, "off" which sends no
142
- # SQL, "raw" which sends the SQL statement in its original form,
143
- # and "obfuscated", which strips out numeric and string literals.
144
- record_sql: obfuscated
145
-
146
- # Threshold in seconds for when to collect stack trace for a SQL
147
- # call. In other words, when SQL statements exceed this threshold,
148
- # then capture and send to New Relic the current stack trace. This is
149
- # helpful for pinpointing where long SQL calls originate from.
150
- stack_trace_threshold: 0.500
151
-
152
- # Determines whether the agent will capture query plans for slow
153
- # SQL queries. Only supported in mysql and postgres. Should be
154
- # set to false when using other adapters.
155
- # explain_enabled: true
156
-
157
- # Threshold for query execution time below which query plans will
158
- # not be captured. Relevant only when `explain_enabled` is true.
159
- # explain_threshold: 0.5
160
-
161
- # Error collector captures information about uncaught exceptions and
162
- # sends them to New Relic for viewing
163
- error_collector:
164
-
165
- # Error collector is enabled by default. Set this to false to turn
166
- # it off. This feature is only available at the Professional and above
167
- # product levels.
168
- enabled: true
169
-
170
- # To stop specific errors from reporting to New Relic, set this property
171
- # to comma-separated values. Default is to ignore routing errors,
172
- # which are how 404's get triggered.
173
- ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
174
-
175
- # If you're interested in capturing memcache keys as though they
176
- # were SQL uncomment this flag. Note that this does increase
177
- # overhead slightly on every memcached call, and can have security
178
- # implications if your memcached keys are sensitive
179
- # capture_memcache_keys: true
180
-
181
- # Application Environments
182
- # ------------------------------------------
183
26
  # Environment-specific settings are in this section.
184
- # For Rails applications, RAILS_ENV is used to determine the environment.
185
- # For Java applications, pass -Dnewrelic.environment <environment> to set
186
- # the environment.
187
-
188
- # NOTE if your application has other named environments, you should
189
- # provide newrelic configuration settings for these environments here.
190
-
27
+ # RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
28
+ # If your application has other named environments, configure them here.
191
29
  development:
192
30
  <<: *default_settings
193
- # Turn on communication to New Relic service in development mode
194
- monitor_mode: true
195
- app_name: <%= @app_name %> (Development)
31
+ app_name: <%= app_name %> (Development)
196
32
 
197
- # Rails Only - when running in Developer Mode, the New Relic Agent will
198
- # present performance information on the last 100 transactions you have
199
- # executed since starting the mongrel.
200
33
  # NOTE: There is substantial overhead when running in developer mode.
201
34
  # Do not use for production or load testing.
202
35
  developer_mode: true
203
36
 
204
37
  test:
205
38
  <<: *default_settings
206
- # It almost never makes sense to turn on the agent when running
207
- # unit, functional or integration tests or the like.
39
+ # It doesn't make sense to report to New Relic from automated test runs.
208
40
  monitor_mode: false
209
41
 
210
- # Turn on the agent in production for 24x7 monitoring. NewRelic
211
- # testing shows an average performance impact of < 5 ms per
212
- # transaction, you can leave this on all the time without
213
- # incurring any user-visible performance degradation.
214
- production:
42
+ staging:
215
43
  <<: *default_settings
216
- monitor_mode: true
44
+ app_name: <%= app_name %> (Staging)
217
45
 
218
- # Many applications have a staging environment which behaves
219
- # identically to production. Support for that environment is provided
220
- # here. By default, the staging environment has the agent turned on.
221
- staging:
46
+ production:
222
47
  <<: *default_settings
223
- monitor_mode: true
224
- app_name: <%= @app_name %> (Staging)
@@ -287,10 +287,14 @@ def in_transaction(*args, &blk)
287
287
  args.first || 'dummy'
288
288
 
289
289
  state = NewRelic::Agent::TransactionState.tl_get
290
+ txn = nil
290
291
 
291
292
  NewRelic::Agent::Transaction.wrap(state, name, category, opts) do
293
+ txn = state.current_transaction
292
294
  yield state.current_transaction
293
295
  end
296
+
297
+ txn
294
298
  end
295
299
 
296
300
  def stub_transaction_guid(guid)
@@ -300,7 +304,7 @@ end
300
304
  # Convenience wrapper around in_transaction that sets the category so that it
301
305
  # looks like we are in a web transaction
302
306
  def in_web_transaction(name='dummy')
303
- in_transaction(name, :category => :controller, :request => stub()) do
307
+ in_transaction(name, :category => :controller, :request => stub(:path => '/')) do
304
308
  yield
305
309
  end
306
310
  end
@@ -311,12 +315,14 @@ def in_background_transaction(name='silly')
311
315
  end
312
316
  end
313
317
 
314
- def last_traced_error
315
- NewRelic::Agent.agent.error_collector.errors.last
318
+ def refute_contains_request_params(attributes)
319
+ attributes.keys.each do |key|
320
+ refute_match /^request\.parameters\./, key.to_s
321
+ end
316
322
  end
317
323
 
318
- def last_traced_error_request_params
319
- last_traced_error.params[:request_params]
324
+ def last_traced_error
325
+ NewRelic::Agent.agent.error_collector.errors.last
320
326
  end
321
327
 
322
328
  def last_transaction_trace
@@ -324,7 +330,11 @@ def last_transaction_trace
324
330
  end
325
331
 
326
332
  def last_transaction_trace_request_params
327
- last_transaction_trace.params[:request_params]
333
+ agent_attributes = attributes_for(last_transaction_trace, :agent)
334
+ agent_attributes.inject({}) do |memo, (key, value)|
335
+ memo[key] = value if key.to_s.start_with?("request.parameters.")
336
+ memo
337
+ end
328
338
  end
329
339
 
330
340
  def find_sql_trace(metric_name)
@@ -337,72 +347,64 @@ def last_sql_trace
337
347
  NewRelic::Agent.agent.sql_sampler.sql_traces.values.last
338
348
  end
339
349
 
340
- def find_last_transaction_segment(transaction_sample=nil)
350
+ def find_last_transaction_node(transaction_sample=nil)
341
351
  if transaction_sample
342
- root_segment = transaction_sample.root_segment
352
+ root_node = transaction_sample.root_node
343
353
  else
344
354
  builder = NewRelic::Agent.agent.transaction_sampler.tl_builder
345
- root_segment = builder.current_segment
355
+ root_node = builder.current_node
346
356
  end
347
357
 
348
- last_segment = nil
349
- root_segment.each_segment {|s| last_segment = s }
358
+ last_node = nil
359
+ root_node.each_node {|s| last_node = s }
350
360
 
351
- return last_segment
361
+ return last_node
352
362
  end
353
363
 
354
- def collect_segment_names(transaction_sample)
355
- names = []
356
-
357
- transaction_sample.root_segment.each_segment do |segment|
358
- names << segment.metric_name
359
- end
360
-
361
- names
362
- end
363
-
364
- def find_segment_with_name(transaction_sample, name)
365
- transaction_sample.root_segment.each_segment do |segment|
366
- if segment.metric_name == name
367
- return segment
364
+ def find_node_with_name(transaction_sample, name)
365
+ transaction_sample.root_node.each_node do |node|
366
+ if node.metric_name == name
367
+ return node
368
368
  end
369
369
  end
370
370
 
371
371
  nil
372
372
  end
373
373
 
374
- def find_segment_with_name_matching(transaction_sample, regex)
375
- transaction_sample.root_segment.each_segment do |segment|
376
- if segment.metric_name.match regex
377
- return segment
374
+ def find_node_with_name_matching(transaction_sample, regex)
375
+ transaction_sample.root_node.each_node do |node|
376
+ if node.metric_name.match regex
377
+ return node
378
378
  end
379
379
  end
380
380
 
381
381
  nil
382
382
  end
383
383
 
384
- def find_all_segments_with_name_matching(transaction_sample, regexes)
384
+ def find_all_nodes_with_name_matching(transaction_sample, regexes)
385
385
  regexes = [regexes].flatten
386
- matching_segments = []
386
+ matching_nodes = []
387
387
 
388
- transaction_sample.root_segment.each_segment do |segment|
388
+ transaction_sample.root_node.each_node do |node|
389
389
  regexes.each do |regex|
390
- if segment.metric_name.match regex
391
- matching_segments << segment
390
+ if node.metric_name.match regex
391
+ matching_nodes << node
392
392
  end
393
393
  end
394
394
  end
395
395
 
396
- matching_segments
396
+ matching_nodes
397
397
  end
398
398
 
399
399
  def with_config(config_hash, at_start=true)
400
400
  config = NewRelic::Agent::Configuration::DottedHash.new(config_hash, true)
401
401
  NewRelic::Agent.config.add_config_for_testing(config, at_start)
402
+ NewRelic::Agent.instance.refresh_attribute_filter
402
403
  begin
403
404
  yield
404
405
  ensure
405
406
  NewRelic::Agent.config.remove_config(config)
407
+ NewRelic::Agent.instance.refresh_attribute_filter
406
408
  end
407
409
  end
408
410
 
@@ -639,3 +641,7 @@ def assert_event_attributes(event, test_name, expected_attributes, non_expected_
639
641
  assert_nil(event_attrs[name], "Found value '#{event_attrs[name]}' for attribute '#{name}', but expected nothing in #{test_name}")
640
642
  end
641
643
  end
644
+
645
+ def attributes_for(sample, type)
646
+ sample.attributes.instance_variable_get("@#{type}_attributes")
647
+ end