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
@@ -16,14 +16,6 @@ module NewRelic
16
16
  :'resque.capture_params' => false,
17
17
  :'sidekiq.capture_params' => false,
18
18
 
19
- # These aren't strictly necessary as add_custom_parameters is
20
- # directly responsible for ignoring incoming param, but we disallow
21
- # attributes by these settings just to be safe
22
- :'transaction_tracer.capture_attributes' => false,
23
- :'error_collector.capture_attributes' => false,
24
- :'browser_monitoring.capture_attributes' => false,
25
- :'analytics_events.capture_attributes' => false,
26
-
27
19
  :'transaction_tracer.record_sql' => record_sql_setting(local_settings, :'transaction_tracer.record_sql'),
28
20
  :'slow_sql.record_sql' => record_sql_setting(local_settings, :'slow_sql.record_sql'),
29
21
  :'mongo.obfuscate_queries' => true,
@@ -211,7 +211,7 @@ module NewRelic
211
211
  DottedHash.new(apply_mask(flattened)).to_hash.delete_if do |k, v|
212
212
  default = DEFAULTS[k]
213
213
  if default
214
- default[:local_only]
214
+ default[:exclude_from_reported_settings]
215
215
  else
216
216
  # In our tests, we add totally bogus configs, because testing.
217
217
  # In those cases, there will be no default. So we'll just let
@@ -6,22 +6,84 @@ module NewRelic
6
6
  module Agent
7
7
  module Configuration
8
8
  class ServerSource < DottedHash
9
- def initialize(hash, existing_config={})
10
- if hash['agent_config']
11
- if hash['agent_config']['transaction_tracer.transaction_threshold'] =~ /apdex_f/i
12
- # when value is "apdex_f" remove the config and defer to default
13
- hash['agent_config'].delete('transaction_tracer.transaction_threshold')
9
+ # These keys appear *outside* of the agent_config hash in the connect
10
+ # response, but should still be merged in as config settings to the
11
+ # main agent configuration.
12
+ TOP_LEVEL_KEYS = [
13
+ "apdex_t",
14
+ "application_id",
15
+ "beacon",
16
+ "browser_key",
17
+ "browser_monitoring.debug",
18
+ "browser_monitoring.loader",
19
+ "browser_monitoring.loader_version",
20
+ "collect_utilization",
21
+ "cross_process_id",
22
+ "data_report_period",
23
+ "data_report_periods.analytic_event_data",
24
+ "encoding_key",
25
+ "error_beacon",
26
+ "js_agent_file",
27
+ "js_agent_loader",
28
+ "trusted_account_ids"
29
+ ]
30
+
31
+ def initialize(connect_reply, existing_config={})
32
+ merged_settings = {}
33
+
34
+ merge_top_level_keys(merged_settings, connect_reply)
35
+ merge_agent_config_hash(merged_settings, connect_reply)
36
+ fix_transaction_threshold(merged_settings)
37
+ filter_keys(merged_settings)
38
+
39
+ apply_feature_gates(merged_settings, connect_reply, existing_config)
40
+
41
+ # The value under this key is a hash mapping transaction name strings
42
+ # to apdex_t values. We don't want the nested hash to be flattened
43
+ # as part of the call to super below, so it skips going through
44
+ # merged_settings.
45
+ self[:web_transactions_apdex] = connect_reply['web_transactions_apdex']
46
+
47
+ # This causes keys in merged_settings to be symbolized and flattened
48
+ super(merged_settings)
49
+ end
50
+
51
+ def merge_top_level_keys(merged_settings, connect_reply)
52
+ TOP_LEVEL_KEYS.each do |key_name|
53
+ if connect_reply[key_name]
54
+ merged_settings[key_name] = connect_reply[key_name]
14
55
  end
56
+ end
57
+ end
15
58
 
16
- hoist_agent_config(hash)
59
+ def merge_agent_config_hash(merged_settings, connect_reply)
60
+ if connect_reply['agent_config']
61
+ merged_settings.merge!(connect_reply['agent_config'])
17
62
  end
63
+ end
18
64
 
