Skip to content
Browse files

Creating tag based on branch v2_9_2 @ 9076

  • Loading branch information...
2 parents 61f1b4c + 47ce608 commit 9cb89eef36a7ed7ae1e40983df541d45855ef998 @bkayser bkayser committed Jun 24, 2009
Showing with 191 additions and 170 deletions.
  1. +1 −0 CHANGELOG
  2. +0 −128 README
  3. +138 −0 README.md
  4. +1 −7 Rakefile
  5. +8 −8 lib/new_relic/agent/agent.rb
  6. +5 −5 lib/new_relic/control.rb
  7. +0 −9 newrelic_spec.rb
  8. +0 −1 spec_helper.rb
  9. +5 −1 test/config/newrelic.yml
  10. +33 −11 test/new_relic/control_test.rb
View
1 CHANGELOG
@@ -5,6 +5,7 @@ v2.9.2
* fix JRuby problem using objectspace
* display custom parameters when looking at transactions in dev mode
* display count of sql statements on the list of transactions in dev mode
+ * fixes for merb--thanks to Carl Lerche
v2.9.1.
* add newrelic_ignore_apdex method to controller classes to allow
View
128 README
@@ -1,128 +0,0 @@
-= New Relic RPM
-
-* http://www.newrelic.com
-
-New Relic RPM is a Ruby performance management system, developed by
-New Relic, Inc. RPM provides you with deep information about the
-performance of your Ruby on Rails or Merb application as it runs in
-production. The New Relic Agent is distributed as a either a Rails
-plugin or a Gem, both hosted on RubyForge.
-
-The New Relic Agent runs in one of two modes:
-
-* Developer Mode : Adds a web interface mapped to /newrelic to your
- application for showing detailed performance metrics on a page by
- page basis.
-
-* Production Mode : Low overhead instrumentation that captures
- detailed information on your application running in production and
- transmits them to rpm.newrelic.com where you can monitor them in
- real time.
-
-=== Developer Mode
-
-Developer mode is on by default when you run your application in the
-development environment (but not when it runs in other environments.)
-When running in developer mode, RPM will track the performance of
-every http request serviced by your application, and store in memory
-this information for the last 100 http transactions.
-
-When running in Developer Mode, the RPM will also add a few pages to
-your application that allow you to analyze this performance
-information. (Don't worry - those pages are not added to your
-application's routes when you run in production mode.)
-
-To view this performance information, including detailed SQL statement
-analysis, open '/newrelic' in your web application. For instance if
-you are running mongrel or thin on port 3000, enter the following into
-your browser:
-
-http://localhost:3000/newrelic
-
-=== Production Mode
-
-To monitor your applications in production, create an account at
-http://newrelic.com/get-RPM.html
-
-When your application runs in the production environment, the New
-Relic agent runs in production mode. It connects to the New Relic RPM
-service and sends deep performance data to the RPM service for your
-analysis. To view this data, login to http://rpm.newrelic.com.
-
-NOTE: You must have a valid account and license key to view this data
-online. When you sign up for an account at www.newrelic.com, you will
-be provided with a license key, as well as a default configuration
-file for New Relic RPM. You can either paste your license key into
-your existing configuration file, config/newrelic.yml, or you can
-replace that config file with the one included in your welcome email.
-
-== Installation
-
-RPM requires an agent be installed in the application as either a
-Rails plug-in or a gem. Both are available on RubyForge--instructions
-below.
-
-=== Git your RPM on!
-
-The agent is also available on Github under newrelic/rpm. Fork away!
-
-=== Requirements:
-
-Ruby 1.8.6 or 1.9.1
-Rails 1.2.6 or above
-Merb 1.0 or above
-
-=== Rails Plug-In Installation
-
- script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm
-
-=== Gem Installation
-
- sudo gem install newrelic_rpm
-
-For Rails, edit environment.rb and add to the initalizer block:
-
- config.gem "newrelic_rpm"
-
-The Developer Mode is unavailable when using the gem on Rails versions
-prior to 2.0.
-
-== Merb Support
-
-To monitor a merb app install the newrelic_rpm gem and add
-
- dependency 'newrelic_rpm'
-
-to your init.rb file.
-
-Current features implemented:
-
- * Standard monitoring, overview pages
- * Error capturing
- * Full Active Record instrumentation, including SQL explains
- * Very limited Data Mapper instrumentation
- * Transaction Traces are implemented but will not be very useful
- with Data Mapper until more work is done with the Data Mapper
- instrumentation
-
-Still under development:
-
- * Developer Mode
- * Data Mapper bindings
-
-== Support
-
-Reach out to us--and to fellow RPM users--at
-http://support.newrelic.com. There you'll find documentation, FAQs,
-and forums where you can submit suggestions and discuss RPM with New
-Relic staff and other users.
-
-Find a bug? E-mail support@newrelic.com, or post it to
-support.newrelic.com.
-
-For other support channels, see http://www.newrelic.com/support.
-
-Thank you, and may your application scale to infinity plus one.
-
-Lew Cirne, Founder and CEO
-New Relic, Inc.
View
138 README.md
@@ -0,0 +1,138 @@
+New Relic RPM
+=============
+
+New Relic RPM is a Ruby performance management system, developed by
+[New Relic, Inc](http://www.newrelic.com). RPM provides you with deep
+information about the performance of your Ruby on Rails or Merb
+application as it runs in production. The New Relic Agent is
+dual-purposed as a either a Rails plugin or a Gem, hosted on
+[github](http://github.com/newrelic/rpm/tree/master) and Rubyforge.
+
+The New Relic Agent runs in one of two modes:
+
+**Developer Mode** : Adds a web interface mapped to /newrelic to your
+ application for showing detailed performance metrics on a page by
+ page basis.
+
+**Production Mode** : Low overhead instrumentation that captures
+ detailed information on your application running in production and
+ transmits them to rpm.newrelic.com where you can monitor them in
+ real time.
+
+### Supported Environments
+
+* Ruby 1.8.6, 1.8.7 or 1.9.1
+* JRuby
+* Rails 1.2.6 or above
+* Merb 1.0 or above
+
+Developer Mode
+--------------
+
+Developer mode is on by default when you run your application in the
+development environment (but not when it runs in other environments.)
+When running in developer mode, RPM will track the performance of
+every http request serviced by your application, and store in memory
+this information for the last 100 http transactions.
+
+When running in Developer Mode, the RPM will also add a few pages to
+your application that allow you to analyze this performance
+information. (Don't worry--those pages are not added to your
+application's routes when you run in production mode.)
+
+To view this performance information, including detailed SQL statement
+analysis, open `/newrelic` in your web application. For instance if
+you are running mongrel or thin on port 3000, enter the following into
+your browser:
+
+ http://localhost:3000/newrelic
+
+Production Mode
+---------------
+
+When your application runs in the production environment, the New
+Relic agent runs in production mode. It connects to the New Relic RPM
+service and sends deep performance data to the RPM service for your
+analysis. To view this data, login to
+[http://rpm.newrelic.com](http://rpm.newrelic.com).
+
+NOTE: You must have a valid account and license key to view this data
+online. Refer to instructions in *Getting Started*, below.
+
+Getting Started
+===============
+
+RPM requires an agent be installed in the application as either a
+Rails plug-in or a gem. Both are available on RubyForge--instructions
+below.
+
+To use Developer Mode, simply install the gem or plugin into your
+application and follow the instructions below.
+
+To monitor your applications in production, create an account at
+[www.newrelic.com](http://newrelic.com/get-RPM.html). There you can
+sign up for a free Lite account or one of our paid subscriptions.
+
+Once you receive the welcome e-mail with a license key and
+`newrelic.yml` file, copy the `newrelic.yml` file into your app config
+directory.
+
+### Rails Plug-In Installation
+
+ script/plugin install http://newrelic.rubyforge.org/svn/newrelic_rpm
+
+### Gem Installation
+
+ sudo gem install newrelic_rpm
+
+For Rails, edit `environment.rb` and add to the initalizer block:
+
+ config.gem "newrelic_rpm"
+
+The Developer Mode is unavailable when using the gem on Rails versions
+prior to 2.0.
+
+### Merb Support
+
+To monitor a merb app install the newrelic_rpm gem and add
+
+ dependency 'newrelic_rpm'
+
+to your init.rb file.
+
+Current features implemented:
+
+* Standard monitoring, overview pages
+* Error capturing
+* Full Active Record instrumentation, including SQL explains
+* Very limited Data Mapper instrumentation
+* Transaction Traces are implemented but will not be very useful
+ with Data Mapper until more work is done with the Data Mapper
+ instrumentation
+
+Still under development:
+
+* Developer Mode
+* Data Mapper bindings
+
+### Github
+
+The agent is also available on Github under newrelic/rpm. Fork away!
+
+### Support
+
+Reach out to us--and to fellow RPM users--at
+[support.newrelic.com](http://support.newrelic.com/discussions/support).
+There you'll find documentation, FAQs, and forums where you can submit
+suggestions and discuss RPM with New Relic staff and other users.
+
+Find a bug? E-mail support@newrelic.com, or post it to
+[support.newrelic.com](http://support.newrelic.com/discussions/support).
+
+Refer to [our website](http://www.newrelic.com/support) for other
+support channels.
+
+Thank you, and may your application scale to infinity plus one.
+
+Lew Cirne, Founder and CEO<br/>
+New Relic, Inc.
View
8 Rakefile
@@ -1,5 +1,4 @@
require 'rubygems'
-require 'rake/gempackagetask'
require 'lib/new_relic/version.rb'
require 'echoe'
@@ -18,11 +17,6 @@ Echoe.new(GEM_NAME) do |p|
p.project = 'newrelic'
p.need_tar_gz = false
p.need_gem = true
+ p.ignore_pattern = %w[]
end
-desc "Create a gemspec file"
-task :gemspec do
- File.open("#{GEM_NAME}.gemspec", "w") do |file|
- file.puts spec.to_ruby
- end
-end
View
16 lib/new_relic/agent/agent.rb
@@ -151,7 +151,7 @@ def start
@started = true
sampler_config = control.fetch('transaction_tracer', {})
- @use_transaction_sampler = sampler_config.fetch('enabled', false)
+ @use_transaction_sampler = sampler_config.fetch('enabled', true)
@record_sql = sampler_config.fetch('record_sql', :obfuscated).to_sym
@@ -162,17 +162,17 @@ def start
@slowest_transaction_threshold = sampler_config.fetch('transaction_threshold', 2.0)
if @slowest_transaction_threshold =~ /apdex_f/i
@slowest_transaction_threshold = apdex_f
- elsif !@slowest_transaction_threshold.is_a? Float
- log.warn "Invalid transaction_threshold detected: '#{@slowest_transaction_threshold}'. Using #{apdex_f} seconds." if @use_transaction_sampler
- @slowest_transaction_threshold = apdex_f
end
@slowest_transaction_threshold = @slowest_transaction_threshold.to_f
- log.info "Transaction tracing threshold is #{@slowest_transaction_threshold} seconds" if @use_transaction_sampler
+ if @use_transaction_sampler
+ log.info "Transaction tracing threshold is #{@slowest_transaction_threshold} seconds."
+ else
+ log.info "Transaction tracing not enabled."
+ end
@explain_threshold = sampler_config.fetch('explain_threshold', 0.5).to_f
@explain_enabled = sampler_config.fetch('explain_enabled', true)
@random_sample = sampler_config.fetch('random_sample', false)
- log.info "Transaction tracing is enabled in agent control" if @use_transaction_sampler
log.warn "Agent is configured to send raw SQL to RPM service" if @record_sql == :raw
# Initialize transaction sampler
@transaction_sampler.random_sampling = @random_sample
@@ -338,10 +338,10 @@ def connect
sampling_rate = invoke_remote :sampling_rate, @agent_id if @random_sample
@transaction_sampler.sampling_rate = sampling_rate
- log.info "Transaction sample rate: #{sampling_rate}"
+ log.info "Transaction sample rate: #{@transaction_sampler.sampling_rate}"
end
- # Ask for mermission to collect error data
+ # Ask for permission to collect error data
@should_send_errors = invoke_remote :should_collect_errors, @agent_id
log.info "Transaction traces will be sent to the RPM service" if @use_transaction_sampler && @should_send_samples
View
10 lib/new_relic/control.rb
@@ -68,7 +68,11 @@ def init_plugin(options={})
@settings = nil
options.each { |sym, val | self[sym.to_s] = val unless sym == :config }
- @log = logger_override if logger_override
+ if logger_override
+ @log = logger_override
+ # Try to grab the log filename
+ @log_file = @log.instance_eval { @logdev.filename rescue nil }
+ end
init_config(options)
if agent_enabled? && !@started
setup_log unless logger_override
@@ -369,10 +373,6 @@ def log_path
File.expand_path(path)
end
- def log_file_name
- @log_file
- end
-
# Create the concrete class for environment specific behavior:
def self.new_instance
@local_env = NewRelic::LocalEnvironment.new
View
9 newrelic_spec.rb
@@ -1,9 +0,0 @@
-# Specs not currently implemented. Unit tests may only run when this is installed
-# as a plugin in a Rails application.
-require File.dirname(__FILE__) + '/spec_helper'
-
-describe "newrelic" do
- it "should do nothing" do
- true.should == true
- end
-end
View
1 spec_helper.rb
@@ -1 +0,0 @@
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
View
6 test/config/newrelic.yml
@@ -1,6 +1,11 @@
# This is the config file loaded when running unit tests locally.
+common: &default_settings
+ transaction_tracer:
+ enabled: true
+ record_sql: raw
test:
+ <<: *default_settings
host: localhost
port: 3000
log_level: debug
@@ -28,7 +33,6 @@ test:
check_bg_loading: true
transaction_tracer:
- enabled: true
record_sql: raw
transaction_threshold: Apdex_f # case insensitive
explain_threshold: 0.1
View
44 test/new_relic/control_test.rb
@@ -1,13 +1,7 @@
require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
-module NewRelic
- class Control
- public :log_file_name
- end
-end
-
class NewRelic::ControlTest < Test::Unit::TestCase
-
+
attr_reader :c
def setup
@@ -24,19 +18,19 @@ def test_test_config
assert_equal false, c['enabled']
c.local_env
end
-
+
def test_root
assert File.directory?(NewRelic::Control.newrelic_root), NewRelic::Control.newrelic_root
assert File.directory?(File.join(NewRelic::Control.newrelic_root, "lib")), NewRelic::Control.newrelic_root + "/lib"
end
-
+
def test_info
props = NewRelic::Control.instance.local_env.snapshot
list = props.assoc('Plugin List').last.sort
assert_not_nil list # can't really guess what might be in here.
assert_match /jdbc|postgres|mysql|sqlite/, props.assoc('Database adapter').last
end
-
+
def test_resolve_ip
assert_equal nil, c.send(:convert_to_ip_address, 'localhost')
assert_equal nil, c.send(:convert_to_ip_address, 'q1239988737.us')
@@ -48,7 +42,7 @@ def test_config_yaml_erb
assert_equal '', c['message']
assert_equal '', c['license_key']
end
-
+
def test_config_booleans
assert_equal c['tval'], true
assert_equal c['fval'], false
@@ -71,5 +65,33 @@ def test_environment_info
snapshot = NewRelic::Control.instance.local_env.snapshot
assert snapshot.assoc('Plugin List').last.include?('newrelic_rpm'), snapshot.inspect
end
+ def test_config_apdex
+ assert_equal 1.1, c['apdex_t']
+ end
+
+ def test_transaction_threshold__apdex
+ forced_start
+ assert_equal 'Apdex_f', c['transaction_tracer']['transaction_threshold']
+ assert_equal 4.4, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
+ end
+
+ def test_transaction_threshold__default
+
+ forced_start :transaction_tracer => {}
+ assert_nil c['transaction_tracer']['transaction_threshold']
+ assert_equal 2.0, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
+ end
+ def test_transaction_threshold__override
+ forced_start :transaction_tracer => { 'transaction_threshold' => 1}
+ assert_equal 1, c['transaction_tracer']['transaction_threshold']
+ assert_equal 1, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
+ end
+ private
+ def forced_start overrides = {}
+ NewRelic::Agent.manual_start overrides
+ # This is to force the agent to start again.
+ NewRelic::Agent.instance.stubs(:started?).returns(nil)
+ NewRelic::Agent.instance.start
+ end
end

0 comments on commit 9cb89ee

Please sign in to comment.
Something went wrong with that request. Please try again.