newrelic_rpm 2.11.1 → 2.11.2.beta

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/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v2.11.2
2
+ * fix for unicorn not reporting when the proc line had 'master' in it
3
+ * allow overriding the log file directory via 'log_file_path' in newrelic.yml
4
+ * allow overriding the log name via 'log_file_name' in newrelic.yml
5
+ * fix for over detection of spawner in passenger 2.0
6
+
1
7
  v2.11.1
2
8
  * republished gem without generated rdocs
3
9
 
@@ -191,10 +191,6 @@ module NewRelic
191
191
  # Register this method as a callback for processes that fork
192
192
  # jobs.
193
193
  #
194
- # Pass <tt>:force_reconnect => true</tt> to force the agent to
195
- # reconnect to the server and start a worker loop for sending
196
- # data.
197
- #
198
194
  # If the master/parent connects to the agent prior to forking the
199
195
  # agent in the forked process will use that agent_run. Otherwise
200
196
  # the forked process will establish a new connection with the
@@ -205,6 +201,15 @@ module NewRelic
205
201
  # that forks worker processes then you will need to force the
206
202
  # agent to reconnect, which it won't do by default. Passenger and
207
203
  # Unicorn are already handled, nothing special needed for them.
204
+ #
205
+ # Options:
206
+ # * <tt>:force_reconnect => true</tt> to force the spawned process to
207
+ # establish a new connection, such as when forking a long running process.
208
+ # The default is false--it will only connect to the server if the parent
209
+ # had not connected.
210
+ # * <tt>:keep_retrying => false</tt> if we try to initiate a new
211
+ # connection, this tells me to only try it once so this method returns
212
+ # quickly if there is some kind of latency with the server.
208
213
  def after_fork(options={})
209
214
  agent.after_fork(options)
210
215
  end
@@ -53,7 +53,15 @@ module NewRelic
53
53
  # * Restarts the sampler thread if necessary
54
54
  # * Initiates a new agent run and worker loop unless that was done
55
55
  # in the parent process and +:force_reconnect+ is not true
56
- #
56
+ #
57
+ # Options:
58
+ # * <tt>:force_reconnect => true</tt> to force the spawned process to
59
+ # establish a new connection, such as when forking a long running process.
60
+ # The default is false--it will only connect to the server if the parent
61
+ # had not connected.
62
+ # * <tt>:keep_retrying => false</tt> if we try to initiate a new
63
+ # connection, this tells me to only try it once so this method returns
64
+ # quickly if there is some kind of latency with the server.
57
65
  def after_fork(options={})
58
66
 
59
67
  # @connected gets false after we fail to connect or have an error
@@ -70,7 +78,10 @@ module NewRelic
70
78
 
71
79
  # Clear out stats that are left over from parent process
72
80
  reset_stats
73
- start_worker_thread(options[:force_reconnect])
81
+
82
+ # Don't ever check to see if this is a spawner. If we're in a forked process
83
+ # I'm pretty sure we're not also forking new instances.
84
+ start_worker_thread(options.merge(:check_for_spawner => false))
74
85
  @stats_engine.start_sampler_thread
75
86
  end
76
87
 
@@ -204,7 +215,7 @@ module NewRelic
204
215
  control.log! "Invalid license key: #{control.license_key}", :error
205
216
  else
206
217
  # Do the connect in the foreground if we are in sync mode
207
- NewRelic::Agent.disable_all_tracing { connect(false) } if control.sync_startup
218
+ NewRelic::Agent.disable_all_tracing { connect(:keep_retrying => false) } if control.sync_startup
208
219
 
209
220
  # Start the event loop and initiate connection if necessary
210
221
  start_worker_thread
@@ -240,8 +251,10 @@ module NewRelic
240
251
  @collector ||= control.server
241
252
  end
242
253
 
243
- # Try to launch the worker thread and connect to the server
244
- def start_worker_thread(force_reconnect=false)
254
+ # Try to launch the worker thread and connect to the server.
255
+ #
256
+ # See #connect for a description of connection_options.
257
+ def start_worker_thread(connection_options = {})
245
258
  log.debug "Creating RPM worker thread."
246
259
  @worker_thread = Thread.new do
247
260
  begin
@@ -250,7 +263,7 @@ module NewRelic
250
263
  # the server rejected us for a licensing reason and we should
251
264
  # just exit the thread. If it returns nil
252
265
  # that means it didn't try to connect because we're in the master.
253
- connect if !@connected or force_reconnect
266
+ connect(connection_options)
254
267
  if @connected
255
268
  # disable transaction sampling if disabled by the server and we're not in dev mode