19
- if hash['web_transactions_apdex']
20
- self[:web_transactions_apdex] = hash.delete('web_transactions_apdex')
65
+ def fix_transaction_threshold(merged_settings)
66
+ # when value is "apdex_f" remove the config and defer to default
67
+ if merged_settings['transaction_tracer.transaction_threshold'] =~ /apdex_f/i
68
+ merged_settings.delete('transaction_tracer.transaction_threshold')
21
69
  end
22
- apply_feature_gates(hash, existing_config)
70
+ end
23
71
 
24
- super(hash)
72
+ def filter_keys(merged_settings)
73
+ merged_settings.delete_if do |key, _|
74
+ setting_spec = DEFAULTS[key.to_sym]
75
+ if setting_spec
76
+ if setting_spec[:allowed_from_server]
77
+ false # it's allowed, so don't delete it
78
+ else
79
+ NewRelic::Agent.logger.warn("Ignoring server-sent config for '#{key}' - this setting cannot be set from the server")
80
+ true # delete it
81
+ end
82
+ else
83
+ NewRelic::Agent.logger.debug("Ignoring unrecognized config key from server: '#{key}'")
84
+ true
85
+ end
86
+ end
25
87
  end
26
88
 
27
89
  # These feature gates are not intended to be bullet-proof, but only to
@@ -29,33 +91,26 @@ module NewRelic
29
91
  # the user's subscription level precludes its use. The server is the
30
92
  # ultimate authority regarding subscription levels, so we expect it to
31
93
  # do the real enforcement there.
32
- def apply_feature_gates(server_config, existing_config)
94
+ def apply_feature_gates(merged_settings, connect_reply, existing_config)
33
95
  gated_features = {
34
- :'transaction_tracer.enabled' => 'collect_traces',
35
- :'slow_sql.enabled' => 'collect_traces',
36
- :'error_collector.enabled' => 'collect_errors',
37
- :'analytics_events.enabled' => 'collect_analytics_events',
38
- :'custom_insights_events.enabled' => 'collect_custom_events'
96
+ 'transaction_tracer.enabled' => 'collect_traces',
97
+ 'slow_sql.enabled' => 'collect_traces',
98
+ 'error_collector.enabled' => 'collect_errors',
99
+ 'analytics_events.enabled' => 'collect_analytics_events',
100
+ 'custom_insights_events.enabled' => 'collect_custom_events'
39
101
  }
40
- gated_features.each do |feature, gate_key|
41
- if server_config.has_key?(gate_key)
42
- allowed_by_server = server_config[gate_key]
43
- requested_value = ungated_value(feature, server_config, existing_config)
44
- effective_value = (allowed_by_server && requested_value)
45
- server_config[feature] = effective_value
102
+ gated_features.each do |config_key, gate_key|
103
+ if connect_reply.has_key?(gate_key)
104
+ allowed_by_server = connect_reply[gate_key]
105
+ requested_value = ungated_value(config_key, merged_settings, existing_config)
106
+ effective_value = (allowed_by_server && requested_value)
107
+ merged_settings[config_key] = effective_value
46
108
  end
47
109
  end
48
110
  end
49
111
 
50
- def ungated_value(key, server_config, existing_config)
51
- server_config.has_key?(key) ? server_config[key] : existing_config[key]
52
- end
53
-
54
- # Move agent_config subkey to top level of hash, symbolizing it too
55
- def hoist_agent_config(hash)
56
- agent_config = hash.delete('agent_config')
57
- DottedHash.symbolize(agent_config)
58
- hash.merge!(agent_config)
112
+ def ungated_value(key, merged_settings, existing_config)
113
+ merged_settings.has_key?(key) ? merged_settings[key] : existing_config[key.to_sym]
59
114
  end
60
115
  end
61
116
  end
@@ -26,7 +26,7 @@ module NewRelic
26
26
  end
27
27
 
28
28
  substitute_transaction_threshold(config)
29
- booleanify_values(config, 'agent_enabled', 'enabled', 'monitor_daemons')
29
+ booleanify_values(config, 'agent_enabled', 'enabled')
30
30
 
31
31
  super(config, true)
32
32
  end
@@ -37,7 +37,7 @@ module NewRelic
37
37
 
38
38
  save_client_cross_app_id(state, env)
39
39
  save_referring_transaction_info(state, env)
40
- set_transaction_custom_parameters(state)
40
+ set_transaction_attributes(state)
41
41
  end
42
42
  end
43
43
 
@@ -47,11 +47,6 @@ module NewRelic
47
47
  insert_response_header(state, env, headers)
48
48
  end
49
49
 
50
- events.subscribe(:notice_error) do |_, options| #THREAD_LOCAL_ACCESS
51
- state = NewRelic::Agent::TransactionState.tl_get
52
-
53
- set_error_custom_parameters(state, options)
54
- end
55
50
  end
56
51
 
57
52
  def save_client_cross_app_id(state, request_headers)
@@ -137,21 +132,21 @@ module NewRelic
137
132
  payload = obfuscator.obfuscate(NewRelic::JSONWrapper.dump(payload))
138
133
  end
139
134
 
140
- def set_transaction_custom_parameters(state)
135
+ def set_transaction_attributes(state)
141
136
  # We expect to get the before call to set the id (if we have it) before
142
137
  # this, and then write our custom parameter when the transaction starts
143
- NewRelic::Agent.add_custom_parameters(:client_cross_process_id => state.client_cross_app_id) if state.client_cross_app_id
138
+ return unless txn = state.current_transaction
139
+
140
+ if state.client_cross_app_id
141
+ txn.attributes.add_intrinsic_attribute(:client_cross_process_id, state.client_cross_app_id)
142
+ end
144
143
 
145
144
  referring_guid = client_referring_transaction_guid(state)
146
145
  if referring_guid
147
- NewRelic::Agent.add_custom_parameters(:referring_transaction_guid => referring_guid)
146
+ txn.attributes.add_intrinsic_attribute(:referring_transaction_guid, referring_guid)
148
147
  end
149
148
  end
150
149
 
151
- def set_error_custom_parameters(state, options)
152
- options[:client_cross_process_id] = state.client_cross_app_id if state.client_cross_app_id
153
- end
154
-
155
150
  def set_metrics(id, timings)
156
151
  metric_name = "ClientApplication/#{id}/all"
157
152
  NewRelic::Agent.record_metric(metric_name, timings.app_time_in_seconds)
@@ -44,10 +44,10 @@ module NewRelic
44
44
  # a race condition if we raise after begin but before t0's set.
45
45
  t0 = Time.now
46
46
  begin
47
- segment = start_trace(state, t0, request)
47
+ node = start_trace(state, t0, request)
48
48
  response = yield
49
49
  ensure
50
- finish_trace(state, t0, segment, request, response)
50
+ finish_trace(state, t0, node, request, response)
51
51
  end
52
52
 
53
53
  return response
@@ -67,13 +67,13 @@ module NewRelic
67
67
  # * []=(key, val) - Set an HTTP request header by name
68
68
  # * uri - Full URI of the request
69
69
  #
70
- # This method returns the transaction segment if it was sucessfully pushed.
70
+ # This method returns the transaction node if it was sucessfully pushed.
71
71
  def start_trace(state, t0, request)
72
72
  inject_request_headers(state, request) if cross_app_enabled?
73
73
  stack = state.traced_method_stack
74
- segment = stack.push_frame(state, :http_request, t0)
74
+ node = stack.push_frame(state, :http_request, t0)
75
75
 
76
- return segment
76
+ return node
77
77
  rescue => err
78
78
  NewRelic::Agent.logger.error "Uncaught exception while tracing HTTP request", err
79
79
  return nil
@@ -95,7 +95,7 @@ module NewRelic
95
95
  # * [](key) - Reads response headers.
96
96
  # * to_hash - Converts response headers to a Hash
97
97
  #
98
- def finish_trace(state, t0, segment, request, response)
98
+ def finish_trace(state, t0, node, request, response)
99
99
  unless t0
100
100
  NewRelic::Agent.logger.error("HTTP request trace finished without start time. This is probably an agent bug.")
101
101
  return
@@ -114,19 +114,19 @@ module NewRelic
114
114
  stats_engine.record_scoped_and_unscoped_metrics(
115
115
  state, scoped_metric, metrics, duration)
