Permalink
Browse files

Merge pull request #1599 from ruby-agent/dev

Ruby Agent 4.5.0 RC1
  • Loading branch information...
2 parents be18f0d + 948143a commit 2bc79e102185861ff078fd15ccbf31a32f088b8a @kenichi kenichi committed with GitHub Enterprise Sep 22, 2017
Showing with 731 additions and 92 deletions.
  1. +25 −25 .travis.yml
  2. +38 −0 CHANGELOG.md
  3. +41 −9 lib/new_relic/agent.rb
  4. +9 −3 lib/new_relic/agent/agent.rb
  5. +1 −7 lib/new_relic/agent/cross_app_tracing.rb
  6. +2 −1 lib/new_relic/agent/database.rb
  7. +10 −2 lib/new_relic/agent/datastores.rb
  8. +4 −0 lib/new_relic/agent/instrumentation/active_job.rb
  9. +1 −1 lib/new_relic/agent/instrumentation/active_record.rb
  10. +2 −0 lib/new_relic/agent/instrumentation/active_record_4.rb
  11. +3 −0 lib/new_relic/agent/instrumentation/active_record_5.rb
  12. +1 −1 lib/new_relic/agent/instrumentation/active_record_subscriber.rb
  13. +6 −0 lib/new_relic/agent/instrumentation/controller_instrumentation.rb
  14. +1 −1 lib/new_relic/agent/instrumentation/curb.rb
  15. +1 −1 lib/new_relic/agent/instrumentation/data_mapper.rb
  16. +1 −1 lib/new_relic/agent/instrumentation/excon/connection.rb
  17. +1 −1 lib/new_relic/agent/instrumentation/excon/middleware.rb
  18. +1 −1 lib/new_relic/agent/instrumentation/httpclient.rb
  19. +1 −1 lib/new_relic/agent/instrumentation/memcache.rb
  20. +2 −2 lib/new_relic/agent/instrumentation/memcache/dalli.rb
  21. +1 −1 lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb
  22. +3 −0 lib/new_relic/agent/instrumentation/rails4/action_controller.rb
  23. +2 −0 lib/new_relic/agent/instrumentation/rails4/action_view.rb
  24. +3 −0 lib/new_relic/agent/instrumentation/rails5/action_cable.rb
  25. +3 −0 lib/new_relic/agent/instrumentation/rails5/action_controller.rb
  26. +3 −1 lib/new_relic/agent/instrumentation/rails5/action_view.rb
  27. +3 −3 lib/new_relic/agent/instrumentation/redis.rb
  28. +1 −1 lib/new_relic/agent/instrumentation/typhoeus.rb
  29. +4 −0 lib/new_relic/agent/method_tracer.rb
  30. +1 −1 lib/new_relic/agent/method_tracer_helpers.rb
  31. +16 −0 lib/new_relic/agent/prepend_supportability.rb
  32. +2 −0 lib/new_relic/agent/transaction.rb
  33. +12 −3 lib/new_relic/agent/transaction/external_request_segment.rb
  34. +63 −0 lib/new_relic/supportability_helper.rb
  35. +1 −1 lib/new_relic/version.rb
  36. +1 −1 lib/sequel/extensions/newrelic_instrumentation.rb
  37. +1 −1 lib/sequel/plugins/newrelic_instrumentation.rb
  38. +5 −2 test/multiverse/suites/active_record/active_record_test.rb
  39. +1 −0 test/multiverse/suites/agent_only/utilization_data_collection_test.rb
  40. +1 −0 test/multiverse/suites/grape/Envfile
  41. +2 −1 test/multiverse/suites/mongo/mongo2_instrumentation_test.rb
  42. +1 −1 test/multiverse/suites/rabbitmq/bunny_test.rb
  43. +2 −0 test/multiverse/suites/rack/builder_map_test.rb
  44. +2 −1 test/multiverse/suites/rack/rack_auto_instrumentation_test.rb
  45. +2 −0 test/multiverse/suites/rack/url_map_test.rb
  46. +44 −0 test/multiverse/suites/rails_prepend/Envfile
  47. +43 −0 test/multiverse/suites/rails_prepend/newrelic_prepender/lib/newrelic_prepender.rb
  48. +7 −0 test/multiverse/suites/rails_prepend/newrelic_prepender/lib/newrelic_prepender/version.rb
  49. +16 −0 test/multiverse/suites/rails_prepend/newrelic_prepender/newrelic_prepender.gemspec
  50. +63 −0 test/multiverse/suites/rails_prepend/prepended_supportability_test.rb
  51. +1 −1 test/multiverse/suites/sinatra/ignoring_test.rb
  52. +1 −1 test/new_relic/agent/cross_app_monitor_test.rb
  53. +6 −0 test/new_relic/agent/database_test.rb
  54. +1 −0 test/new_relic/agent/instrumentation/task_instrumentation_test.rb
  55. +11 −5 test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb
  56. +1 −1 test/new_relic/agent/method_tracer_test.rb
  57. +4 −1 test/new_relic/agent/stats_engine_test.rb
  58. +202 −0 test/new_relic/agent/supportability_test.rb
  59. +10 −3 test/new_relic/agent/transaction/segment_test.rb
  60. +1 −0 test/new_relic/agent/transaction_test.rb
  61. +18 −3 test/new_relic/agent_test.rb
  62. +1 −1 test/new_relic/fake_server.rb
  63. +13 −0 test/new_relic/http_client_test_cases.rb
  64. +1 −1 test/new_relic/multiverse_helpers.rb