256
269
  if !control.developer_mode? && !@should_send_samples
@@ -327,8 +340,22 @@ module NewRelic
327
340
  # Set keep_retrying=false to disable retrying and return asap, such as when
328
341
  # invoked in the foreground. Otherwise this runs until a successful
329
342
  # connection is made, or the server rejects us.
343
+ #
344
+ # * <tt>:keep_retrying => false</tt> to only try to connect once, and
345
+ # return with the connection set to nil. This ensures we may try again
346
+ # later (default true).
347
+ # * <tt>force_reconnect => true</tt> if you want to establish a new connection
348
+ # to the server before running the worker loop. This means you get a separate
349
+ # agent run and RPM sees it as a separate instance (default is false).
350
+ # * <tt>:check_for_spawner => false</tt> to omit the check to see if we are
351
+ # an application spawner. We detect the spawner and stop the agent so we don't
352
+ # report stats from a spawner. You don't want to do this check if you _know_
353
+ # you are not in a spawner (default is true).
330
354
 
331
- def connect(keep_retrying = true)
355
+ def connect(options)
356
+ return if @connected && !options[:force_reconnect]
357
+ keep_retrying = options[:keep_retrying].nil? || options[:keep_retrying]
358
+ check_for_spawner = options[:check_for_spawner].nil? || options[:check_for_spawner]
332
359
 
333
360
  # wait a few seconds for the web server to boot, necessary in development
334
361
  connect_retry_period = keep_retrying ? 10 : 0
@@ -337,7 +364,7 @@ module NewRelic
337
364
  begin
338
365
  sleep connect_retry_period.to_i
339
366
  # Running in the Passenger or Unicorn spawners?
340
- if $0 =~ /ApplicationSpawner|unicorn.* master/
367
+ if check_for_spawner && $0 =~ /ApplicationSpawner|^unicorn\S* master/
341
368
  log.debug "Process is master spawner (#$0) -- don't connect to RPM service"
342
369
  @connected = nil
343
370
  return
@@ -315,7 +315,7 @@ module Agent
315
315
  alias_method method_name, _traced_method_name(method_name, metric_name_code)
316
316
 
317
317
  NewRelic::Control.instance.log.debug("Traced method: class = #{self.name}, method = #{method_name}, "+
318
- "metric = '#{metric_name_code}', options: #{options.inspect}")
318
+ "metric = '#{metric_name_code}'")
319
319
  end
320
320
 
321
321
  # For tests only because tracers must be removed in reverse-order
@@ -33,7 +33,8 @@ module NewRelic
33
33
  # strip newrelic from the trace
34
34
  backtrace = backtrace.reject {|line| line =~ /new_relic\/agent\// }
35
35
  # rename methods back to their original state
36
- backtrace = backtrace.collect {|line| line.gsub(/_without_(newrelic|trace)/, "")}
36
+ # GJV - 4/6/10 - adding .to_s call since we were seeing line as a Fixnum in some cases
37
+ backtrace = backtrace.collect {|line| line.to_s.gsub(/_without_(newrelic|trace)/, "")}
37
38
  end
38
39
  backtrace
39
40
  end
@@ -121,11 +121,11 @@ module NewRelic
121
121
  "Set the application name.",
122
122
  "Default is app_name setting in newrelic.yml") { | e | @appname = e }
123
123
  o.on("-e", "--environment=name", String,
124
- "Override the (RAILS|MERB|RUBY)_ENV setting",
124
+ "Override the (RAILS|MERB|RUBY|RACK)_ENV setting",
125
125
  "currently: #{config.env}") { | e | @environment = e }
126
126
  o.on("-u", "--user=USER", String,
127
- "Specify the user deploying.",
128
- "Default: #{@user}") { | u | @user = u }
127
+ "Specify the user deploying, for information only",
128
+ "Default: #{@user || '<none>'}") { | u | @user = u }
129
129
  o.on("-r", "--revision=REV", String,
130
130
  "Specify the revision being deployed") { | r | @revision = r }