116
116
 
117
- # If we don't have segment, something failed during start_trace so
118
- # the current segment isn't the HTTP call it should have been.
119
- if segment
120
- segment.name = scoped_metric
117
+ # If we don't have node, something failed during start_trace so
118
+ # the current node isn't the HTTP call it should have been.
119
+ if node
120
+ node.name = scoped_metric
121
121
  add_transaction_trace_parameters(request, response)
122
122
  end
123
123
  end
124
124
  ensure
125
- # If we have a segment, always pop the traced method stack to avoid
125
+ # If we have a node, always pop the traced method stack to avoid
126
126
  # an inconsistent state, which prevents tracing of whole transaction.
127
- if segment
127
+ if node
128
128
  stack = state.traced_method_stack
129
- stack.pop_frame(state, segment, scoped_metric, t1)
129
+ stack.pop_frame(state, node, scoped_metric, t1)
130
130
  end
131
131
  end
132
132
  rescue NewRelic::Agent::CrossAppTracing::Error => err
@@ -192,7 +192,7 @@ module NewRelic
192
192
 
193
193
  def add_transaction_trace_parameters(request, response)
194
194
  filtered_uri = ::NewRelic::Agent::HTTPClients::URIUtil.filter_uri(request.uri)
195
- transaction_sampler.add_segment_parameters(:uri => filtered_uri)
195
+ transaction_sampler.add_node_parameters(:uri => filtered_uri)
196
196
  if response && response_is_crossapp?(response)
197
197
  add_cat_transaction_trace_parameters(response)
198
198
  end
@@ -203,7 +203,7 @@ module NewRelic
203
203
  # add them to the current TT node.
204
204
  def add_cat_transaction_trace_parameters( response )
205
205
  appdata = extract_appdata( response )
