newrelic_rpm 3.5.1.14 → 3.5.2.17

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of newrelic_rpm might be problematic. Click here for more details.

data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - ree
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - jruby
data/CHANGELOG CHANGED
@@ -1,10 +1,11 @@
1
1
 
2
2
  # New Relic Ruby Agent Release Notes #
3
3
 
4
- ### Next Up ###
5
4
  ## v3.5.2 ##
6
5
 
7
- ### current version ###
6
+ * Simplified process of running agent test suite and documented code
7
+ contribution process in GUIDELINES_FOR_CONTRIBUTING.
8
+
8
9
  ## v3.5.1 ##
9
10
 
10
11
  * Enabling Memory Profiling on Lion and Mountain Lion
@@ -0,0 +1,52 @@
1
+ # Guidelines for Contributing Code
2
+
3
+ At New Relic we welcome community code contributions to the Ruby Agent, and have
4
+ taken effort to make this process easy for both contributors and our development
5
+ team.
6
+
7
+ When contributing keep in mind that the agent runs in a wide variety of ruby
8
+ language implementations (e.g. 1.8.6, 1.8.7, 1.9.x, jruby, etc.) as well as a
9
+ wide variety of application environments (e.g. rails, sinatra, roll-your-own,
10
+ etc., etc.)
11
+
12
+ Because of this we need to be more defensive in our coding practices than most
13
+ projects. Syntax must be compatible with all supported ruby implementations
14
+ (e.g. no 1.9 specific hash syntax) and we can't assume the presence of any
15
+ specific libraries such as `ActiveSupport`.
16
+
17
+ ## Testing
18
+
19
+ The agent includes a suite of unit tests which should be used to verify your
20
+ changes don't break existing functionality.
21
+
22
+ ### Running Tests
23
+
24
+ Running the test suite is simple. Just invoke:
25
+
26
+ bundle
27
+ bundle exec rake
28
+
29
+ This will run the unit tests in standalone mode, bootstrapping a basic Rails
30
+ 3.2 environment for the agent to instrument then executing the test suite.
31
+
32
+ These tests are setup to run automatically in
33
+ [travis-ci](https://travis-ci.org/newrelic/rpm) under several Ruby implementations.
34
+ When you've pushed your changes to github you can confirm that the travis-ci
35
+ build passes for your fork of the codebase.
36
+
37
+ Additionally, our own CI jobs runs these tests under multiple versions of Rails to
38
+ verify compatibility.
39
+
40
+ ### Writing Tests
41
+
42
+ For most contributions it is strongly recommended to add additional tests which
43
+ exercise your changes.
44
+
45
+ This helps us efficiently incorporate your changes into our mainline codebase
46
+ and provides a safeguard that your change won't be broken by future development.
47
+
48
+ There are some rare cases where code changes do not result in changed
49
+ functionality (e.g. a performance optimization) and new tests are not required.
50
+ In general, including tests with your pull request dramatically increases the
51
+ chances it will be accepted.
52
+
data/Gemfile CHANGED
@@ -1,10 +1,16 @@
1
1
  source :rubygems
2
2
 
3
3
  group :development do
4
- gem 'rake', '>= 0.9.2.2'
5
- gem 'mocha'
6
- gem 'shoulda'
4
+ # require 0.9.2.2.
5
+ # There's problems with the test task in rake 10
6
+ # https://github.com/jimweirich/rake/issues/144
7
+ gem 'rake', '0.9.2.2'
8
+ gem 'mocha', '~>0.12.0'
9
+ gem 'shoulda', '~>3.0.1'
7
10
  gem 'sdoc-helpers'
8
11
  gem 'rdoc', '>= 2.4.2'
9
- gem 'rdiscount'
12
+ gem 'rails', '~>3.2.0'
13
+ gem 'sqlite3', :platform => 'mri'
14
+ gem 'activerecord-jdbcsqlite3-adapter', :platform => 'jruby'
15
+ gem 'jruby-openssl', :platform => 'jruby'
10
16
  end
@@ -1,30 +1,30 @@
1
- = New Relic Ruby Agent
1
+ # New Relic Ruby Agent
2
2
 
3
3
  New Relic is a performance management system, developed by
4
4
  New Relic, Inc (http://www.newrelic.com). It provides you with deep
5
5
  information about the performance of your Rails or Ruby
6
6
  application as it runs in production. The New Relic Ruby Agent is
7
7
  dual-purposed as a either a Rails plugin or a Gem, hosted on
8
- github[http://github.com/newrelic/rpm/tree/master].
8
+ [github](http://github.com/newrelic/rpm/tree/master).
9
9
 
10
10
  The New Relic Ruby Agent runs in one of two modes:
11
11
 
12
- ==== Production Mode
12
+ #### Production Mode
13
13
 
14
14
  Low overhead instrumentation that captures detailed information on
15
15
  your application running in production and transmits them to
16
16
  newrelic.com where you can monitor them in real time.
17
17
 
18
- ==== Developer Mode
18
+ #### Developer Mode
19
19
 
20
- A Rack middleware that maps /newrelic to an application for showing
20
+ A Rack middleware that maps `/newrelic` to an application for showing
21
21
  detailed performance metrics on a page by page basis. Installed
22
22
  automatically in Rails applications.
23
23
 
24
- == Supported Environments
24
+ ## Supported Environments
25
25
 
26
- * Ruby 1.8.7, 1.9.1, or 1.9.2, including REE
27
- * JRuby 1.4 or higher
26
+ * Ruby 1.8.6, 1.8.7, REE, 1.9.x
27
+ * JRuby 1.6 and 1.7
28
28
  * Rails 2.0 or later for Production Mode
29
29
  * Rails 2.3 or later for Developer Mode
30
30
  * Sinatra
@@ -37,27 +37,42 @@ desired. Report any problems to support@newrelic.com.
37
37
  You can also monitor non-web applications. Refer to the "Other
38
38
  Environments" section under "Getting Started".
39
39
 
40
- = Getting Started
40
+ ## Contributing Code
41
41
 
42
- Install the Ruby Agent as a gem. If you are using Rails you can
43
- install the gem as a plug-in--details below.
42
+ We welcome code contributions (in the form of pull requests) from our user
43
+ community. Before submitting a pull request please review
44
+ [GUIDELINES_FOR_CONTRIBUTING](https://github.com/newrelic/rpm/blob/master/GUIDELINES_FOR_CONTRIBUTING.md).
44
45
 
45
- gem install newrelic_rpm
46
+ Following these helps us efficiently review and incorporate your contribution
47
+ and avoid breaking your code with future changes to the agent.
48
+
49
+
50
+ ## Getting Started
51
+
52
+ Install the Ruby Agent as a gem.
53
+
54
+ gem install newrelic_rpm
55
+
56
+ Or add it to your project's Gemfile.
57
+
58
+ gem 'newrelic_rpm'
46
59
 
47
60
  To monitor your applications in production, create an account at
48
61
  http://newrelic.com/ . There you can
49
62
  sign up for a free Lite account or one of our paid subscriptions.
50
63
 
51
64
  Once you receive the welcome e-mail with a license key and
52
- +newrelic.yml+ file, copy the +newrelic.yml+ file into your app config
65
+ `newrelic.yml` file, copy the `newrelic.yml` file into your app config
53
66
  directory.
54
67
 
55
- All agent configuration is done in the +newrelic.yml+ file. This file
56
- is by default read from the +config+ directory of the application root
68
+ The initial configuration is done in the `newrelic.yml` file. This file
69
+ is by default read from the `config` directory of the application root
57
70
  and is subsequently searched for in the application root directory,
58
- and then in a <tt>~/.newrelic</tt> directory
71
+ and then in a `~/.newrelic` directory. Once you're up and running you can
72
+ enable Server Side Config and manage your newrelic configuation from the web
73
+ UI.
59
74
 
60
- === Rails Installation
75
+ #### Rails Installation
61
76
 
62
77
  You can install the agent as a Gem:
63
78
 
@@ -68,88 +83,87 @@ Add the following line to your Gemfile:
68
83
  gem 'newrelic_rpm'
69
84
 
70
85
  For Rails 2.x without Bundler:
71
-
72
- edit +environment.rb+ and add to the initalizer block:
73
-
74
- config.gem "newrelic_rpm"
75
-
76
- === Merb Installation
77
86
 
78
- To monitor a merb app install the newrelic_rpm gem and add
87
+ edit `environment.rb` and add to the initalizer block:
79
88
 
80
- dependency 'newrelic_rpm'
89
+ config.gem "newrelic_rpm"
81
90
 
82
- to your init.rb file.
83
-
84
- === Sinatra Installation
91
+ #### Sinatra Installation
85
92
 
86
93
  To use the Ruby Agent with a Sinatra app, add
94
+
87
95
  require 'newrelic_rpm'
96
+
88
97
  in your Sinatra app, below the Sinatra require directive.
89
98
 
90
- Then make sure you set RACK_ENV to the environment corresponding to the
91
- configuration definitions in the newrelic.yml file; i.e., development,
99
+ Then make sure you set `RACK_ENV` to the environment corresponding to the
100
+ configuration definitions in the newrelic.yml file; e.g., development,
92
101
  staging, production, etc.
93
102
 
94
- To use Developer Mode in Sinatra, add NewRelic::Rack::DeveloperMode to
95
- the middleware stack. See the +config.ru+ sample below.
103
+ To use Developer Mode in Sinatra, add `NewRelic::Rack::DeveloperMode` to
104
+ the middleware stack. See the `config.ru` sample below.
105
+
106
+ #### Other Environments
96
107
 
97
- === Other Environments
108
+ You can use the Ruby Agent to monitor any Ruby application. Add
98
109
 
99
- You can use the Ruby Agent to monitor any Ruby application. Add
100
110
  require 'newrelic_rpm'
111
+
101
112
  to your startup sequence and then manually start the agent using
113
+
102
114
  NewRelic::Agent.manual_start
103
115
 
104
116
  To instrument Rack based applications, refer to the docs in
105
- NewRelic::Agent::Instrumentation::Rack.
117
+ `NewRelic::Agent::Instrumentation::Rack`.
106
118
 
107
- Refer to the docs in New Relic for details on how to monitor other web
108
- frameworks, background jobs, and daemons.
119
+ Refer to the [New Relic's Docs](http://newrelic.com/docs) for details on how to
120
+ monitor other web frameworks, background jobs, and daemons.
109
121
 
110
- Also, see if your environment is already supported by the
111
- rpm_contrib[http://newrelic.github.com/rpm_contrib] gem.
122
+ The Ruby Agent provides an API that allows custom instrumentation of additional
123
+ frameworks. You can find a list of community created intrumentation plugins
124
+ (e.g. [newrelic-redis](https://github.com/evanphx/newrelic-redis)) in the
125
+ [RPM Contrib README](https://github.com/newrelic/rpm_contrib/blob/master/README.md#new-relic-ruby-agent-plugins-seperate-projects).
112
126
 
113
- == Developer Mode
127
+ ## Developer Mode
114
128
 
115
129
  When running the Developer Mode, the Ruby Agent will track the
116
130
  performance of every HTTP request serviced by your application, and
117
131
  store in memory this information for the last 100 HTTP transactions.
118
132
 
119
133
  To view this performance information, including detailed SQL statement
120
- analysis, open +/newrelic+ in your web application. For instance if
134
+ analysis, open `/newrelic` in your web application. For instance if
121
135
  you are running mongrel or thin on port 3000, enter the following into
122
136
  your browser:
123
137
 
124
138
  http://localhost:3000/newrelic
125
139
 
126
- Developer Mode is only initialized if the +developer_mode+ setting in
140
+ Developer Mode is only initialized if the `developer_mode` setting in
127
141
  the newrelic.yml file is set to true. By default, it is turned off in
128
- all environments but +development+.
142
+ all environments but `development`.
129
143
 
130
- ==== Developer Mode in Rails
144
+ #### Developer Mode in Rails
131
145
 
132
146
  Developer Mode is available automatically in Rails Applications based
133
147
  on Rails 2.3 and later. No additional configuration is required. When
134
- your application starts and +developer_mode+ is enabled, the Ruby
148
+ your application starts and `developer_mode` is enabled, the Ruby
135
149
  Agent injects a middleware into your Rails middleware stack.
136
150
 
137
151
  For earlier versions of Rails that support Rack, you can use
138
- a +config.ru+ as below.
152
+ a `config.ru` as below.
139
153
 
140
- ==== Developer Mode in Rack Applications
154
+ #### Developer Mode in Rack Applications
141
155
 
142
156
  Developer Mode is available for any Rack based application such as
143
157
  Sinatra by installing the NewRelic::Rack::DeveloperMode
144
158
  middleware. This middleware passes all requests that do not start with
145
159
  /newrelic.
146
160
 
147
- Here's an example entry for Developer Mode in a +config.ru+ file:
161
+ Here's an example entry for Developer Mode in a `config.ru` file:
148
162
 
149
163
  require 'new_relic/rack/developer_mode'
150
164
  use NewRelic::Rack::DeveloperMode
151
165
 
152
- == Production Mode
166
+ ## Production Mode
153
167
 
154
168
  When your application runs in the production environment, the New
155
169
  Relic agent runs in production mode. It connects to the New Relic
@@ -157,13 +171,13 @@ service and sends deep performance data to the UI for your
157
171
  analysis. To view this data, log in to http://rpm.newrelic.com.
158
172
 
159
173
  NOTE: You must have a valid account and license key to view this data
160
- online. Refer to instructions in *Getting Started*, below.
174
+ online. Refer to instructions in *Getting Started*.
161
175
 
162
176
 
163
- = Support
177
+ ## Support
164
178
 
165
179
  Reach out to us--and to fellow users--at
166
- support.newrelic.com[http://support.newrelic.com/].
180
+ [support.newrelic.com](http://support.newrelic.com/).
167
181
  There you'll find documentation, FAQs, and forums where you can submit
168
182
  suggestions and discuss New Relic with staff and other users.
169
183
 
@@ -171,9 +185,11 @@ Also available is community support on IRC: we generally use #newrelic
171
185
  on irc.freenode.net
172
186
 
173
187
  Find a bug? E-mail support@newrelic.com, or post it to
174
- support.newrelic.com[http://support.newrelic.com/].
175
188
 
176
- Thank you, and may your application scale to infinity plus one.
189
+ [support.newrelic.com](http://support.newrelic.com/).
190
+
191
+ Thank you, and may your application scale to infinity plus one.
192
+
193
+ Lew Cirne, Founder and CEO
177
194
 
178
- Lew Cirne, Founder and CEO<br/>
179
195
  New Relic, Inc.
data/Rakefile CHANGED
@@ -1,12 +1,7 @@
1
1
  require 'rubygems'
2
2
  require "#{File.dirname(__FILE__)}/lib/new_relic/version.rb"
3
- require 'rake/testtask'
4
-
5
3
  require "#{File.dirname(__FILE__)}/lib/tasks/all.rb"
6
4
 
7
- task :test => Rake::Task['test:newrelic']
8
-
9
- task :default => :test
10
5
 
11
6
  desc 'Generate gemspec [ build_number, stage ]'
12
7
  task :gemspec, [ :build_number, :stage ] do |t, args|
@@ -0,0 +1,5 @@
1
+ # This config is used when setting up a basic rails environment for running the
2
+ # unit tests.
3
+ test:
4
+ database: ':memory:'
5
+ adapter: 'sqlite3'
@@ -364,8 +364,19 @@ module NewRelic
364
364
  # doing an at_exit within an at_exit block.
365
365
  def install_exit_handler
366
366
  if Agent.config[:send_data_on_exit] && !weird_ruby?
367
- # Our shutdown handler needs to run after other shutdown handlers
368
- at_exit { at_exit { shutdown } }
367
+ at_exit do
368
+ # Workaround for MRI 1.9 bug that loses exit codes in at_exit blocks.
369
+ # This is necessary to get correct exit codes for the agent's
370
+ # test suites.
371
+ # http://bugs.ruby-lang.org/issues/5218
372
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION.match(/^1\.9/)
373
+ exit_status = $!.status if $!.is_a?(SystemExit)
374
+ shutdown
375
+ exit exit_status if exit_status
376
+ else
377
+ shutdown
378
+ end
379
+ end
369
380
  end
370
381
  end
371
382
 
@@ -3,7 +3,7 @@ module NewRelic
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 3
5
5
  MINOR = 5
6
- TINY = 1
6
+ TINY = 2
7
7
  BUILD = nil
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
data/lib/tasks/tests.rake CHANGED
@@ -1,24 +1,25 @@
1
- # run unit tests for the NewRelic Agent
2
1
  begin
3
- require 'rake/test_task'
2
+ require 'rake/testtask'
4
3
  rescue LoadError => e
5
4
  end
6
5
 
7
6
  if defined? Rake::TestTask
7
+ task :test => 'test:newrelic'
8
+ task :default => :test
8
9
  namespace :test do
9
- AGENT_HOME = File.expand_path(File.join(File.dirname(__FILE__), "..",".."))
10
+ AGENT_HOME = File.expand_path(File.join(File.dirname(__FILE__),'..','..'))
10
11
  Rake::TestTask.new(:newrelic) do |t|
11
12
  t.libs << "#{AGENT_HOME}/test"
12
13
  t.libs << "#{AGENT_HOME}/lib"
13
- t.test_files = FileList["#{AGENT_HOME}/test/**/*_test.rb"]
14
+ t.pattern = "#{AGENT_HOME}/test/**/*_test.rb"
14
15
  t.verbose = true
16
+ end
15
17
 
16
- # Set the test loader to use the Ruby provided test loading script.
17
- # In ruby 1.9 the default Rake provided runner seems to exit with a 0
18
- # status code, even when tests fail.
19
- t.loader = :testrb if RUBY_VERSION >= '1.9'
18
+ Rake::TestTask.new(:intentional_fail) do |t|
19
+ t.libs << "#{AGENT_HOME}/test"
20
+ t.libs << "#{AGENT_HOME}/lib"
21
+ t.pattern = "#{AGENT_HOME}/test/intentional_fail.rb"
22
+ t.verbose = true
20
23
  end
21
- Rake::Task['test:newrelic'].comment = "Run the unit tests for the Agent"
22
- task 'test:newrelic' => :environment
23
24
  end
24
25
  end
@@ -19,7 +19,8 @@ EOS
19
19
  s.extra_rdoc_files = [
20
20
  "CHANGELOG",
21
21
  "LICENSE",
22
- "README.rdoc",
22
+ "README.md",
23
+ "GUIDELINES_FOR_CONTRIBUTING.md",
23
24
  "newrelic.yml"
24
25
  ]
25
26
  s.files = [<% files.each do |file| %>
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ class IntentionalFail < Test::Unit::TestCase
3
+
4
+ # This test suite is provided to facilitate testing that build scripts (e.g.
5
+ # rake test) return the correct exit codes when tests fail.
6
+ def test_fail
7
+ assert false
8
+ end
9
+
10
+ end
@@ -4,6 +4,16 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
4
4
  require 'active_record_fixtures'
5
5
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
6
6
 
7
+ # the db adapter library the tests are running under (e.g. sqlite3)
8
+ def adapter
9
+ if ActiveRecord::Base.respond_to?(:connection_config)
10
+ ActiveRecord::Base.connection_config[:adapter]
11
+ else
12
+ # old versions of rails are usually tested against mysql
13
+ 'mysql'
14
+ end
15
+ end
16
+
7
17
  def setup
8
18
  super
9
19
  NewRelic::Agent.manual_start
@@ -87,7 +97,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
87
97
  ActiveRecord/find
88
98
  ActiveRecord/ActiveRecordFixtures::Order/find
89
99
  Database/SQL/insert
90
- RemoteService/sql/mysql/localhost
100
+ RemoteService/sql/#{adapter}/localhost
91
101
  ]
92
102
 
93
103
  if NewRelic::Control.instance.rails_version < '2.1.0'
@@ -149,7 +159,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
149
159
  ActiveRecord/ActiveRecordFixtures::Order/find
150
160
  ActiveRecord/ActiveRecordFixtures::Order/create
151
161
  Database/SQL/other
152
- RemoteService/sql/mysql/localhost]
162
+ RemoteService/sql/#{adapter}/localhost]
153
163
 
154
164
  if NewRelic::Control.instance.rails_version < '2.1.0'
155
165
  expected += ['ActiveRecord/save',
@@ -190,7 +200,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
190
200
  ActiveRecord/find
191
201
  ActiveRecord/ActiveRecordFixtures::Order/find
192
202
  ActiveRecord/ActiveRecordFixtures::Shipment/find
193
- RemoteService/sql/mysql/localhost
203
+ RemoteService/sql/#{adapter}/localhost
194
204
  ]
195
205
 
196
206
  assert_calls_metrics(*expected_metrics) do
@@ -256,7 +266,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
256
266
 
257
267
  expected_metrics = %W[
258
268
  ActiveRecord/all
259
- RemoteService/sql/mysql/localhost
269
+ RemoteService/sql/#{adapter}/localhost
260
270
  ActiveRecord/destroy
261
271
  ActiveRecord/ActiveRecordFixtures::Order/destroy
262
272
  Database/SQL/insert
@@ -299,7 +309,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
299
309
  expected_metrics = %W[
300
310
  ActiveRecord/all
301
311
  Database/SQL/select
302
- RemoteService/sql/mysql/localhost
312
+ RemoteService/sql/#{adapter}/localhost
303
313
  ]
304
314
 
305
315
  assert_calls_unscoped_metrics(*expected_metrics) do
@@ -317,7 +327,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
317
327
  expected_metrics = %W[
318
328
  ActiveRecord/all
319
329
  Database/SQL/other
320
- RemoteService/sql/mysql/localhost
330
+ RemoteService/sql/#{adapter}/localhost
321
331
  ]
322
332
  assert_calls_unscoped_metrics(*expected_metrics) do
323
333
  ActiveRecordFixtures::Order.connection.execute "begin"
@@ -333,7 +343,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
333
343
  return if isSqlite?
334
344
  return if isPostgres?
335
345
 
336
- expected_metrics = %W[ActiveRecord/all Database/SQL/show RemoteService/sql/mysql/localhost]
346
+ expected_metrics = %W[ActiveRecord/all Database/SQL/show RemoteService/sql/#{adapter}/localhost]
337
347
 
338
348
  assert_calls_metrics(*expected_metrics) do
339
349
  ActiveRecordFixtures::Order.connection.execute "show tables"
@@ -499,7 +509,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
499
509
  true
500
510
  end
501
511
 
502
- expected_metrics = %W[ActiveRecord/all Database/SQL/select RemoteService/sql/mysql/localhost]
512
+ expected_metrics = %W[ActiveRecord/all Database/SQL/select RemoteService/sql/#{adapter}/localhost]
503
513
 
504
514
  assert_calls_metrics(*expected_metrics) do
505
515
  begin
@@ -513,7 +523,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
513
523
  compare_metrics expected_metrics, metrics
514
524
  check_metric_count('Database/SQL/select', 1)
515
525
  check_metric_count('ActiveRecord/all', 1)
516
- check_metric_count('RemoteService/sql/mysql/localhost', 1)
526
+ check_metric_count("RemoteService/sql/#{adapter}/localhost", 1)
517
527
  end
518
528
 
519
529
  def test_rescue_handling
@@ -535,7 +545,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
535
545
  # puts NewRelic::Agent::Database.config.inspect
536
546
 
537
547
  ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
538
- assert(NewRelic::Agent.get_stats('RemoteService/sql/mysql/localhost').call_count != 0)
548
+ assert(NewRelic::Agent.get_stats("RemoteService/sql/#{adapter}/localhost").call_count != 0)
539
549
 
540
550
  config = ActiveRecordFixtures::Shipment.connection.instance_eval { @config }
541
551
  config[:host] = '127.0.0.1'
@@ -545,7 +555,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
545
555
  # puts NewRelic::Agent::Database.config.inspect
546
556
 
547
557
  ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
548
- assert(NewRelic::Agent.get_stats('RemoteService/sql/mysql/127.0.0.1').call_count != 0)
558
+ assert(NewRelic::Agent.get_stats("RemoteService/sql/#{adapter}/127.0.0.1").call_count != 0)
549
559
 
550
560
  config[:host] = 'localhost'
551
561
  ActiveRecordFixtures::Shipment.establish_connection(config)
@@ -35,7 +35,7 @@ module NewRelic
35
35
  end
36
36
 
37
37
  def test_default_metric_name_code
38
- assert_equal "Custom/#{name}/test_method", default_metric_name_code('test_method')
38
+ assert_equal "Custom/#{self.class.name}/test_method", self.class.default_metric_name_code('test_method')
39
39
  end
40
40
 
41
41
  def test_newrelic_method_exists_positive
@@ -44,13 +44,13 @@ module NewRelic
44
44
  end
45
45
 
46
46
  def test_newrelic_method_exists_negative
47
- self.expects(:method_defined?).returns(false)
48
- self.expects(:private_method_defined?).returns(false)
47
+ self.class.expects(:method_defined?).returns(false)
48
+ self.class.expects(:private_method_defined?).returns(false)
49
49
 
50
50
  fake_log = mock('log')
51
51
  NewRelic::Control.instance.expects(:log).returns(fake_log)
52
- fake_log.expects(:warn).with("Did not trace #{name}#test_method because that method does not exist")
53
- assert !newrelic_method_exists?('test_method')
52
+ fake_log.expects(:warn).with("Did not trace #{self.class.name}#test_method because that method does not exist")
53
+ assert !self.class.newrelic_method_exists?('test_method')
54
54
  end
55
55
 
56
56
  def test_set_deduct_call_time_based_on_metric_positive
@@ -129,6 +129,7 @@ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
129
129
 
130
130
  def test_log_path_path_created
131
131
  path = File.expand_path('tmp/log_path_test')
132
+ FileUtils.mkdir_p(File.dirname(path))
132
133
  @base.instance_eval { @log_path = nil }
133
134
  with_config(:log_file_path => 'tmp/log_path_test') do
134
135
  assert !File.directory?(path) || FileUtils.rmdir(path)
@@ -80,10 +80,18 @@ class NewRelic::ControlTest < Test::Unit::TestCase
80
80
  end
81
81
  end
82
82
 
83
- def test_resolve_ip
83
+ def test_resolve_ip_for_localhost
84
84
  assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
85
+ end
86
+
87
+ def test_resolve_ip_for_non_existent_domain
88
+ Resolv.stubs(:getaddress).raises(Resolv::ResolvError)
89
+ IPSocket.stubs(:getaddress).raises(SocketError)
85
90
  assert_equal nil, control.send(:convert_to_ip_address, 'q1239988737.us')
86
- # This will fail if you don't have a valid, accessible, DNS server
91
+ end
92
+
93
+ def test_resolves_valid_ip
94
+ Resolv.stubs(:getaddress).with('collector.newrelic.com').returns('204.93.223.153')
87
95
  assert_equal '204.93.223.153', control.send(:convert_to_ip_address, 'collector.newrelic.com')
88
96
  end
89
97
 
data/test/script/ci.sh CHANGED
@@ -164,4 +164,4 @@ bundle --local || bundle
164
164
  # there are failures to see if they are transient (instead of re-running it by
165
165
  # hand). Ultimately we'll move towards a more elegant solution.
166
166
 
167
- bundle exec rake --trace db:create:all test:newrelic || bundle exec rake --trace test:newrelic || bundle exec rake --trace test:newrelic
167
+ bundle exec rake --trace db:create:all test:newrelic || bundle exec rake --trace test:newrelic
data/test/test_helper.rb CHANGED
@@ -3,11 +3,13 @@ ENV['RAILS_ENV'] = 'test'
3
3
  NEWRELIC_PLUGIN_DIR = File.expand_path(File.join(File.dirname(__FILE__),".."))
4
4
  $LOAD_PATH << '.'
5
5
  $LOAD_PATH << '../../..'
6
+ $LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"lib")
6
7
  $LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"test")
7
8
  $LOAD_PATH << File.join(NEWRELIC_PLUGIN_DIR,"ui/helpers")
8
9
  $LOAD_PATH.uniq!
9
10
 
10
11
  require 'rubygems'
12
+ require 'rake'
11
13
  # We can speed things up in tests that don't need to load rails.
12
14
  # You can also run the tests in a mode without rails. Many tests
13
15
  # will be skipped.
@@ -20,29 +22,36 @@ begin
20
22
  rescue LoadError
21
23
  # ignore load problems on test help - it doesn't exist in rails 3
22
24
  end
23
-
24
- rescue LoadError
25
- # To run the tests against a standalone agent build, you need to
26
- # add a rails app to the load path. It can be 2.* to 3.*. It should
27
- # referenc newrelic_rpm in the Gemfile with a :path option pointing
28
- # to this work directory.
29
- guess = File.expand_path("../../../rpm", __FILE__)
30
- if $LOAD_PATH.include? guess
31
- puts "Unable to load Rails for New Relic tests. See note in test_helper.rb"
32
- raise
33
- else
34
- $LOAD_PATH << guess
35
- retry
25
+ require 'newrelic_rpm'
26
+ rescue LoadError => e
27
+ puts "Running tests in standalone mode."
28
+ require 'bundler'
29
+ Bundler.require
30
+ require 'rails/all'
31
+ require 'newrelic_rpm'
32
+
33
+ # Bootstrap a basic rails environment for the agent to run in.
34
+ class MyApp < Rails::Application
35
+ config.active_support.deprecation = :log
36
+ config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
37
+ config.after_initialize do
38
+ NewRelic::Agent.manual_start
39
+ end
36
40
  end
41
+ MyApp.initialize!
42
+
37
43
  end
38
- require 'newrelic_rpm'
39
44
 
40
45
  require 'test/unit'
41
46
  require 'shoulda'
42
47
  require 'test_contexts'
43
48
  require 'mocha'
44
- require 'mocha/integration/test_unit'
45
- require 'mocha/integration/test_unit/assertion_counter'
49
+
50
+ begin # 1.8.6
51
+ require 'mocha/integration/test_unit'
52
+ require 'mocha/integration/test_unit/assertion_counter'
53
+ rescue LoadError
54
+ end
46
55
 
47
56
  require 'new_relic/fake_service'
48
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1.14
4
+ version: 3.5.2.17
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-13 00:00:00.000000000 Z
14
+ date: 2012-11-14 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: ! 'New Relic is a performance management system, developed by New Relic,
17
17
 
@@ -35,16 +35,19 @@ extensions: []
35
35
  extra_rdoc_files:
36
36
  - CHANGELOG
37
37
  - LICENSE
38
- - README.rdoc
38
+ - README.md
39
+ - GUIDELINES_FOR_CONTRIBUTING.md
39
40
  - newrelic.yml
40
41
  files:
41
42
  - .gitignore
42
43
  - .project
44
+ - .travis.yml
43
45
  - CHANGELOG
46
+ - GUIDELINES_FOR_CONTRIBUTING.md
44
47
  - Gemfile
45
48
  - InstallationNotes.md
46
49
  - LICENSE
47
- - README.rdoc
50
+ - README.md
48
51
  - Rakefile
49
52
  - bin/mongrel_rpm
50
53
  - bin/newrelic
@@ -53,6 +56,7 @@ files:
53
56
  - cert/oldsite.pem
54
57
  - cert/site.pem
55
58
  - config.dot
59
+ - config/database.yml
56
60
  - init.rb
57
61
  - install.rb
58
62
  - lib/conditional_vendored_dependency_detection.rb
@@ -171,6 +175,7 @@ files:
171
175
  - test/config/newrelic.yml
172
176
  - test/config/test_control.rb
173
177
  - test/fixtures/proc_cpuinfo.txt
178
+ - test/intentional_fail.rb
174
179
  - test/new_relic/agent/agent/connect_test.rb
175
180
  - test/new_relic/agent/agent/start_test.rb
176
181
  - test/new_relic/agent/agent/start_worker_thread_test.rb