View
@@ -32,10 +32,10 @@ notifications:
rvm:
# Run slowest builds first to try and optimize overall cycle time.
- - jruby-9.1.12.0
- - 2.4.1
- - 2.3.4
- - 2.2.7
+ - jruby-9.1.13.0
+ - 2.4.2
+ - 2.3.5
+ - 2.2.8
- 2.1.10
- 2.0.0-p648
@@ -81,39 +81,39 @@ matrix:
exclude:
# Unsupported Rails/Ruby combinations
# 2.4
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails21
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails22
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails23
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails30
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails31
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails32
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails40
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails41
- - rvm: 2.4.1
+ - rvm: 2.4.2
env: TYPE=UNIT ENVIRONMENT=rails42
# 2.3
- - rvm: 2.3.4
+ - rvm: 2.3.5
env: TYPE=UNIT ENVIRONMENT=rails21
- - rvm: 2.3.4
+ - rvm: 2.3.5
env: TYPE=UNIT ENVIRONMENT=rails22
- - rvm: 2.3.4
+ - rvm: 2.3.5
env: TYPE=UNIT ENVIRONMENT=rails23
# 2.2
- - rvm: 2.2.7
+ - rvm: 2.2.8
env: TYPE=UNIT ENVIRONMENT=rails21
- - rvm: 2.2.7
+ - rvm: 2.2.8
env: TYPE=UNIT ENVIRONMENT=rails22
- - rvm: 2.2.7
+ - rvm: 2.2.8
env: TYPE=UNIT ENVIRONMENT=rails23
# 2.1
@@ -141,15 +141,15 @@ matrix:
env: TYPE=UNIT ENVIRONMENT=rails51
# jruby 9.0
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails21
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails22
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails23
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails30
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails31
- - rvm: jruby-9.1.12.0
+ - rvm: jruby-9.1.13.0
env: TYPE=UNIT ENVIRONMENT=rails32
View
@@ -1,5 +1,43 @@
# New Relic Ruby Agent Release Notes #
+## v4.5.0 ##
+
+ * Send synthetics headers even when CAT disabled
+
+ The agent now sends synthetics headers whenever they are received from an
+ external request, even if cross-application tracing is disabled.
+
+ * Bugfix for DelayedJob Daemonization
+
+ Customers using the delayed_job script that ships with the gem may encounter
+ an IOError with a message indicating the stream was closed. This was due to
+ the agent attempting to write a byte into a Pipe that was closed during the
+ deamonization of the delayed_job script. This issue has been fixed.
+
+ * Collect supportability metrics for public API
+
+ The agent now collects Supportability/API/{method} metrics to track usage of
+ all methods in the agent's public API.
+
+ * Collect supportability metrics on `Module#prepend`
+
+ The agent now collects Supportability/PrependedModules/{Module} metrics
+ for ActiveRecord 4 and 5, ActionController 4 and 5, ActionView 4 and 5,
+ ActiveJob 5, and ActionCable 5. These help track the adoption of the
+ `Module#prepend` method so we can maintain compatibility with newer versions
+ of Ruby and Rails.
+
+ * Collect explain plans when using PostGIS ActiveRecord adapter
+
+ The agent will now collect slow SQL explain plans, if configured to, on
+ connections using the PostGIS adapter. Thanks Ari Pollak for the contribution!
+
+ * Lazily intialize New Relic Config
+
+ The agent will lazily initialize the New Relic config. This allows the agent
+ to pickup configuration from environment variables set by dotenv and similar
+ tools.
+
## v4.4.0 ##
* Include test helper for 3rd party use
View
@@ -30,6 +30,7 @@ module Agent
require 'new_relic/metric_spec'
require 'new_relic/metric_data'
require 'new_relic/noticed_error'
+ require 'new_relic/supportability_helper'
require 'new_relic/agent/encoding_normalizer'
require 'new_relic/agent/stats'
@@ -65,6 +66,8 @@ module Agent
require 'thread'
require 'resolv'
+ extend NewRelic::SupportabilityHelper
+
# An exception that is thrown by the server if the agent license is invalid.
class LicenseException < StandardError; end
@@ -120,17 +123,14 @@ def logger=(log)
@logger = log
end
- # This needs to come after the definition of the logger method above, since
- # instantiating the config writes to the Logger.
-
- @config = NewRelic::Agent::Configuration::Manager.new
-
- attr_reader :config
+ def config
+ @config ||= Configuration::Manager.new
+ end
# For testing
# Important that we don't change the instance or we orphan callbacks
def reset_config
- @config.reset_to_defaults
+ config.reset_to_defaults
end
# @!group Recording custom metrics
@@ -152,6 +152,8 @@ def reset_config
#
# @api public
def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
+ record_api_supportability_metric(:record_metric)
+
return unless agent
if value.is_a?(Hash)
@@ -179,8 +181,8 @@ def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
return unless agent
- agent.stats_engine.tl_record_unscoped_metrics(metric_name) do |stats|
- stats.increment_count(amount)
+ { 'Supportability/API/increment_metric' => 1, metric_name => amount }.each do |metric, increment_amount|
+ agent.stats_engine.tl_record_unscoped_metrics(metric) {|stats| stats.increment_count(increment_amount) }
end
end
@@ -200,6 +202,8 @@ def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
# @api public
#
def ignore_error_filter(&block)
+ record_api_supportability_metric(:ignore_error_filter)
+
if block
NewRelic::Agent::ErrorCollector.ignore_error_filter = block
else
@@ -236,6 +240,7 @@ def ignore_error_filter(&block)
# @api public
#
def notice_error(exception, options={})
+ record_api_supportability_metric(:notice_error)
if options.has_key?(:trace_only)
NewRelic::Agent.logger.log_once(:warn, :trace_only_deprecated,
@@ -276,9 +281,12 @@ def notice_error(exception, options={})
# @api public
#
def record_custom_event(event_type, event_attrs)
+ record_api_supportability_metric(:record_custom_event)
+
if agent && NewRelic::Agent.config[:'custom_insights_events.enabled']
agent.custom_event_aggregator.record(event_type, event_attrs)
end
+
nil
end
@@ -304,6 +312,8 @@ def record_custom_event(event_type, event_attrs)
# @api public
#
def manual_start(options={})
+ record_api_supportability_metric(:manual_start)
+
raise "Options must be a hash" unless Hash === options
NewRelic::Control.instance.init_plugin({ :agent_enabled => true, :sync_startup => true }.merge(options))
end
@@ -334,6 +344,7 @@ def manual_start(options={})
# @api public
#
def after_fork(options={})
+ record_api_supportability_metric(:after_fork)
agent.after_fork(options) if agent
end
@@ -345,6 +356,7 @@ def after_fork(options={})
# @api public
#
def shutdown(options={})
+ record_api_supportability_metric(:shutdown)
agent.shutdown if agent
end
@@ -354,6 +366,7 @@ def shutdown(options={})
# @api public
def drop_buffered_data
agent.drop_buffered_data if agent
+ record_api_supportability_metric(:drop_buffered_data)
end
# Add instrumentation files to the agent. The argument should be
@@ -366,13 +379,15 @@ def drop_buffered_data
# @api public
#
def add_instrumentation(file_pattern)
+ record_api_supportability_metric(:add_instrumentation)
NewRelic::Control.instance.add_instrumentation file_pattern
end
# Require agent testing helper methods
#
# @api public
def require_test_helper
+ record_api_supportability_metric(:require_test_helper)
require File.expand_path('../../../test/agent_helper', __FILE__)
end
@@ -393,6 +408,7 @@ def require_test_helper
# @api public
#
def set_sql_obfuscator(type = :replace, &block)
+ record_api_supportability_metric(:set_sql_obfuscator)
NewRelic::Agent::Database.set_sql_obfuscator(type, &block)
end
@@ -407,6 +423,7 @@ def set_sql_obfuscator(type = :replace, &block)
# @api public
#
def ignore_transaction
+ record_api_supportability_metric(:ignore_transaction)
txn = NewRelic::Agent::Transaction.tl_current
txn.ignore! if txn
end
@@ -417,6 +434,7 @@ def ignore_transaction
# @api public
#
def ignore_apdex
+ record_api_supportability_metric(:ignore_apdex)
txn = NewRelic::Agent::Transaction.tl_current
txn.ignore_apdex! if txn
end
@@ -427,6 +445,7 @@ def ignore_apdex
# @api public
#
def ignore_enduser
+ record_api_supportability_metric(:ignore_enduser)
txn = NewRelic::Agent::Transaction.tl_current
txn.ignore_enduser! if txn
end
@@ -439,6 +458,8 @@ def ignore_enduser
# @api public
#
def disable_all_tracing
+ record_api_supportability_metric(:disable_all_tracing)
+
return yield unless agent
begin
@@ -455,6 +476,8 @@ def disable_all_tracing
# @api public
#
def disable_transaction_tracing
+ record_api_supportability_metric(:disable_transaction_tracing)
+
return yield unless agent
state = agent.set_record_tt(false)
@@ -477,6 +500,8 @@ def disable_transaction_tracing
# @api public
#
def disable_sql_recording
+ record_api_supportability_metric(:disable_sql_recording)
+
return yield unless agent
state = agent.set_record_sql(false)
@@ -519,6 +544,8 @@ def tl_is_sql_recorded?
# @api public
#
def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
+ record_api_supportability_metric(:add_custom_attributes)
+
if params.is_a? Hash
txn = Transaction.tl_current
txn.add_custom_attributes(params) if txn
@@ -555,6 +582,7 @@ def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
# @api public
#
def set_transaction_name(name, options={})
+ record_api_supportability_metric(:set_transaction_name)
Transaction.set_overriding_transaction_name(name, options[:category])
end
@@ -564,6 +592,8 @@ def set_transaction_name(name, options={})
# @api public
#
def get_transaction_name #THREAD_LOCAL_ACCESS
+ record_api_supportability_metric(:get_transaction_name)
+
txn = Transaction.tl_current
if txn
namer = Instrumentation::ControllerInstrumentation::TransactionNamer
@@ -621,6 +651,8 @@ def notify(event_type, *args)
# @api public
#
def browser_timing_header
+ record_api_supportability_metric(:browser_timing_header)
+
return "" unless agent
agent.javascript_instrumentor.browser_timing_header
end
Oops, something went wrong.

0 comments on commit 2bc79e1

Please sign in to comment.