Skip to content

Commit

Permalink
Agent release 2.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kayser committed Nov 19, 2009
1 parent 7b16c44 commit 9fc1314
Show file tree
Hide file tree
Showing 79 changed files with 1,119 additions and 2,447 deletions.
53 changes: 15 additions & 38 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,52 +1,29 @@
v2.10.1
* add support for textmate to dev mode
* preliminary sinatra support, displays actions named by the URI pattern matched
* added add_transaction_tracer method to support instrumenting methods as
if they were web transactions; this will facilitate better visibility of background
tasks and eventually things like rack, metal and Sinatra
* adjusted apdex scores to reflect time spent in the mongrel queue
* fixed incompatibility with JRuby on startup
* implmented CPU measure for JRuby which reflects the cpu burn for
all controller actions (does not include background tasks)
* fixed scope issue with GC instrumentation, subtracting time from caller
* added # of GC calls to GC instrumentation
* renamed the dispatcher metric
* refactored stats_engine code for readability

v2.10.0
* support unicorn
* instrumentation of GC for REE and MRE with GC patch
* support agent restarting when changes are made to the account
* removed #newrelic_notice_error from Object class, replaced by NewRelic::Agent#notic_error
* collect histogram statistics
* add custom parameters to newrelic_notice_error call to display
extra info for errors
* add method disable_all_tracing(&block) to execute a block without
capturing metrics
* newrelic_ignore now blocks all instrumentation collection for
the specified actions
* added doc to method_tracer API and removed second arg
requirement for add_method_tracer call
* instrumentation for Net::HTTP
* remove method_tracer shim to avoid timing problems in monitoring daemons
* for non-rails daemons, look at APP_ROOT and NRCONFIG env vars for custom locations

v2.9.6
v2.9.8.
* Fix bug in Net instrumentation when a block is passed to request calls.

v2.9.7.
* Fix External instrumentation so it does not capture Net
calls outside of web transactions.

v2.9.6.
* add instrumentation for Net::HTTP calls, to show up as "External"
* added support for validating agents in the cloud.
* recognize Unicorn dispatcher
* add NewRelic module definitions to ActiveRecord instrumentation

v2.9.5
v2.9.5.
* Snow Leopard memory fix

v2.9.4
v2.9.4.
* clamp size of data sent to server
* reset statistics for passenger when forking to avoid erroneous data
* fix problem deserializing errors from the server
* fix incompatibility with postgres introduced in 2.9.

v2.9.3.
* fix startup failure in Windows due to memory sampler
* add JRuby environment information
* add JRuby environment information

v2.9.2.
* change default apdex_t to 0.5 seconds
* fix bug in deployments introduced by multi_homed setting
Expand Down
140 changes: 34 additions & 106 deletions lib/new_relic/agent.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# = New Relic Agent
#
# New Relic RPM is a performance monitoring application for Ruby
# applications running in production. For more information on RPM
# please visit http://www.newrelic.com.
# New Relic RPM is a performance monitoring application for Ruby applications running
# in production. For more information on RPM please visit http://www.newrelic.com.
#
# The New Relic Agent can be installed in Rails applications to gather
# runtime performance metrics, traces, and errors for display in a
# Developer Mode UI (mapped to /newrelic in your application server)
# or for monitoring and analysis at http://rpm.newrelic.com with just
# about any Ruby application.
# The New Relic Agent can be installed in Ruby applications to gather runtime performance
# metrics, traces, and errors for display in a Developer Mode UI (mapped to /newrelic in your application
# server) or for monitoring and analysis at http://rpm.newrelic.com.
#
# For detailed information on configuring or customizing the RPM Agent
# please visit our {support and documentation site}[http://support.newrelic.com].
# For detailed information on configuring or customizing the RPM Agent please visit our
# {support and documentation site}[http://support.newrelic.com].
#
# == Starting the Agent as a Gem
#
Expand All @@ -23,56 +20,24 @@
# dependency 'newrelic_rpm'
# in the Merb config/init.rb
#
# For Sinatra, just require the +newrelic_rpm+ gem and it will
# automatically detect Sinatra and instrument all the handlers.
#
# For other frameworks, or to manage the agent manually,
# invoke NewRelic::Agent#manual_start directly.
# For other frameworks, or to manage the agent manually, invoke NewRelic::Agent#manual_start
# directly.
#
# == Configuring the Agent
#
# All agent configuration is done in the +newrelic.yml+ file. This
# file is by default read from the +config+ directory of the
# application root and is subsequently searched for in the application
# root directory, and then in a +~/.newrelic+ directory
#
# == Using with Rack/Metal
# All agent configuration is done in the +newrelic.yml+ file. This file is by
# default read from the +config+ directory of the application root and is subsequently
# searched for in the application root directory, and then in a +~/.newrelic+ directory
#
# To instrument middlewares, refer to the docs in
# NewRelic::Agent::Instrumentation::Rack.
# == Agent APIs
#
# == Agent API
#
# For details on the Agent API, refer to NewRelic::Agent.
#
# The agent has some APIs available for extending and customizing.
#
# :main: lib/new_relic/agent.rb
module NewRelic
# == Agent APIs
# This module contains the public API methods for the Agent.
#
# For adding custom instrumentation to method invocations, refer to
# the docs in the class NewRelic::Agent::MethodTracer.
#
# For information on how to customize the controller
# instrumentation, or to instrument something other than Rails so
# that high level dispatcher actions or background tasks show up as
# first class operations in RPM, refer to
# NewRelic::Agent::Instrumentation::ControllerInstrumentation and
# NewRelic::Agent::Instrumentation::ControllerInstrumentation::ClassMethods.
#
# Methods in this module as well as documented methods in
# NewRelic::Agent::MethodTracer and
# NewRelic::Agent::Instrumentation::ControllerInstrumentation are
# available to applications. When the agent is not enabled the
# method implementations are stubbed into no-ops to reduce overhead.
#
# Methods and classes in other parts of the agent are not guaranteed
# to be available between releases.
#
# Refer to the online docs at support.newrelic.com to see how to
# access the data collected by custom instrumentation, or e-mail
# support at New Relic for help.

# Methods in the Agent module are delegated to the NewRelic::Agent::Agent
# singleton instance.
module Agent
extend self

Expand All @@ -85,7 +50,6 @@ module Agent
require 'new_relic/transaction_analysis'
require 'new_relic/transaction_sample'
require 'new_relic/noticed_error'
require 'new_relic/histogram'

require 'new_relic/agent/chained_call'
require 'new_relic/agent/agent'
Expand All @@ -112,9 +76,6 @@ class LicenseException < StandardError; end

# An exception that forces an agent to stop reporting until its mongrel is restarted.
class ForceDisconnectException < StandardError; end

# An exception that forces an agent to restart.
class ForceRestartException < StandardError; end

# Used to blow out of a periodic task without logging a an error, such as for routine
# failures.
Expand All @@ -129,19 +90,19 @@ class ServerError < StandardError; end

class BackgroundLoadingError < StandardError; end

@agent = nil
@@agent = nil

# The singleton Agent instance. Used internally.
def agent #:nodoc:
raise "Plugin not initialized!" if @agent.nil?
@agent
# The singleton Agent instance.
def agent
raise "Plugin not initialized!" if @@agent.nil?
@@agent
end

def agent= new_instance #:nodoc:
@agent = new_instance
def agent= new_instance
@@agent = new_instance
end

alias instance agent #:nodoc:
alias instance agent

# Get or create a statistics gatherer that will aggregate numerical data
# under a metric name.
Expand All @@ -152,10 +113,12 @@ def agent= new_instance #:nodoc:
# Return a NewRelic::Stats that accepts data
# via calls to add_data_point(value).
def get_stats(metric_name, use_scope=false)
@agent.stats_engine.get_stats(metric_name, use_scope)
@@agent.stats_engine.get_stats(metric_name, use_scope)
end

alias get_stats_no_scope get_stats
def get_stats_no_scope(metric_name)
@@agent.stats_engine.get_stats_no_scope(metric_name)
end

# Call this to manually start the Agent in situations where the Agent does
# not auto-start.
Expand All @@ -177,12 +140,6 @@ def manual_start(options={})
options.merge! :agent_enabled => true
NewRelic::Control.instance.init_plugin options
end

# Shutdown the agent. Call this before exiting. Sends any queued data
# and kills the background thread.
def shutdown
@agent.shutdown
end

# This method sets the block sent to this method as a sql obfuscator.
# The block will be called with a single String SQL statement to obfuscate.
Expand Down Expand Up @@ -221,7 +178,7 @@ def disable_sql_recording
end

# This method disables the recording of transaction traces in the given
# block. See also #disable_all_tracing
# block.
def disable_transaction_tracing
state = agent.set_record_tt(false)
begin
Expand All @@ -231,44 +188,15 @@ def disable_transaction_tracing
end
end

# Yield to the block without collecting any metrics or traces in any of the
# subsequent calls. If executed recursively, will keep track of the first
# entry point and turn on tracing again after leaving that block.
# This uses the thread local +newrelic_untrace+
def disable_all_tracing
agent.push_trace_execution_flag(false)
yield
ensure
agent.pop_trace_execution_flag
end

# Check to see if we are capturing metrics currently on this thread.
def is_execution_traced?
Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
end

# Set a filter to be applied to errors that RPM will track.
# This method allows a filter to be applied to errors that RPM will track.
# The block should return the exception to track (which could be different from
# the original exception) or nil to ignore this exception.
#
# The block is yielded to with the exception to filter.
# the original exception) or nil to ignore this exception
#
def ignore_error_filter(&block)
agent.error_collector.ignore_error_filter(&block)
end

# Record the given error in RPM. It will be passed through the #ignore_error_filter
# if there is one.
#
# * <tt>exception</tt> is the exception which will be recorded
# * <tt>extra_params</tt> is a hash of name value pairs to appear alongside
# the exception in RPM.
#
def notice_error(exception, extra_params = {})
NewRelic::Agent.agent.error_collector.notice_error(exception, nil, nil, extra_params)
end

# Add parameters to the current transaction trace on the call stack.
# Add parameters to the current transaction trace
#
def add_custom_parameters(params)
agent.add_custom_parameters(params)
Expand All @@ -277,4 +205,4 @@ def add_custom_parameters(params)
alias add_request_parameters add_custom_parameters

end
end
end

0 comments on commit 9fc1314

Please sign in to comment.