206
- transaction_sampler.add_segment_parameters( \
206
+ transaction_sampler.add_node_parameters( \
207
207
  :transaction_guid => appdata[APPDATA_TXN_GUID_INDEX] )
208
208
  end
209
209
 
@@ -3,6 +3,7 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  require 'new_relic/agent/sized_buffer'
6
+ require 'new_relic/agent/attribute_processing'
6
7
 
7
8
  module NewRelic
8
9
  module Agent
@@ -11,7 +12,6 @@ module NewRelic
11
12
 
12
13
  TYPE = 'type'.freeze
13
14
  TIMESTAMP = 'timestamp'.freeze
14
- EVENT_PARAMS_CTX = 'recording custom event'.freeze
15
15
  EVENT_TYPE_REGEX = /^[a-zA-Z0-9:_ ]+$/.freeze
16
16
 
17
17
  DEFAULT_CAPACITY_KEY = :'custom_insights_events.max_samples_stored'
@@ -33,6 +33,10 @@ module NewRelic
33
33
  end
34
34
 
35
35
  def record(type, attributes)
36
+ unless attributes.is_a? Hash
37
+ raise ArgumentError, "Expected Hash but got #{attributes.class}"
38
+ end
39
+
36
40
  type = @type_strings[type]
37
41
  unless type =~ EVENT_TYPE_REGEX
38
42
  note_dropped_event(type)
@@ -41,7 +45,7 @@ module NewRelic
41
45
 
42
46
  event = [
43
47
  { TYPE => type, TIMESTAMP => Time.now.to_i },
44
- event_params(attributes, EVENT_PARAMS_CTX)
48
+ AttributeProcessing.flatten_and_coerce(attributes)
45
49
  ]
46
50
 
47
51
  stored = @lock.synchronize do
@@ -49,7 +49,9 @@ module NewRelic
49
49
  end
50
50
 
51
51
  def record_sql_method(config_section=:transaction_tracer)
52
- case Agent.config["#{config_section}.record_sql".to_sym].to_s
52
+ key = record_sql_method_key(config_section)
53
+
54
+ case Agent.config[key].to_s
53
55
  when 'off'
54
56
  :off
55
57
  when 'none'
@@ -63,6 +65,17 @@ module NewRelic
63
65
  end
64
66
  end
65
67
 
68
+ def record_sql_method_key(config_section)
69
+ case config_section
70
+ when :transaction_tracer
71
+ :'transaction_tracer.record_sql'
72
+ when :slow_sql
73
+ :'slow_sql.record_sql'
74
+ else
75
+ "#{config_section}.record_sql".to_sym
76
+ end
77
+ end
78
+
66
79
  RECORD_FOR = [:raw, :obfuscated].freeze
67
80
 
68
81
  def should_record_sql?(config_section=:transaction_tracer)
@@ -96,7 +109,7 @@ module NewRelic
96
109
 
97
110
  # Perform this in the runtime environment of a managed
98
111
  # application, to explain the sql statement executed within a
99
- # segment of a transaction sample. Returns an array of
112
+ # node of a transaction sample. Returns an array of
100
113
  # explanations (which is an array rows consisting of an array of
101
114
  # strings for each column returned by the the explain query)
102
115
  # Note this happens only for statements whose execution time
@@ -6,8 +6,16 @@ require 'new_relic/agent/datastores/metric_helper'
6
6
 
7
7
  module NewRelic
8
8
  module Agent
9
+ #
10
+ # This module contains helper methods to facilitate instrumentation of
11
+ # datastores not directly supported by the Ruby agent. It is intended to be
12
+ # primarily used by authors of 3rd-party datastore instrumentation.
13
+ #
14
+ # @api public
9
15
  module Datastores
10
16
 
17
+ # @!group Tracing query methods
18
+
11
19
  # Add Datastore tracing to a method. This properly generates the metrics
12
20
  # for New Relic's Datastore features. It does not capture the actual
13
21
  # query content into Transaction Traces. Use wrap if you want to provide
@@ -16,12 +24,12 @@ module NewRelic
16
24
  # @param [Class] clazz the class to instrument
17
25
  #
18
26
  # @param [String, Symbol] method_name the name of instance method to
19
- # instrument
27
+ # instrument
20
28
  #
21
29
  # @param [String] product name of your datastore for use in metric naming, e.g. "Redis"
22
30
  #
23
31
  # @param [optional,String] operation the name of operation if different
24
- # than the instrumented method name
32
+ # than the instrumented method name
25
33
  #
26
34
  # @api public
27
35
  #
@@ -62,33 +70,33 @@ module NewRelic
62
70
  # end
63
71
  #
64
72
  # @param [String] product the datastore name for use in metric naming,
65
- # e.g. "FauxDB"
73
+ # e.g. "FauxDB"
66
74
  #
67
75
  # @param [String,Symbol] operation the name of operation (e.g. "select"),
68
- # often named after the method that's being instrumented.
76
+ # often named after the method that's being instrumented.
69
77
  #
70
78
  # @param [optional, String] collection the collection name for use in
71
- # statement-level metrics (i.e. table or model name)
79
+ # statement-level metrics (i.e. table or model name)
72
80
  #
73
81
  # @param [Proc,#call] callback proc or other callable to invoke after
74
- # running the datastore block. Receives three arguments: result of the
75
- # yield, the most specific (scoped) metric name, and elapsed time of the
76
- # call. An example use is attaching SQL to Transaction Traces at the end
77
- # of a wrapped datastore call.
82
+ # running the datastore block. Receives three arguments: result of the
83
+ # yield, the most specific (scoped) metric name, and elapsed time of the
84
+ # call. An example use is attaching SQL to Transaction Traces at the end
85
+ # of a wrapped datastore call.
78
86
  #
79
- # callback = Proc.new do |result, metrics, elapsed|
80
- # NewRelic::Agent::Datastores.notice_sql(query, metrics, elapsed)
81
- # end
87
+ # callback = Proc.new do |result, metrics, elapsed|
88
+ # NewRelic::Agent::Datastores.notice_sql(query, metrics, elapsed)
89
+ # end
82
90
  #
83
- # NewRelic::Agent::Datastores.wrap("FauxDB", "find", "items", callback) do
84
- # FauxDB.find(query)
85
- # end
91
+ # NewRelic::Agent::Datastores.wrap("FauxDB", "find", "items", callback) do
92
+ # FauxDB.find(query)
93
+ # end
86
94
  #
87
- # **NOTE: THERE ARE SECURITY CONCERNS WHEN CAPTURING SQL!**
88
- # New Relic's Transaction Tracing and Slow SQL features will
89
- # attempt to apply obfuscation to the passed queries, but it is possible
90
- # for a query format to be unsupported and result in exposing user
91
- # information embedded within captured queries.
95
+ # @note THERE ARE SECURITY CONCERNS WHEN CAPTURING QUERY TEXT!
96
+ # New Relic's Transaction Tracing and Slow SQL features will
97
+ # attempt to apply obfuscation to the passed queries, but it is possible
98
+ # for a query format to be unsupported and result in exposing user
99
+ # information embedded within captured queries.
92
100
  #
93
101
  # @api public
94
102
  #
@@ -110,29 +118,33 @@ module NewRelic
110
118
  end
111
119
  end
112
120
 
121
+ # @!group Capturing query / statement text
122
+
113
123
  # Wrapper for simplifying attaching SQL queries during a transaction.
114
124
  #
115
- # If you are recording non-SQL data, please use the notice_statement
116
- # method instead.
125
+ # If you are recording non-SQL data, please use {notice_statement}
126
+ # instead.
117
127
  #
118
128
  # NewRelic::Agent::Datastores.notice_sql(query, metrics, elapsed)
119
129
  #
120
130
  # @param [String] query the SQL text to be captured. Note that depending
121
- # on user settings, this string will be run through obfuscation, but
122
- # some dialects of SQL (or non-SQL queries) are not guaranteed to be
123
- # properly obfuscated by these routines!
131
+ # on user settings, this string will be run through obfuscation, but
132
+ # some dialects of SQL (or non-SQL queries) are not guaranteed to be
133
+ # properly obfuscated by these routines!
124
134
  #
125
135
  # @param [String] scoped_metric The most specific metric relating to this
126
- # query. Typically the result of
127
- # NewRelic::Agent::Datastores::MetricHelper#metrics_for
136
+ # query. Typically the result of
137
+ # NewRelic::Agent::Datastores::MetricHelper#metrics_for
128
138
  #
129
139
  # @param [Float] elapsed the elapsed time during query execution
130
140
  #
131
- # **NOTE: THERE ARE SECURITY CONCERNS WHEN CAPTURING SQL!**
132
- # New Relic's Transaction Tracing and Slow SQL features will
133
- # attempt to apply obfuscation to the passed queries, but it is possible
134
- # for a query format to be unsupported and result in exposing user
135
- # information embedded within captured queries.
141
+ # @note THERE ARE SECURITY CONCERNS WHEN CAPTURING QUERY TEXT!
142
+ # New Relic's Transaction Tracing and Slow SQL features will
143
+ # attempt to apply obfuscation to the passed queries, but it is possible
144
+ # for a query format to be unsupported and result in exposing user
145
+ # information embedded within captured queries.
146
+ #
147
+ # @api public
136
148
  #
137
149
  def self.notice_sql(query, scoped_metric, elapsed)
138
150
  agent = NewRelic::Agent.instance
@@ -155,12 +167,14 @@ module NewRelic
155
167
  #
156
168
  # @param [Float] elapsed the elapsed time during query execution
157
169
  #
158
- # **NOTE: THERE ARE SECURITY CONCERNS WHEN CAPTURING STATEMENTS!**
159
- # This method will properly ignore statements when the user has turned
160
- # off capturing queries, but it is not able to obfuscate arbitrary data!
161
- # To prevent exposing user information embedded in captured queries,
162
- # please ensure all data passed to this method is safe to transmit to
163
- # New Relic.
170
+ # @note THERE ARE SECURITY CONCERNS WHEN CAPTURING STATEMENTS!
171
+ # This method will properly ignore statements when the user has turned
172
+ # off capturing queries, but it is not able to obfuscate arbitrary data!
173
+ # To prevent exposing user information embedded in captured queries,
174
+ # please ensure all data passed to this method is safe to transmit to
175
+ # New Relic.
176
+ #
177
+ # @api public
164
178
  #
165
179
  def self.notice_statement(statement, elapsed)
166
180
  # Settings may change eventually, but for now we follow the same