131
131
  o.on("-c", "--changes",
@@ -232,7 +232,7 @@ module NewRelic
232
232
  #this can only be on when SSL is enabled
233
233
  @verify_certificate ||= ( use_ssl? ? fetch('verify_certificate', false) : false)
234
234
  end
235
-
235
+
236
236
  def server
237
237
  @remote_server ||= server_from_host(nil)
238
238
  end
@@ -405,7 +405,7 @@ module NewRelic
405
405
 
406
406
  # Control subclasses may override this, but it can be called multiple times.
407
407
  def setup_log
408
- @log_file = "#{log_path}/newrelic_agent.log"
408
+ @log_file = "#{log_path}/#{log_file_name}"
409
409
  @log = Logger.new @log_file
410
410
 
411
411
  # change the format just for our logger
@@ -435,11 +435,17 @@ module NewRelic
435
435
  end
436
436
 
437
437
  def log_path
438
- path = File.join(root,'log')
439
- unless File.directory? path
440
- path = '.'
441
- end
442
- File.expand_path(path)
438
+ @log_path ||= begin
439
+ path = self['log_file_path'] || File.join(root,'log')
440
+ unless File.directory? path
441
+ path = '.'
442
+ end
443
+ File.expand_path(path)
444
+ end
445
+ end
446
+
447
+ def log_file_name
448
+ @log_file_name ||= fetch('log_file_name', 'newrelic_agent.log')
443
449
  end
444
450
 
445
451
  # Create the concrete class for environment specific behavior:
@@ -11,9 +11,9 @@ class NewRelic::Control::Rails < NewRelic::Control
11
11
  end
12
12
 
13
13
  def log_path
14
- path = ::RAILS_DEFAULT_LOGGER.instance_eval do
14
+ path = super || ::RAILS_DEFAULT_LOGGER.instance_eval do
15
15
  File.dirname(@log.path) rescue File.dirname(@logdev.filename)
16
- end rescue "#{root}/log"
16
+ end rescue File.join(root, 'log')
17
17
  File.expand_path(path)
18
18
  end
19
19
  # In versions of Rails prior to 2.0, the rails config was only available to
@@ -3,8 +3,8 @@ module NewRelic
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 2
5
5
  MINOR = 11
6
- TINY = 1
7
- BUILD = nil # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
6
+ TINY = 2
7
+ BUILD = 'beta' #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
10
10
 
data/newrelic.yml CHANGED
@@ -47,6 +47,11 @@ common: &default_settings
47
47
  # information separate from that of your application. Specify its
48
48
  # log level here.
49
49
  log_level: info
50
+
51
+ # If you wish to override the location of the log file, you can
52
+ # uncomment this
53
+ # log_file_path: /var/log
54
+ # log_file_name: newrelic_agent.log
50
55
 
51
56
  # The newrelic agent communicates with the RPM service via http by
52
57
  # default. If you want to communicate via https to increase
data/newrelic_rpm.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{newrelic_rpm}
8
- s.version = "2.11.1"
8
+ s.version = "2.11.2.beta"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bill Kayser"]
12
- s.date = %q{2010-04-02}
12
+ s.date = %q{2010-04-08}
13
13
  s.description = %q{New Relic RPM is a Ruby performance management system, developed by
14
14
  New Relic, Inc (http://www.newrelic.com). RPM provides you with deep
15
15
  information about the performance of your Ruby on Rails or Merb
@@ -206,9 +206,12 @@ For details on this specific release, refer to the CHANGELOG file.
206
206
  s.specification_version = 3
207
207
 
208
208
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
209
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
209
210
  else
211
+ s.add_dependency(%q<jeweler>, [">= 0"])
210
212
  end
211
213
  else
214
+ s.add_dependency(%q<jeweler>, [">= 0"])
212
215
  end
213
216
  end
214
217
 
@@ -1,4 +1,5 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'../../lib/new_relic/commands/deployments'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__),'/../../lib/new_relic/command'))
2
3
  require 'rubygems'
3
4
  require 'mocha'
4
5
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 2
7
7
  - 11
8
- - 1
9
- version: 2.11.1
8
+ - 2
9
+ - beta
10
+ version: 2.11.2.beta
10
11
  platform: ruby
11
12
  authors:
12
13
  - Bill Kayser
@@ -14,10 +15,21 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-02 00:00:00 -07:00
18
+ date: 2010-04-08 00:00:00 -07:00
18
19
  default_executable:
19
- dependencies: []
20
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: jeweler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :development
32
+ version_requirements: *id001
21
33
  description: |
22
34
  New Relic RPM is a Ruby performance management system, developed by
23
35
  New Relic, Inc (http://www.newrelic.com). RPM provides you with deep
@@ -227,11 +239,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
239
  version: "0"
228
240
  required_rubygems_version: !ruby/object:Gem::Requirement
229
241
  requirements:
230
- - - ">="
242
+ - - ">"
231
243
  - !ruby/object:Gem::Version
232
244
  segments:
233
- - 0
234
- version: "0"
245
+ - 1
246
+ - 3
247
+ - 1
248
+ version: 1.3.1
235
249
  requirements: []
236
250
 
237
251
  rubyforge_project: