newrelic_rpm 3.3.1.beta2 → 3.3.1

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
@@ -3,6 +3,8 @@ v3.3.1
3
3
  * fix for issues with RAILS_ROOT deprecation warnings
4
4
  * fixed incorrect 1.9 GC time reporting
5
5
  * obfusction for Slow SQL queries respects transaction trace config
6
+ * fix for RUM instrumentation repoting bad timing info in some cases
7
+ * refactored ActiveRecord instrumentation, no longer requires Rails
6
8
 
7
9
  v3.3.0
8
10
  * fix for GC instrumentation when using Ruby 1.9
@@ -1070,9 +1070,6 @@ module NewRelic
1070
1070
  now = Time.now
1071
1071
  log.debug "Sending (#{@traces.length}) transaction traces"
1072
1072
 
1073
- # REMOVE THIS BEFORE SHIPPING
1074
- log.info "Sending tts with GUIDS #{@traces.collect{|t| t.guid}.join(",")}"
1075
-
1076
1073
  begin
1077
1074
  options = { :keep_backtraces => true }
1078
1075
  options[:record_sql] = @record_sql unless @record_sql == :off
@@ -1284,6 +1281,13 @@ module NewRelic
1284
1281
  log.debug "Serializing agent data to disk"
1285
1282
  NewRelic::Agent.save_data
1286
1283
  end
1284
+ rescue Exception => e
1285
+ NewRelic::Control.instance.disable_serialization = true
1286
+ NewRelic::Control.instance.log.warn("Disabling serialization: #{e.message}")
1287
+ retry_count ||= 0
1288
+ retry_count += 1
1289
+ retry unless retry_count > 1
1290
+ raise e
1287
1291
  end
1288
1292
 
1289
1293
  # This method contacts the server to send remaining data and
@@ -33,14 +33,7 @@ module NewRelic
33
33
 
34
34
  # RUM footer command used for 'finish' - based on whether JSONP is
35
35
  # being used. 'nrfj' for JSONP, otherwise 'nrf2'
36
- def finish_command
37
- if NewRelic::Control.instance.fetch('browser_monitoring', {}) \
38
- .fetch('auto_instrument', true)
39
- @finish_command
40
- else
41
- 'nrf2'
42
- end
43
- end
36
+ attr_reader :finish_command
44
37
 
45
38
  # A static javascript header that is identical for every account
46
39
  # and application
@@ -231,8 +231,8 @@ module NewRelic
231
231
  # If a single argument is passed in, it is treated as a metric
232
232
  # path. This form is deprecated.
233
233
  def perform_action_with_newrelic_trace(*args, &block)
234
- NewRelic::Agent::TransactionInfo.reset unless NewRelic::Control.
235
- instance.browser_monitoring_auto_instrument?
234
+ request = newrelic_request(args)
235
+ NewRelic::Agent::TransactionInfo.reset(request)
236
236
 
237
237
  # Skip instrumentation based on the value of 'do_not_trace' and if
238
238
  # we aren't calling directly with a block.
@@ -272,6 +272,22 @@ module NewRelic
272
272
  end
273
273
 
274
274
  protected
275
+
276
+ def newrelic_request(args)
277
+ opts = args.first
278
+ # passed as a parameter to add_transaction_tracer
279
+ if opts.respond_to?(:keys) && opts.respond_to?(:[]) && opts[:request]
280
+ opts[:request]
281
+ # in a Rack app
282
+ elsif opts.respond_to?(:keys) && opts.respond_to?(:[]) &&
283
+ opts['rack.version']
284
+ Rack::Request.new(args)
285
+ # in a Rails app
286
+ elsif self.respond_to?(:request)
287
+ self.request
288
+ end
289
+ end
290
+
275
291
  # Should be implemented in the dispatcher class
276
292
  def newrelic_response_code; end
277
293
 
@@ -28,8 +28,9 @@ DependencyDetection.defer do
28
28
  end
29
29
 
30
30
  executes do
31
- # We're on an older version of passenger
32
- NewRelic::Agent.logger.warn "An older version of Phusion Passenger has been detected. We recommend using at least release 2.1.1."
31
+ ## We're on an older version of passenger
32
+ ## FIXME: This warning is printing on current version of passenger
33
+ # NewRelic::Agent.logger.warn "An older version of Phusion Passenger has been detected. We recommend using at least release 2.1.1."
33
34
 
34
35
  NewRelic::Agent::Instrumentation::MetricFrame.check_server_connection = true
35
36
  end
@@ -45,11 +45,22 @@ module NewRelic
45
45
 
46
46
  # clears any existing transaction info object and initializes a new one.
47
47
  # This starts the timer for the transaction.
48
- def self.reset
48
+ def self.reset(request=nil)
49
49
  clear
50
- get
51
- end
50
+ instance = get
52
51
 
52
+ if request
53
+ agent_flag = request.cookies['NRAGENT']
54
+ if agent_flag
55
+ s = agent_flag.split("=")
56
+ if s.length == 2
57
+ if s[0] == "tk" && s[1]
58
+ instance.token = s[1]
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
53
64
  end
54
65
  end
55
66
  end
@@ -84,6 +84,8 @@ module NewRelic
84
84
  rescue Exception => e
85
85
  NewRelic::Control.instance.log.error("Error serializing data to disk: #{e.inspect}")
86
86
  NewRelic::Control.instance.log.debug(e.backtrace.split("\n"))
87
+ # re-raise so that serialization will be disabled higher up the stack
88
+ raise e
87
89
  end
88
90
 
89
91
  def get_data_from_file(f)
@@ -27,13 +27,16 @@ module NewRelic::LanguageSupport
27
27
  def self.included(base)
28
28
  # need to use syck rather than psych when possible
29
29
  if defined?(::YAML::ENGINE)
30
- base.class_eval do
31
- def load_newrelic_yml(*args)
32
- yamler = ::YAML::ENGINE.yamler
33
- ::YAML::ENGINE.yamler = 'syck'
34
- val = super
35
- ::YAML::ENGINE.yamler = yamler
36
- val
30
+ unless NewRelic::LanguageSupport.using_engine?('jruby') &&
31
+ NewRelic::LanguageSupport.using_version?('1.9')
32
+ base.class_eval do
33
+ def load_newrelic_yml(*args)
34
+ yamler = ::YAML::ENGINE.yamler
35
+ ::YAML::ENGINE.yamler = 'syck'
36
+ val = super
37
+ ::YAML::ENGINE.yamler = yamler
38
+ val
39
+ end
37
40
  end
38
41
  end
39
42
  end
@@ -9,33 +9,16 @@ module NewRelic::Rack
9
9
 
10
10
  # method required by Rack interface
11
11
  def call(env)
12
-
13
- req = Rack::Request.new(env)
14
-
15
- # clear any previous transaction info
16
- NewRelic::Agent::TransactionInfo.reset
17
-
18
- agent_flag = req.cookies['NRAGENT']
19
-
20
- if agent_flag
21
- s = agent_flag.split("=")
22
- if s.length == 2
23
- if s[0] == "tk" && s[1]
24
- NewRelic::Agent::TransactionInfo.get.token = s[1]
25
- end
26
- end
27
- end
28
-
29
12
  # Two experimental options for allowing TT capture based on http params
30
13
  #
31
- if req.params['nr_capture_deep_tt']
14
+ # if req.params['nr_capture_deep_tt']
32
15
  # NewRelic::Agent::TransactionInfo.get.force_persist = true
33
16
  # NewRelic::Agent::TransactionInfo.get.capture_deep_tt = true
34
- end
17
+ # end
35
18
 
36
- if req.params['nr_capture_tt']
19
+ # if req.params['nr_capture_tt']
37
20
  # NewRelic::Agent::TransactionInfo.get.force_persist = true
38
- end
21
+ # end
39
22
 
40
23
  result = @app.call(env) # [status, headers, response]
41
24
 
@@ -44,12 +27,6 @@ module NewRelic::Rack
44
27
 
45
28
  if response_string
46
29
  response = Rack::Response.new(response_string, result[0], result[1])
47
-
48
- if NewRelic::Agent::TransactionInfo.get.token
49
- # clear the cookie via expiration in the past
50
- response.set_cookie("NRAGENT", {:value => "tk=", :path => "/", :expires => Time.now-(24* 60*60)})
51
- end
52
-
53
30
  response.finish
54
31
  else
55
32
  result
@@ -4,7 +4,7 @@ module NewRelic
4
4
  MAJOR = 3
5
5
  MINOR = 3
6
6
  TINY = 1
7
- BUILD = 'beta2' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
7
+ BUILD = nil # 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_rpm.gemspec CHANGED
@@ -4,15 +4,21 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "newrelic_rpm"
8
- s.version = "3.3.1.beta2"
7
+ s.name = %q{newrelic_rpm}
8
+ s.version = "3.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
12
- s.date = "2011-11-29"
13
- s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). New Relic provides you with deep\ninformation about the performance of your web application as it runs\nin production. The New Relic Ruby Agent is dual-purposed as a either a\nGem or plugin, hosted on\nhttp://github.com/newrelic/rpm/\n"
14
- s.email = "support@newrelic.com"
15
- s.executables = ["mongrel_rpm", "newrelic", "newrelic_cmd"]
12
+ s.date = %q{2011-12-15}
13
+ s.description = %q{New Relic is a performance management system, developed by New Relic,
14
+ Inc (http://www.newrelic.com). New Relic provides you with deep
15
+ information about the performance of your web application as it runs
16
+ in production. The New Relic Ruby Agent is dual-purposed as a either a
17
+ Gem or plugin, hosted on
18
+ http://github.com/newrelic/rpm/
19
+ }
20
+ s.email = %q{support@newrelic.com}
21
+ s.executables = ["newrelic_cmd", "newrelic", "mongrel_rpm"]
16
22
  s.extra_rdoc_files = [
17
23
  "CHANGELOG",
18
24
  "LICENSE",
@@ -11,7 +11,7 @@ class NewRelic::Agent::BrowserMonitoringTest < Test::Unit::TestCase
11
11
  @browser_monitoring_key = "fred"
12
12
  @episodes_file = "this_is_my_file"
13
13
  NewRelic::Agent.instance.instance_eval do
14
- @beacon_configuration = NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => true, "browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file"})
14
+ @beacon_configuration = NewRelic::Agent::BeaconConfiguration.new({"rum.enabled" => true, "browser_key" => "browserKey", "application_id" => "apId", "beacon"=>"beacon", "episodes_url"=>"this_is_my_file", 'rum.jsonp' => true})
15
15
  end
16
16
  Thread.current[:last_metric_frame] = nil
17
17
  NewRelic::Agent::TransactionInfo.clear
