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
@@ -13,6 +13,7 @@ module NewRelic
13
13
  include NewRelic::Agent::MethodTracer
14
14
 
15
15
  def setup
16
+ NewRelic::Agent.drop_buffered_data
16
17
  NewRelic::Agent.manual_start
17
18
  NewRelic::Agent.reset_config
18
19
  NewRelic::Agent.instance.stubs(:start_worker_thread)
@@ -24,7 +25,7 @@ module NewRelic
24
25
 
25
26
  def test_shutdown
26
27
  mock_agent = mocked_agent
27
- mock_agent.expects(:shutdown).with({})
28
+ mock_agent.expects(:shutdown)
28
29
  NewRelic::Agent.shutdown
29
30
  end
30
31
 
@@ -39,23 +40,21 @@ module NewRelic
39
40
  NewRelic::Agent.manual_start(:monitor_mode => true, :license_key => "a" * 40)
40
41
  NewRelic::Agent.instance.service = default_service
41
42
  NewRelic::Agent.instance.finish_setup('agent_config' =>
42
- { :some_absurd_setting => true })
43
- assert NewRelic::Agent.config[:some_absurd_setting]
43
+ { 'data_report_period' => 10 })
44
+ assert_equal 10, NewRelic::Agent.config[:data_report_period]
44
45
  NewRelic::Agent.shutdown
45
- assert !NewRelic::Agent.config[:some_absurd_setting]
46
+ assert_equal 60, NewRelic::Agent.config[:data_report_period]
46
47
  end
47
48
 
48
49
  def test_finish_setup_applied_server_side_config
49
50
  with_config_low_priority({
50
51
  :'transction_tracer.enabled' => true,
51
- :'error_collector.enabled' => true,
52
- :log_level => 'info' }) do
53
- NewRelic::Agent.instance.finish_setup('log_level' => 'debug',
52
+ :'error_collector.enabled' => true }) do
53
+ NewRelic::Agent.instance.finish_setup(
54
54
  'agent_config' => { 'transaction_tracer.enabled' => false },
55
55
  'collect_errors' => false)
56
- assert !NewRelic::Agent.config[:'transaction_tracer.enabled']
57
- assert !NewRelic::Agent.config[:'error_collector.enabled']
58
- assert_equal 'debug', NewRelic::Agent.config[:log_level]
56
+ refute NewRelic::Agent.config[:'transaction_tracer.enabled']
57
+ refute NewRelic::Agent.config[:'error_collector.enabled']
59
58
  end
60
59
  end
61
60
 
@@ -332,7 +331,7 @@ module NewRelic
332
331
  Transactor.new.txn do
333
332
  NewRelic::Agent.set_transaction_name('new_name')
334
333
  end
335
- assert_equal 'Controller/new_name', sampler.last_sample.params[:path]
334
+ assert_equal 'Controller/new_name', sampler.last_sample.transaction_name
336
335
  end
337
336
 
338
337
  def test_set_transaction_name_gracefully_fails_when_frozen
@@ -395,12 +394,13 @@ module NewRelic
395
394
  assert called
396
395
  end
397
396
 
398
- # The assumption is that txn.ignore! works as expected, and is tested elsewhere.
399
397
  def test_ignore_transaction_works
400
398
  in_transaction do |txn|
401
399
  NewRelic::Agent.ignore_transaction
402
400
  assert txn.ignore?
403
401
  end
402
+
403
+ assert_empty NewRelic::Agent.instance.transaction_sampler.harvest!
404
404
  end
405
405
 
406
406
  # The assumption is that txn.ignore_apdex! works as expected, and is tested elsewhere.
@@ -419,6 +419,21 @@ module NewRelic
419
419
  end
420
420
  end
421
421
 
422
+ def test_add_custom_parameters_deprecated
423
+ NewRelic::Agent::Deprecator.expects(:deprecate)
424
+ NewRelic::Agent.add_custom_parameters(:is => "bunk")
425
+ end
426
+
427
+ def test_add_request_parameters_deprecated
428
+ NewRelic::Agent::Deprecator.expects(:deprecate)
429
+ NewRelic::Agent.add_request_parameters(:is => "bunk")
430
+ end
431
+
432
+ def test_set_user_attributes_deprecated
433
+ NewRelic::Agent::Deprecator.expects(:deprecate)
434
+ NewRelic::Agent.set_user_attributes(:is => "bunk")
435
+ end
436
+
422
437
  private
423
438
 
424
439
  def with_unstarted_agent
@@ -0,0 +1,27 @@
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
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
6
+ require 'new_relic/cli/command'
7
+ require 'new_relic/cli/commands/install'
8
+
9
+ class NewRelic::Cli::InstallTest < Minitest::Test
10
+ def test_fails_without_app_name
11
+ assert_raises(NewRelic::Cli::Command::CommandFailure) do
12
+ NewRelic::Cli::Install.new(["-l", "license"])
13
+ end
14
+ end
15
+
16
+ def test_basic_run
17
+ install = NewRelic::Cli::Install.new(["-l", "license", "app"])
18
+ assert_equal "license", install.license_key
19
+ assert_equal "app", install.app_name
20
+ end
21
+
22
+ def test_app_name_with_spaces
23
+ install = NewRelic::Cli::Install.new(["-l", "license", "my", "app"])
24
+ assert_equal "license", install.license_key
25
+ assert_equal "my app", install.app_name
26
+ end
27
+ end
@@ -89,65 +89,6 @@ class CoerceTest < Minitest::Test
89
89
  string(Unstringable.new, "HERE")
90
90
  end
91
91
 
92
- def test_event_params_coerce_returns_empty_hash_when_non_hash_is_passed
93
- assert_equal({}, event_params([]))
94
- assert_equal({}, event_params(''))
95
- assert_equal({}, event_params(1))
96
- assert_equal({}, event_params(nil))
97
- assert_equal({}, event_params(self.class))
98
- end
99
-
100
- def test_event_params_coerce_converts_hash_keys_to_strings
101
- assert_equal(
102
- {'foo' => 1, 'bar' => 2, '3' => 3},
103
- event_params({:foo => 1, 'bar' => 2, 3 => 3})
104
- )
105
- end
106
-
107
- def test_event_params_coerce_only_allow_values_that_are_strings_symbols_floats_or_ints_or_bools
108
- assert_equal(
109
- {
110
- 'foo' => 1.0,
111
- 'bar' => 2,
112
- 'bang' => 'woot',
113
- 'ok' => 'dokey',
114
- 'truthy' => true,
115
- 'falsy' => false
116
- },
117
- event_params(
118
- {
119
- 'foo' => 1.0,
120
- 'bar' => 2,
121
- 'bang' => 'woot',
122
- 'ok' => :dokey,
123
- 'bad' => [],
124
- 'worse' => {},
125
- 'nope' => Rational(1),
126
- 'truthy' => true,
127
- 'falsy' => false
128
- }
129
- )
130
- )
131
- end
132
-
133
- def test_event_params_turns_nan_or_infinity_into_null
134
- assert_equal(
135
- {
136
- 'nan' => nil,
137
- 'inf' => nil,
138
- 'ninf' => nil
139
- },
140
- event_params(
141
- {
142
- # Ruby 1.8.7 doesn't have Float::NAN, INFINITY so we have to hack it
143
- 'nan' => 0.0 / 0.0,
144
- 'inf' => 1.0 / 0.0,
145
- 'ninf' => -1.0 / 0.0
146
- }
147
- )
148
- )
149
- end
150
-
151
92
  class Unstringable
152
93
  undef :to_s
153
94
  end
@@ -46,12 +46,12 @@ module NewRelic
46
46
  end
47
47
 
48
48
  def test_calling_harvest_after_re_populating_works
49
- c = create_container
50
- populate_container(c, num_data_items)
51
- assert_equal(num_data_items, c.harvest!.size)
49
+ container = create_container
50
+ populate_container(container, num_data_items)
51
+ assert_equal(num_data_items, container.harvest!.size)
52
52
 
