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
@@ -1,25 +0,0 @@
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 'new_relic/transaction_sample'
6
- require 'new_relic/transaction_sample/segment'
7
- module NewRelic
8
- class TransactionSample
9
- class SummarySegment < Segment
10
- def initialize(segment)
11
- super segment.entry_timestamp, segment.metric_name
12
-
13
- add_segments segment.called_segments
14
-
15
- end_trace segment.exit_timestamp
16
- end
17
-
18
- def add_segments(segments)
19
- segments.collect do |segment|
20
- SummarySegment.new(segment)
21
- end.each {|segment| add_called_segment(segment)}
22
- end
23
- end
24
- end
25
- end
@@ -1,18 +0,0 @@
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
- # Represents url mapping rules stored on the server. These rules should be applied
6
- # to URLs which are not normalized into controller class/action by Rails routes.
7
- # Insantiated strictly by Marshal.
8
- class NewRelic::UrlRule
9
- attr_reader :match_expression, :replacement, :eval_order, :terminate_chain
10
-
11
- def apply url
12
- return nil
13
- end
14
-
15
- class RuleSet
16
-
17
- end
18
- end
@@ -1 +0,0 @@
1
- SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?
@@ -1 +0,0 @@
1
- SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3="othervalue" LIMIT ?
@@ -1 +0,0 @@
1
- SELECT * FROM t WHERE foo="bar/*" AND baz="whatever */qux"
@@ -1 +0,0 @@
1
- SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = ? AND c3=? LIMIT ?
@@ -1 +0,0 @@
1
- SELECT "t001"."c2" FROM "t001" WHERE "t001"."c2" = 'value' AND c3=1234 LIMIT 1
@@ -1,2 +0,0 @@
1
- SELECT * FROM t WHERE foo=? AND
2
- baz=?
@@ -1,2 +0,0 @@
1
- SELECT * FROM t WHERE foo="bar--" AND
2
- baz="qux--"
@@ -1 +0,0 @@
1
- SELECT * FROM foo WHERE bar='baz' /* Hide Me */
@@ -1,2 +0,0 @@
1
- SELECT * FROM foobar WHERE password=?
2
- ?
@@ -1,2 +0,0 @@
1
- SELECT * FROM foobar WHERE password='hunter2'
2
- -- No peeking!
@@ -1 +0,0 @@
1
- SELECT foo, bar FROM baz WHERE password=? ?
@@ -1 +0,0 @@
1
- SELECT foo, bar FROM baz WHERE password='hunter2' # Secret
@@ -1 +0,0 @@
1
- SELECT "col1", "col2" from "table" WHERE "col3"=E? AND country=e?
@@ -1,4 +0,0 @@
1
- # PostgreSQL supports an alternate string quoting mode where backslash escape
2
- # sequences are interpreted.
3
- # See: http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE
4
- SELECT "col1", "col2" from "table" WHERE "col3"=E'foo\'bar\\baz' AND country=e'foo\'bar\\baz'
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE foo='bar' AND baz="nothing to see here'
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here
@@ -1 +0,0 @@
1
- INSERT INTO `X` values("test",0, 1 , 2, 'test')
@@ -1 +0,0 @@
1
- SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?
@@ -1 +0,0 @@
1
- SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'
@@ -1 +0,0 @@
1
- INSERT INTO X VALUES(?, ?, ?.?, ?+?)
@@ -1 +0,0 @@
1
- INSERT INTO X VALUES(1, 23456, 123.456, 99+100)
@@ -1,4 +0,0 @@
1
- # Pathological SQL Obfuscation Test Cases
2
-
3
- ## Why are these pathological?
4
- Because obfuscating dialect-specific SQL is difficult without building a comprehensive lexer, so there are some edge cases where agents are expected to err on the side of over-obfuscation, even though the resulting obfuscation differs from how a perfect lexer might parse and obfuscate it.
@@ -1,2 +0,0 @@
1
- SELECT * FROM t WHERE /* ' */
2
- bar='baz' -- '
@@ -1,4 +0,0 @@
1
- SELECT * FROM t WHERE -- '
2
- /* ' */ c2='xxx' /* ' */
3
- c='x
4
- xx' -- '
@@ -1 +0,0 @@
1
- SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name=? AND value=?
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name="foo" AND value="don't"
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name=? AND value = ?
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name='foo' AND value = 'bar'
@@ -1,4 +0,0 @@
1
- # If backslashes are being ignored in single-quoted strings
2
- # (standard_conforming_strings=on in PostgreSQL, or NO_BACKSLASH_ESCAPES is on
3
- # in MySQL), then this is valid SQL.
4
- SELECT * FROM table WHERE col='foo\''bar'
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE col1=? AND col2=?
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE col1='foo"bar' AND col2='what"ever'
@@ -1 +0,0 @@
1
- select * from accounts where accounts.name != ? order by accounts.name
@@ -1,2 +0,0 @@
1
- select * from accounts where accounts.name != 'dude
2
- newline' order by accounts.name
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE col1="don't" AND col2="won't"
@@ -1 +0,0 @@
1
- INSERT INTO X values(?, ?,?, ? , ?, ?, ?)
@@ -1 +0,0 @@
1
- INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', """jim''s"" hat", "\"jim''s secret\"")
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name=? AND color=?
@@ -1,4 +0,0 @@
1
- # If backslashes are being ignored in single-quoted strings
2
- # (standard_conforming_strings=on in PostgreSQL, or NO_BACKSLASH_ESCAPES is on
3
- # in MySQL), then this is valid SQL.
4
- SELECT * FROM table WHERE name='foo\' AND color='blue'
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE foo="this string ends with a backslash\\"
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE foo='this string ends with a backslash\\'
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name=? AND color=?
@@ -1 +0,0 @@
1
- SELECT * FROM table WHERE name='foo\'' AND color='blue'
@@ -1 +0,0 @@
1
- INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')
@@ -1,261 +0,0 @@
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
- class NewRelic::Agent::ErrorCollector::NoticeErrorTest < Minitest::Test
7
- require 'new_relic/agent/error_collector'
8
- include NewRelic::Agent::ErrorCollector::NoticeError
9
-
10
- def test_error_params_from_options_mocked
11
- options = {:initial => 'options'}
12
- self.expects(:uri_ref_and_root).returns({:hi => 'there', :hello => 'bad'})
13
- self.expects(:normalized_request_and_custom_params).with({:initial => 'options'}).returns({:hello => 'world'})
14
- assert_equal({:hi => 'there', :hello => 'world'}, error_params_from_options(options))
15
- end
16
-
17
- module Winner
18
- def winner
19
- 'yay'
20
- end
21
- end
22
-
23
- def test_sense_method
24
- object = Object.new
25
- object.extend(Winner)
26
- assert !sense_method(object, 'blab')
27
- assert_equal 'yay', sense_method(object, 'winner')
28
- end
29
-
30
- def test_fetch_from_options
31
- options = {:hello => 'world'}
32
- assert_equal 'world', fetch_from_options(options, :hello, '')
33
- assert_equal '', fetch_from_options(options, :none, '')
34
- assert_equal({}, options)
35
- end
36
-
37
- def test_uri_ref_and_root_default
38
- fake_control = mocked_control
39
- fake_control.expects(:root).returns('rootbeer')
40
- options = {}
41
- assert_equal({:request_referer => '', :rails_root => 'rootbeer', :request_uri => ''}, uri_ref_and_root(options))
42
- end
43
-
44
- def test_uri_ref_and_root_values
45
- fake_control = mocked_control
46
- fake_control.expects(:root).returns('rootbeer')
47
- options = {:uri => 'whee', :referer => 'bang'}
48
- assert_equal({:request_referer => 'bang', :rails_root => 'rootbeer', :request_uri => 'whee'}, uri_ref_and_root(options))
49
- end
50
-
51
- def test_custom_params_from_opts_base
52
- assert_equal({}, custom_params_from_opts({}))
53
- end
54
-
55
- def test_custom_params_from_opts_custom_params
56
- assert_equal({:foo => 'bar'}, custom_params_from_opts({:custom_params => {:foo => 'bar'}}))
57
- end
58
-
59
- def test_custom_params_from_opts_merged_params
60
- assert_equal({:foo => 'baz'}, custom_params_from_opts({:custom_params => {:foo => 'bar'}, :foo => 'baz'}))
61
- end
62
-
63
- def test_request_params_from_opts_positive
64
- with_config(:capture_params => true) do
65
- val = {:request_params => 'foo'}
66
- assert_equal('foo', request_params_from_opts(val))
67
- assert_equal({}, val, "should delete request_params key from hash")
68
- end
69
- end
70
-
71
- def test_request_params_from_opts_negative
72
- with_config(:capture_params => false) do
73
- val = {:request_params => 'foo'}
74
- assert_equal(nil, request_params_from_opts(val))
75
- assert_equal({}, val, "should delete request_params key from hash")
76
- end
77
- end
78
-
79
- def test_normalized_request_and_custom_params_base
80
- self.expects(:normalize_params).with(nil).returns(nil)
81
- self.expects(:normalize_params).with({}).returns({})
82
- with_config(:capture_params => true) do
83
- assert_equal({:request_params => nil, :custom_params => {}},
84
- normalized_request_and_custom_params({}))
85
- end
86
- end
87
-
88
- def test_extract_stack_trace
89
- exception = mock('exception')
90
- self.expects(:sense_method).with(exception, 'original_exception')
91
- self.expects(:sense_method).with(exception, 'backtrace')
92
- assert_equal('<no stack trace>', extract_stack_trace(exception))
93
- end
94
-
95
- def test_extract_stack_trace_positive
96
- orig = mock('original')
97
- exception = mock('exception')
98
- self.expects(:sense_method).with(exception, 'original_exception').returns(orig)
99
- self.expects(:sense_method).with(orig, 'backtrace').returns('STACK STACK STACK')
100
- assert_equal('STACK STACK STACK', extract_stack_trace(exception))
101
- end
102
-
103
- def test_over_queue_limit_negative
104
- @errors = []
105
- assert !over_queue_limit?(nil)
106
- end
107
-
108
- def test_over_queue_limit_positive
109
- @errors = (1..21).map{|_| NewRelic::NoticedError.new("", {}, nil)}
110
- expects_logging(:warn, includes('The error reporting queue has reached 20'))
111
- assert over_queue_limit?('hooray')
112
- end
113
-
114
- def test_exception_info
115
- exception = mock('exception')
116
- self.expects(:sense_method).with(exception, 'file_name').returns('file_name')
117
- self.expects(:sense_method).with(exception, 'line_number').returns('line_number')
118
- self.expects(:extract_stack_trace).with(exception).returns('stack_trace')
119
- assert_equal({:file_name => 'file_name', :line_number => 'line_number', :stack_trace => 'stack_trace'},
120
- exception_info(exception))
121
- end
122
-
123
- def test_add_to_error_queue_positive
124
- noticed_error = mock('noticed_error')
125
- noticed_error.expects(:message).returns('a message')
126
- @lock = Mutex.new
127
- @errors = []
128
- self.expects(:over_queue_limit?).with('a message').returns(false)
129
- add_to_error_queue(noticed_error)
130
- assert_equal([noticed_error], @errors)
131
- end
132
-
133
- def test_add_to_error_queue_negative
134
- noticed_error = mock('noticed_error')
135
- noticed_error.expects(:message).returns('a message')
136
- @lock = Mutex.new
137
- @errors = []
138
- self.expects(:over_queue_limit?).with('a message').returns(true)
139
- add_to_error_queue(noticed_error)
140
- assert_equal([], @errors)
141
- end
142
-
143
- def test_skip_notice_error_is_true_if_the_error_collector_is_disabled
144
- error = mocked_error
145
- with_error_collector_config(:'error_collector.enabled' => false) do |error_collector|
146
- assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
147
- end
148
- end
149
-
150
- def test_skip_notice_error_is_true_if_the_error_is_nil
151
- error = nil
152
- with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
153
- error_collector.expects(:error_is_ignored?).with(error).returns(false)
154
- assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
155
- end
156
- end
157
-
158
- def test_skip_notice_error_is_true_if_the_error_is_ignored
159
- error = mocked_error
160
- with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
161
- error_collector.expects(:error_is_ignored?).with(error).returns(true)
162
- assert error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
163
- end
164
- end
165
-
166
- def test_skip_notice_error_returns_false_for_non_nil_unignored_errors_with_an_enabled_error_collector
167
- error = mocked_error
168
- with_error_collector_config(:'error_collector.enabled' => true) do |error_collector|
169
- error_collector.expects(:error_is_ignored?).with(error).returns(false)
170
- assert !error_collector.skip_notice_error?(NewRelic::Agent::TransactionState.tl_get, error)
171
- end
172
- end
173
-
174
- def test_filtered_error_positive
175
- with_error_collector_config(:'error_collector.ignore_errors' => 'an_error') do |error_collector|
176
- error = mocked_error
177
- error_class = mock('error class')
178
- error.expects(:class).returns(error_class)
179
- error_class.expects(:name).returns('an_error')
180
- assert error_collector.filtered_error?(error)
181
- end
182
- end
183
-
184
- def test_filtered_error_negative
185
- error = mocked_error
186
- error_class = mock('error class')
187
- error.expects(:class).returns(error_class)
188
- error_class.expects(:name).returns('an_error')
189
- assert !NewRelic::Agent::ErrorCollector.new.filtered_error?(error)
190
- end
191
-
192
- def test_filtered_by_error_filter_empty
193
- # should return right away when there's no filter
194
- assert !filtered_by_error_filter?(nil)
195
- end
196
-
197
- def test_filtered_by_error_filter_positive
198
- error = mocked_error
199
- self.class.class_eval do
200
- define_method(:ignore_filter_proc) do |e|
201
- assert_equal(error, e)
202
- false
203
- end
204
- end
205
- assert filtered_by_error_filter?(error)
206
- ensure
207
- self.class.class_eval { undef :ignore_filter_proc }
208
- end
209
-
210
- def test_filtered_by_error_filter_negative
211
- error = mocked_error
212
- self.class.class_eval do
213
- define_method(:ignore_filter_proc) do |e|
214
- assert_equal(error, e)
215
- true
216
- end
217
- end
218
- assert !filtered_by_error_filter?(error)
219
- ensure
220
- self.class.class_eval { undef :ignore_filter_proc }
221
- end
222
-
223
- def test_error_is_ignored_positive
224
- error = mocked_error
225
- self.expects(:filtered_error?).with(error).returns(true)
226
- assert error_is_ignored?(error)
227
- end
228
-
229
- def test_error_is_ignored_negative
230
- error = mocked_error
231
- self.expects(:filtered_error?).with(error).returns(false)
232
- assert !error_is_ignored?(error)
233
- end
234
-
235
- def test_error_is_ignored_no_error
236
- assert !error_is_ignored?(nil), 'should not ignore nil'
237
- end
238
-
239
- private
240
-
241
- def mocked_error
242
- mock('error')
243
- end
244
-
245
- def mocked_control
246
- fake_control = mock('control')
247
- NewRelic::Control.stubs(:instance).returns(fake_control)
248
- fake_control
249
- end
250
-
251
- def with_error_collector_config(config)
252
- with_config(config) do
253
- yield NewRelic::Agent::ErrorCollector.new
254
- end
255
- end
256
-
257
- def ignore_error_filter
258
- @ignore_filter
259
- end
260
-
261
- end