@@ -286,12 +286,6 @@ var e=document.createElement("script");'
286
286
  assert_equal("<script type=\"text/javascript\">if (!NREUMQ.f) { NREUMQ.f=function() {\nNREUMQ.push([\"load\",new Date().getTime()]);\nvar e=document.createElement(\"script\");\ne.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";\ndocument.body.appendChild(e);\nif(NREUMQ.a)NREUMQ.a();\n};\nNREUMQ.a=window.onload;window.onload=NREUMQ.f;\n};\nNREUMQ.push([\"nrfj\",\"\",\"\",1,\"most recent transaction\",0,0,new Date().getTime(),\"ABC\",\"0123456789ABCDEF\",\"user\",\"account\",\"product\"])</script>", value, "should return the javascript given some default values")
287
287
  end
288
288
 
289
- def test_use_nrf2_footer_when_auto_rum_disabled
290
- NewRelic::Control.instance['browser_monitoring'] = { 'auto_instrument' => false }
291
- value = footer_js_string(NewRelic::Agent.instance.beacon_configuration, '', '', 1)
292
- assert_match(/nrf2/, value, "footer should use nrf2 when auto-rum disabled")
293
- end
294
-
295
289
  def test_html_safe_if_needed_unsafed
296
290
  string = mock('string')
297
291
  # here to handle 1.9 encoding - we stub this out because it should
@@ -151,6 +151,18 @@ module NewRelic
151
151
  assert_equal(NewRelic::Agent.agent, NewRelic::Agent.instance, "should return the same agent for both identical methods")
152
152
  end
153
153
 
154
+ def test_load_data_should_disable_serialization_if_an_error_is_encountered
155
+ NewRelic::Control.instance['disable_serialization'] = false
156
+ NewRelic::DataSerialization.stubs(:should_send_data?).returns(false)
157
+ NewRelic::Agent.stubs(:save_data).raises(Errno::EACCES)
158
+ begin
159
+ NewRelic::Agent.instance.send(:save_or_transmit_data)
160
+ rescue Errno::EACCES; end
161
+ # should be true
162
+ assert(NewRelic::Control.instance['disable_serialization'])
163
+ NewRelic::Control.instance['disable_serialization'] = false
164
+ end
165
+
154
166
  def test_load_data_should_not_write_files_when_serialization_disabled
155
167
  NewRelic::Control.instance['disable_serialization'] = true
156
168
  NewRelic::DataSerialization.expects(:read_and_write_to_file).never
@@ -17,8 +17,6 @@ class BrowserMonitoringTest < Test::Unit::TestCase
17
17
  include Rack::Test::Methods
18
18
 
19
19
  class TestApp
20
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
21
-
22
20
  def self.doc=(other)
23
21
  @@doc = other
24
22
  end
@@ -38,7 +36,7 @@ class BrowserMonitoringTest < Test::Unit::TestCase
38
36
  EOL
39
37
  [200, {'Content-Type' => 'text/html'}, Rack::Response.new(@@doc)]
40
38
  end
41
- add_transaction_tracer :call, :category => :rack
39
+ include NewRelic::Agent::Instrumentation::Rack
42
40
  end
43
41
 
44
42
  def app
metadata CHANGED
@@ -1,10 +1,15 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
- version: !ruby/object:Gem::Version
4
- version: 3.3.1.beta2
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 3
8
+ - 3
9
+ - 1
10
+ version: 3.3.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Bill Kayser
9
14
  - Jon Guymon
10
15
  - Justin George
@@ -12,66 +17,73 @@ authors:
12
17
  autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
- date: 2011-11-29 00:00:00.000000000 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
20
+
21
+ date: 2011-12-15 00:00:00 -08:00
22
+ default_executable:
23
+ dependencies:
24
+ - !ruby/object:Gem::Dependency
18
25
  name: jeweler
19
- requirement: &2153088200 !ruby/object:Gem::Requirement
26
+ prerelease: false
27
+ requirement: &id001 !ruby/object:Gem::Requirement
20
28
  none: false
21
- requirements:
22
- - - ! '>='
23
- - !ruby/object:Gem::Version
24
- version: '0'
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ hash: 3
33
+ segments:
34
+ - 0
35
+ version: "0"
25
36
  type: :development
26
- prerelease: false
27
- version_requirements: *2153088200
28
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
29
39
  name: mocha
30
- requirement: &2153087680 !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
31
42
  none: false
32
- requirements:
33
- - - ! '>='
34
- - !ruby/object:Gem::Version
35
- version: '0'
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
36
50
  type: :development
37
- prerelease: false
38
- version_requirements: *2153087680
39
- - !ruby/object:Gem::Dependency
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
40
53
  name: shoulda
41
- requirement: &2153087180 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
42
56
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
47
64
  type: :development
48
- prerelease: false
49
- version_requirements: *2153087180
50
- description: ! 'New Relic is a performance management system, developed by New Relic,
51
-
65
+ version_requirements: *id003
66
+ description: |
67
+ New Relic is a performance management system, developed by New Relic,
52
68
  Inc (http://www.newrelic.com). New Relic provides you with deep
53
-
54
69
  information about the performance of your web application as it runs
55
-
56
70
  in production. The New Relic Ruby Agent is dual-purposed as a either a
57
-
58
71
  Gem or plugin, hosted on
59
-
60
72
  http://github.com/newrelic/rpm/
61
73
 
62
- '
63
74
  email: support@newrelic.com
64
- executables:
65
- - mongrel_rpm
66
- - newrelic
75
+ executables:
67
76
  - newrelic_cmd
77
+ - newrelic
78
+ - mongrel_rpm
68
79
  extensions: []
69
- extra_rdoc_files:
80
+
81
+ extra_rdoc_files:
70
82
  - CHANGELOG
71
83
  - LICENSE
72
84
  - README.rdoc
73
85
  - newrelic.yml
74
- files:
86
+ files:
75
87
  - CHANGELOG
76
88
  - LICENSE
77
89
  - README.rdoc
@@ -330,40 +342,63 @@ files:
330
342
  - vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb
331
343
  - vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb
332
344
  - vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb
345
+ has_rdoc: true
333
346
  homepage: http://www.github.com/newrelic/rpm
334
347
  licenses: []
335
- post_install_message: ! "\nPLEASE NOTE:\n\nDeveloper Mode is now a Rack middleware.\n\nDeveloper
336
- Mode is no longer available in Rails 2.1 and earlier.\nHowever, starting in version
337
- 2.12 you can use Developer Mode in any\nRack based framework, in addition to Rails.
338
- \ To install developer mode\nin a non-Rails application, just add NewRelic::Rack::DeveloperMode
339
- to\nyour middleware stack.\n\nIf you are using JRuby, we recommend using at least
340
- version 1.4 or \nlater because of issues with the implementation of the timeout
341
- library.\n\nRefer to the README.md file for more information.\n\nPlease see http://github.com/newrelic/rpm/blob/master/CHANGELOG\nfor
342
- a complete description of the features and enhancements available\nin version 3.3
343
- of the Ruby Agent.\n \n"
344
- rdoc_options:
348
+
349
+ post_install_message: |
350
+
351
+ PLEASE NOTE:
352
+
353
+ Developer Mode is now a Rack middleware.
354
+
355
+ Developer Mode is no longer available in Rails 2.1 and earlier.
356
+ However, starting in version 2.12 you can use Developer Mode in any
357
+ Rack based framework, in addition to Rails. To install developer mode
358
+ in a non-Rails application, just add NewRelic::Rack::DeveloperMode to
359
+ your middleware stack.
360
+
361
+ If you are using JRuby, we recommend using at least version 1.4 or
362
+ later because of issues with the implementation of the timeout library.
363
+
364
+ Refer to the README.md file for more information.
365
+
366
+ Please see http://github.com/newrelic/rpm/blob/master/CHANGELOG
367
+ for a complete description of the features and enhancements available
368
+ in version 3.3 of the Ruby Agent.
369
+
370
+
371
+ rdoc_options:
345
372
  - --line-numbers
346
373
  - --inline-source
347
374
  - --title
348
375
  - New Relic Ruby Agent
349
- require_paths:
376
+ require_paths:
350
377
  - lib
351
- required_ruby_version: !ruby/object:Gem::Requirement
378
+ required_ruby_version: !ruby/object:Gem::Requirement
352
379
  none: false
353
- requirements:
354
- - - ! '>='
355
- - !ruby/object:Gem::Version
356
- version: '0'
357
- required_rubygems_version: !ruby/object:Gem::Requirement
380
+ requirements:
381
+ - - ">="
382
+ - !ruby/object:Gem::Version
383
+ hash: 3
384
+ segments:
385
+ - 0
386
+ version: "0"
387
+ required_rubygems_version: !ruby/object:Gem::Requirement
358
388
  none: false
359
- requirements:
360
- - - ! '>='
361
- - !ruby/object:Gem::Version
362
- version: '0'
389
+ requirements:
390
+ - - ">="
391
+ - !ruby/object:Gem::Version
392
+ hash: 3
393
+ segments:
394
+ - 0
395
+ version: "0"
363
396
  requirements: []
397
+
364
398
  rubyforge_project:
365
- rubygems_version: 1.8.10
399
+ rubygems_version: 1.4.2
366
400
  signing_key:
367
401
  specification_version: 3
368
402
  summary: New Relic Ruby Agent
369
403
  test_files: []
404
+