53
- populate_container(c, num_data_items)
54
- assert_equal(num_data_items, c.harvest!.size)
53
+ populate_container(container, num_data_items)
54
+ assert_equal(num_data_items, container.harvest!.size)
55
55
  end
56
56
  end
57
57
 
@@ -136,7 +136,7 @@ module NewRelic
136
136
 
137
137
  # Symbols remain in Ruby-marshalled data, so tidy up so tests can
138
138
  # rely on strings to compare against in fake collector results.
139
- body = NewRelic::JSONWrapper.normalize(body)
139
+ body = NewRelic::Agent::EncodingNormalizer.normalize_object(body)
140
140
  end
141
141
  rescue
142
142
  body = "UNABLE TO DECODE BODY: #{raw_body}"
@@ -297,19 +297,26 @@ module NewRelic
297
297
  def synthetics_resource_id
298
298
  @body[9]
299
299
  end
300
- end
301
300
 
302
- class SubmittedTransactionTraceTree
303
- def initialize(body, format)
304
- @body = body
301
+ def agent_attributes
302
+ tree.attributes['agentAttributes']
305
303
  end
306
304
 
307
- def request_params
308
- @body[1]
305
+ def custom_attributes
306
+ tree.attributes['userAttributes']
309
307
  end
310
308
 
311
- def custom_params
312
- @body[2]
309
+ def intrinsic_attributes
310
+ tree.attributes['intrinsics']
311
+ end
312
+ end
313
+
314
+ class SubmittedTransactionTraceTree
315
+ attr_reader :attributes
316
+
317
+ def initialize(body, format)
318
+ @body = body
319
+ @attributes = body[4]
313
320
  end
314
321
  end
315
322
 
@@ -374,6 +381,17 @@ module NewRelic
374
381
  @params = error_info[4]
375
382
  end
376
383
 
384
+ def agent_attributes
385
+ @params["agentAttributes"]
386
+ end
387
+
388
+ def custom_attributes
389
+ @params["userAttributes"]
390
+ end
391
+
392
+ def intrinsic_attributes
393
+ @params["intrinsics"]
394
+ end
377
395
  end
378
396
  end
379
397
 
@@ -12,7 +12,8 @@ class FilteringTestApp
12
12
  params = req.params
13
13
  filtered = ::NewRelic::Agent::ParameterFiltering.apply_filters(env, params)
14
14
  txn.filtered_params = filtered
15
+ txn.merge_request_parameters(filtered)
15
16
  raise "Intentional error" if params["raise"]
16
17
  [200, {}, ["Filters applied"]]
17
18
  end
18
- end
19
+ end
@@ -179,8 +179,8 @@ module HttpClientTestCases
179
179
  perform_action_with_newrelic_trace(:name => "task") do
180
180
  get_response
181
181
 
182
- last_segment = find_last_transaction_segment()
183
- assert_equal "External/localhost/#{client_name}/GET", last_segment.metric_name
182
+ last_node = find_last_transaction_node()
183
+ assert_equal "External/localhost/#{client_name}/GET", last_node.metric_name
184
184
  end
185
185
  end
186
186
 
@@ -316,9 +316,9 @@ module HttpClientTestCases
316
316
  in_transaction("test") do
317
317
  get_response
318
318
 
319
- last_segment = find_last_transaction_segment()
320
- assert_includes last_segment.params.keys, :transaction_guid
321
- assert_equal TRANSACTION_GUID, last_segment.params[:transaction_guid]
319
+ last_node = find_last_transaction_node()
320
+ assert_includes last_node.params.keys, :transaction_guid
321
+ assert_equal TRANSACTION_GUID, last_node.params[:transaction_guid]
322
322
  end
323
323
  end
324
324
 
@@ -340,9 +340,9 @@ module HttpClientTestCases
340
340
  in_transaction("test") do
341
341
  get_response
342
342
 
343
- last_segment = find_last_transaction_segment()
344
- assert_includes last_segment.params.keys, :transaction_guid
345
- assert_equal TRANSACTION_GUID, last_segment.params[:transaction_guid]
343
+ last_node = find_last_transaction_node()
344
+ assert_includes last_node.params.keys, :transaction_guid
345
+ assert_equal TRANSACTION_GUID, last_node.params[:transaction_guid]
346
346
  end
347
347
  end
348
348
 
@@ -404,7 +404,7 @@ module HttpClientTestCases
404
404
  get_response
405
405
  end
406
406
 
407
- refute_match( /undefined method `rename_scope_segment" for nil:NilClass/i,
407
+ refute_match( /undefined method `.*" for nil:NilClass/i,
408
408
  logger.messages.flatten.map {|log| log.to_s }.join(" ") )
409
409
  end
410
410
 
@@ -412,9 +412,9 @@ module HttpClientTestCases
412
412
  full_url = "#{default_url}?foo=bar#fragment"
413
413
  in_transaction do
414
414
  get_response(full_url)
415
- last_segment = find_last_transaction_segment()
415
+ last_node = find_last_transaction_node()
416
416
  filtered_uri = default_url
417
- assert_equal filtered_uri, last_segment.params[:uri]
417
+ assert_equal filtered_uri, last_node.params[:uri]
418
418
  end
419
419
  end
420
420
 
@@ -431,7 +431,7 @@ module HttpClientTestCases
431
431
  end
432
432
 
433
433
  # https://newrelic.atlassian.net/browse/RUBY-1244
434
- def test_failure_to_add_tt_node_doesnt_append_params_to_wrong_segment
434
+ def test_failure_to_add_tt_node_doesnt_append_params_to_wrong_node
435
435
  # Fake a failure in our start-up code...
436
436
  NewRelic::JSONWrapper.stubs(:dump).raises("Boom!")
437
437
 
@@ -439,8 +439,8 @@ module HttpClientTestCases
439
439
  with_config(:"cross_application_tracer.enabled" => true) do
440
440
  get_response
441
441
 
442
- last_segment = find_last_transaction_segment()
443
- refute last_segment.params.key?(:uri)
442
+ last_node = find_last_transaction_node()
443
+ refute last_node.params.key?(:uri)
444
444
  end
445
445
  end
446
446
  end
@@ -466,8 +466,8 @@ module HttpClientTestCases
466
466
  # across all libraries
467
467
  end
468
468
 
469
- last_segment = find_last_transaction_segment()
470
- assert_equal("External/localhost/#{client_name}/GET", last_segment.metric_name)
469
+ last_node = find_last_transaction_node()
470
+ assert_equal("External/localhost/#{client_name}/GET", last_node.metric_name)
471
471
  end
472
472
 
473
473
  evil_server.stop
@@ -20,61 +20,7 @@ class JSONWrapperTest < Minitest::Test
20
20
  assert(obj == copy)
21
21
  end
22
22
 
23
- def test_normalize_converts_symbol_values_to_strings
24
- result = NewRelic::JSONWrapper.normalize([:foo, :bar])
25
- assert_equal(['foo', 'bar'], result)
26
- end
27
-
28
- def test_normalize_converts_symbols_in_hash_to_strings
29
- result = NewRelic::JSONWrapper.normalize({:key => :value})
30
- assert_equal({'key' => 'value'}, result)
31
- end
32
-
33
23
  if NewRelic::LanguageSupport.supports_string_encodings?
34
- def test_normalize_string_returns_input_if_correctly_encoded_utf8
35
- string = "i want a pony"
36
- result = NewRelic::JSONWrapper.normalize_string(string)
37
- assert_same(string, result)
38
- assert_equal(Encoding.find('UTF-8'), result.encoding)
39
- end
40
-
41
- def test_normalize_string_returns_munged_copy_if_ascii_8bit
42
- string = (0..255).to_a.pack("C*")
43
- result = NewRelic::JSONWrapper.normalize_string(string)
44
- refute_same(string, result)
45
- assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
46
- assert_equal(string, result.dup.force_encoding('ASCII-8BIT'))
47
- end
48
-
49
- def test_normalize_string_returns_munged_copy_if_invalid_utf8
50
- string = (0..255).to_a.pack("C*").force_encoding('UTF-8')
51
- result = NewRelic::JSONWrapper.normalize_string(string)
52
- refute_same(result, string)
53
- assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
54
- assert_equal(string, result.dup.force_encoding('UTF-8'))
55
- end
56
-
57
- def test_normalize_string_returns_munged_copy_if_other_convertible_encoding
58
- string = "i want a pony".encode('UTF-16LE')
59
- result = NewRelic::JSONWrapper.normalize_string(string)
60
- refute_same(result, string)
61
- assert_equal(Encoding.find('UTF-8'), result.encoding)
62
- assert_equal(string, result.encode('UTF-16LE'))
63
- end
64
-
65
- def test_normalize_string_returns_munged_copy_if_other_non_convertible_enocding
66
- # Attempting to convert from UTF-7 to UTF-8 in Ruby will raise an
67
- # Encoding::ConverterNotFoundError, which is what we're trying to
68
- # replicate for this test case.
69
- # The following UTF-7 string decodes to 'Jyväskylä', a city in Finland
70
- string = "Jyv+AOQ-skyl+AOQ-".force_encoding("UTF-7")
71
- assert string.valid_encoding?
72
- result = NewRelic::JSONWrapper.normalize_string(string)
73
- refute_same(result, string)
74
- assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
75
- assert_equal('Jyv+AOQ-skyl+AOQ-'.force_encoding('ISO-8859-1'), result)
76
- end
77
-
78
24
  def test_normalizes_string_encodings_if_asked
79
25
  string = (0..255).to_a.pack("C*")
80
26
  encoded = NewRelic::JSONWrapper.dump([string], :normalize => true)
@@ -66,6 +66,7 @@ module MarshallingTestCases
66
66
  "name" => "TestTransaction/do_it",
67
67
  "duration" => 0.0,
68
68
  },
69
+ {},
69
70
  {}
70
71
  ]
71
72
 
@@ -50,6 +50,10 @@ module MultiverseHelpers
50
50
  # test cases have the chance to change settings on the fake collector first
51
51
  start_fake_collector unless omit_collector?
52
52
 
53
+ # If a test not using the multiverse helper runs before us, we might need
54
+ # to clean up before a test too.
55
+ NewRelic::Agent.drop_buffered_data
56
+
53
57
  trigger_agent_reconnect(opts)
54
58
  end
55
59
 
@@ -123,5 +127,145 @@ module MultiverseHelpers
123
127
  ENV["NEWRELIC_OMIT_FAKE_COLLECTOR"] == "true"
124
128
  end
125
129
 
130
+ def run_harvest
131
+ NewRelic::Agent.instance.send(:transmit_data)
132
+ NewRelic::Agent.instance.send(:transmit_event_data)
133
+ end
134
+
135
+ def single_transaction_trace_posted
136
+ posts = $collector.calls_for("transaction_sample_data")
137
+ assert_equal 1, posts.length, "Unexpected post count"
138
+
139
+ transactions = posts.first.samples
140
+ assert_equal 1, transactions.length, "Unexpected trace count"
141
+
142
+ transactions.first
143
+ end
144
+
145
+ def single_error_posted
146
+ assert_equal 1, $collector.calls_for("error_data").length
147
+ assert_equal 1, $collector.calls_for("error_data").first.errors.length
148
+
149
+ $collector.calls_for("error_data").first.errors.first
150
+ end
151
+
152
+ def single_event_posted
153
+ assert_equal 1, $collector.calls_for("analytic_event_data").length
154
+ assert_equal 1, $collector.calls_for("analytic_event_data").first.events.length
155
+
156
+ $collector.calls_for("analytic_event_data").first.events.first
157
+ end
158
+
159
+ def capture_js_data
160
+ state = NewRelic::Agent::TransactionState.tl_get
161
+ events = stub(:subscribe => nil)
162
+ @instrumentor = NewRelic::Agent::JavascriptInstrumentor.new(events)
163
+ @js_data = @instrumentor.data_for_js_agent(state)
164
+
165
+ raw_attributes = @js_data["atts"]
166
+
167
+ if raw_attributes
168
+ attributes = NewRelic::JSONWrapper.load @instrumentor.obfuscator.deobfuscate(raw_attributes)
169
+ @js_custom_attributes = attributes['u']
170
+ @js_agent_attributes = attributes['a']
171
+ end
172
+ end
173
+
174
+ def assert_transaction_trace_has_agent_attribute(attribute, expected)
175
+ actual = single_transaction_trace_posted.agent_attributes[attribute]
176
+ assert_equal expected, actual
177
+ end
178
+
179
+ def assert_event_has_agent_attribute(attribute, expected)
180
+ assert_equal expected, single_event_posted.last[attribute]
181
+ end
182
+
183
+ def assert_error_has_agent_attribute(attribute, expected)
184
+ assert_equal expected, single_error_posted.params["agentAttributes"][attribute]
185
+ end
186
+
187
+ def assert_transaction_tracer_has_custom_attributes(attribute, expected)
188
+ actual = single_transaction_trace_posted.custom_attributes[attribute]
189
+ assert_equal expected, actual
190
+ end
191
+
192
+ def assert_transaction_event_has_custom_attributes(attribute, expected)
193
+ assert_equal expected, single_event_posted[1][attribute]
194
+ end
195
+
196
+ def assert_error_collector_has_custom_attributes(attribute, expected)
197
+ assert_equal expected, single_error_posted.params["userAttributes"][attribute]
198
+ end
199
+
200
+ def assert_browser_monitoring_has_custom_attributes(attribute, expected)
201
+ assert_equal expected, @js_custom_attributes[attribute]
202
+ end
203
+
204
+ def assert_browser_monitoring_has_agent_attribute(attribute, expected)
205
+ assert_equal expected, @js_agent_attributes[attribute]
206
+ end
207
+
208
+ def refute_transaction_tracer_has_custom_attributes(attribute)
209
+ refute_includes single_transaction_trace_posted.custom_attributes, attribute
210
+ end
211
+
212
+ def refute_transaction_event_has_custom_attributes(attribute)
213
+ refute_includes single_event_posted[1], attribute
214
+ end
215
+
216
+ def refute_error_collector_has_custom_attributes(attribute)
217
+ refute_includes single_error_posted.params["userAttributes"], attribute
218
+ end
219
+
220
+ def refute_browser_monitoring_has_custom_attributes(_)
221
+ assert_nil @js_custom_attributes
222
+ end
223
+
224
+ def refute_transaction_trace_has_agent_attribute(attribute)
225
+ refute_includes single_transaction_trace_posted.agent_attributes, attribute
226
+ end
227
+
228
+ def refute_event_has_agent_attribute(attribute)
229
+ refute_includes single_event_posted.last, attribute
230
+ end
231
+
232
+ def refute_error_has_agent_attribute(attribute)
233
+ refute_includes single_error_posted.params["agentAttributes"], attribute
234
+ end
235
+
236
+ def refute_browser_monitoring_has_any_attributes
237
+ refute_includes @js_data, "atts"
238
+ end
239
+
240
+ def refute_browser_monitoring_has_agent_attribute(_)
241
+ assert_nil @js_agent_attributes
242
+ end
243
+
244
+ def attributes_for_single_error_posted(key)
245
+ run_harvest
246
+ single_error_posted.params[key]
247
+ end
248
+
249
+ def user_attributes_for_single_error_posted
250
+ attributes_for_single_error_posted("userAttributes")
251
+ end
252
+
253
+ def agent_attributes_for_single_error_posted
254
+ attributes_for_single_error_posted("agentAttributes")
255
+ end
256
+
257
+ def agent_attributes_for_single_event_posted
258
+ run_harvest
259
+ single_event_posted[2]
260
+ end
261
+
262
+ def agent_attributes_for_single_event_posted_without_ignored_attributes
263
+ ignored_keys = ["httpResponseCode", "request.headers.referer",
264
+ "request.parameters.controller", "request.parameters.action"]
265
+ attrs = agent_attributes_for_single_event_posted
266
+ ignored_keys.each { |k| attrs.delete(k) }
267
+ attrs
268
+ end
269
+
126
270
  extend self
127
271
  end