newrelic_rpm 3.6.0.83 → 3.6.1.85.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/CHANGELOG +27 -0
  2. data/Gemfile +2 -7
  3. data/README.md +1 -1
  4. data/lib/new_relic/agent/agent.rb +3 -2
  5. data/lib/new_relic/agent/autostart.rb +56 -0
  6. data/lib/new_relic/agent/browser_monitoring.rb +19 -14
  7. data/lib/new_relic/agent/configuration/defaults.rb +12 -2
  8. data/lib/new_relic/agent/configuration/environment_source.rb +4 -1
  9. data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
  10. data/lib/new_relic/agent/cross_app_tracing.rb +19 -10
  11. data/lib/new_relic/agent/error_collector.rb +5 -4
  12. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +204 -0
  13. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +88 -0
  14. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
  15. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  16. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +84 -0
  17. data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +3 -2
  18. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +104 -87
  19. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +91 -0
  20. data/lib/new_relic/agent/instrumentation/memcache.rb +4 -4
  21. data/lib/new_relic/agent/instrumentation/merb/errors.rb +4 -4
  22. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +20 -20
  24. data/lib/new_relic/agent/instrumentation/rails/errors.rb +5 -5
  25. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +3 -3
  26. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +3 -25
  27. data/lib/new_relic/agent/instrumentation/rails4/action_view.rb +2 -115
  28. data/lib/new_relic/agent/instrumentation/rails4/active_record.rb +2 -82
  29. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +3 -4
  30. data/lib/new_relic/agent/method_tracer.rb +93 -56
  31. data/lib/new_relic/agent/null_logger.rb +6 -0
  32. data/lib/new_relic/agent/samplers/cpu_sampler.rb +9 -4
  33. data/lib/new_relic/agent/sql_sampler.rb +10 -6
  34. data/lib/new_relic/agent/stats_engine/metric_stats.rb +19 -3
  35. data/lib/new_relic/agent/stats_engine/transactions.rb +53 -34
  36. data/lib/new_relic/agent/system_info.rb +54 -0
  37. data/lib/new_relic/agent/thread.rb +2 -2
  38. data/lib/new_relic/agent/transaction/pop.rb +52 -0
  39. data/lib/new_relic/agent/transaction.rb +388 -0
  40. data/lib/new_relic/agent/transaction_info.rb +5 -13
  41. data/lib/new_relic/agent/transaction_sample_builder.rb +13 -20
  42. data/lib/new_relic/agent/transaction_sampler.rb +13 -15
  43. data/lib/new_relic/agent/uri_util.rb +35 -0
  44. data/lib/new_relic/agent.rb +54 -11
  45. data/lib/new_relic/build.rb +2 -2
  46. data/lib/new_relic/control/frameworks/rails.rb +0 -1
  47. data/lib/new_relic/control/frameworks/rails3.rb +2 -0
  48. data/lib/new_relic/control/frameworks/rails4.rb +0 -4
  49. data/lib/new_relic/control/instance_methods.rb +5 -19
  50. data/lib/new_relic/control/server_methods.rb +2 -0
  51. data/lib/new_relic/environment_report.rb +4 -34
  52. data/lib/new_relic/latest_changes.rb +1 -1
  53. data/lib/new_relic/local_environment.rb +0 -6
  54. data/lib/new_relic/metric_spec.rb +2 -2
  55. data/lib/new_relic/rack/error_collector.rb +6 -4
  56. data/lib/new_relic/transaction_sample.rb +7 -1
  57. data/lib/new_relic/version.rb +1 -1
  58. data/lib/newrelic_rpm.rb +2 -2
  59. data/newrelic.yml +20 -20
  60. data/test/config/test_control.rb +2 -2
  61. data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -1
  62. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -2
  63. data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
  64. data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -3
  65. data/test/multiverse/suites/agent_only/rename_rule_test.rb +2 -0
  66. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +96 -0
  67. data/test/multiverse/suites/agent_only/testing_app.rb +1 -0
  68. data/test/multiverse/suites/rails/error_tracing_test.rb +17 -29
  69. data/test/multiverse/suites/rails/queue_time_test.rb +8 -2
  70. data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -3
  71. data/test/multiverse/suites/resque/instrumentation_test.rb +1 -1
  72. data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +8 -0
  73. data/test/new_relic/agent/agent/connect_test.rb +2 -1
  74. data/test/new_relic/agent/agent/start_test.rb +0 -10
  75. data/test/new_relic/agent/agent_logger_test.rb +15 -0
  76. data/test/new_relic/agent/agent_test_controller.rb +6 -2
  77. data/test/new_relic/agent/agent_test_controller_test.rb +20 -69
  78. data/test/new_relic/agent/autostart_test.rb +67 -0
  79. data/test/new_relic/agent/browser_monitoring_test.rb +60 -38
  80. data/test/new_relic/agent/configuration/environment_source_test.rb +19 -17
  81. data/test/new_relic/agent/cross_app_monitor_test.rb +8 -0
  82. data/test/new_relic/agent/error_collector/notice_error_test.rb +0 -5
  83. data/test/new_relic/agent/error_collector_test.rb +8 -9
  84. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +228 -0
  85. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +18 -34
  86. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +5 -5
  87. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +8 -9
  88. data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +1 -1
  89. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +24 -38
  90. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +126 -178
  91. data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
  92. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +135 -151
  93. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +153 -81
  94. data/test/new_relic/agent/method_tracer_test.rb +42 -33
  95. data/test/new_relic/agent/mock_scope_listener.rb +4 -4
  96. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -2
  97. data/test/new_relic/agent/rpm_agent_test.rb +86 -89
  98. data/test/new_relic/agent/sql_sampler_test.rb +18 -19
  99. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +5 -8
  100. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +20 -8
  101. data/test/new_relic/agent/stats_engine/samplers_test.rb +31 -14
  102. data/test/new_relic/agent/stats_engine_test.rb +53 -60
  103. data/test/new_relic/agent/thread_test.rb +7 -7
  104. data/test/new_relic/agent/transaction/pop_test.rb +96 -0
  105. data/test/new_relic/agent/transaction_info_test.rb +6 -17
  106. data/test/new_relic/agent/transaction_sample_builder_test.rb +10 -18
  107. data/test/new_relic/agent/transaction_sampler_test.rb +80 -75
  108. data/test/new_relic/agent/{instrumentation/metric_frame_test.rb → transaction_test.rb} +76 -42
  109. data/test/new_relic/agent/uri_util_test.rb +75 -0
  110. data/test/new_relic/agent_test.rb +115 -9
  111. data/test/test_helper.rb +138 -9
  112. data.tar.gz.sig +0 -0
  113. metadata +37 -74
  114. metadata.gz.sig +0 -0
  115. data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +0 -84
  116. data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -353
  117. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -175
  118. data/test/test_contexts.rb +0 -34
@@ -15,6 +15,7 @@ module NewRelic
15
15
 
16
16
  # Module defining methods stubbed out when the agent is disabled
17
17
  module Shim #:nodoc:
18
+ def notice_transaction(*args); end
18
19
  def notice_first_scope_push(*args); end
19
20
  def notice_push_scope(*args); end
20
21
  def notice_pop_scope(*args); end
@@ -94,12 +95,14 @@ module NewRelic
94
95
  #
95
96
  # Note that in developer mode, this captures a stacktrace for
96
97
  # the beginning of each segment, which can be fairly slow
97
- def notice_push_scope(scope, time=Time.now)
98
+ def notice_push_scope(time=Time.now)
98
99
  return unless builder
99
100
 
100
- builder.trace_entry(scope, time.to_f)
101
+ segment = builder.trace_entry(time.to_f)
101
102
 
102
103
  capture_segment_trace if Agent.config[:developer_mode]
104
+
105
+ return segment
103
106
  end
104
107
 
105
108
  # in developer mode, capture the stack trace with the segment.
@@ -120,12 +123,6 @@ module NewRelic
120
123
  end
121
124
  end
122
125
 
123
- # Rename the latest scope's segment in the builder to +new_name+.
124
- def rename_scope_segment( new_name )
125
- return unless builder
126
- builder.rename_current_segment( new_name )
127
- end
128
-
129
126
  # Defaults to zero, otherwise delegated to the transaction
130
127
  # sample builder
131
128
  def scope_depth
@@ -149,18 +146,19 @@ module NewRelic
149
146
  #
150
147
  # It sets various instance variables to the finished sample,
151
148
  # depending on which settings are active. See `store_sample`
152
- def notice_scope_empty(time=Time.now)
149
+ def notice_scope_empty(txn, time=Time.now, gc_time=nil)
153
150
  last_builder = builder
151
+ last_builder.set_transaction_name(txn.name) if enabled? && last_builder
152
+
154
153
  return unless last_builder
155
154
 
156
- last_builder.finish_trace(time.to_f)
155
+ last_builder.finish_trace(time.to_f, txn.custom_parameters)
157
156
  clear_builder
158
157
  return if last_builder.ignored?
159
158
 
160
159
  @samples_lock.synchronize do
161
- # NB this instance variable may be used elsewhere, it's not
162
- # just a side effect
163
160
  @last_sample = last_builder.sample
161
+ @last_sample.set_custom_param(:gc_time, gc_time) if gc_time
164
162
  store_sample(@last_sample)
165
163
  end
166
164
  end
@@ -234,10 +232,10 @@ module NewRelic
234
232
  end
235
233
  end
236
234
 
237
- # Delegates to the builder to store the path, uri, and
235
+ # Delegates to the builder to store the uri, and
238
236
  # parameters if the sampler is active
239
- def notice_transaction(path, uri=nil, params={})
240
- builder.set_transaction_info(path, uri, params) if enabled? && builder
237
+ def notice_transaction(uri=nil, params={})
238
+ builder.set_transaction_info(uri, params) if enabled? && builder
241
239
  end
242
240
 
243
241
  # Tells the builder to ignore a transaction, if we are currently
@@ -0,0 +1,35 @@
1
+ # -*- ruby -*-
2
+ # encoding: utf-8
3
+ # This file is distributed under New Relic's license terms.
4
+ # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
5
+
6
+ # This module includes utilities for manipulating URIs, particularly from the
7
+ # context of Net::HTTP requests. We don't always have direct access to the full
8
+ # URI from our instrumentation points in Net::HTTP, and we want to filter out
9
+ # some URI parts before saving URIs from instrumented calls - logic for that
10
+ # lives here.
11
+
12
+ module NewRelic
13
+ module Agent
14
+ module URIUtil
15
+ def self.uri_from_connection_and_request(http, request)
16
+ parsed = case request.path
17
+ when /^https?:\/\//
18
+ URI(request.path)
19
+ else
20
+ scheme = http.use_ssl? ? 'https' : 'http'
21
+ URI("#{scheme}://#{http.address}:#{http.port}#{request.path}")
22
+ end
23
+ end
24
+
25
+ def self.filtered_uri_for(http, request)
26
+ parsed = uri_from_connection_and_request(http, request)
27
+ parsed.user = nil
28
+ parsed.password = nil
29
+ parsed.query = nil
30
+ parsed.fragment = nil
31
+ parsed.to_s
32
+ end
33
+ end
34
+ end
35
+ end
@@ -64,7 +64,7 @@ module NewRelic
64
64
  module Agent
65
65
  extend self
66
66
  extend Forwardable
67
-
67
+
68
68
  require 'new_relic/version'
69
69
  require 'new_relic/local_environment'
70
70
  require 'new_relic/metrics'
@@ -98,6 +98,8 @@ module NewRelic
98
98
  require 'new_relic/agent/transaction_info'
99
99
  require 'new_relic/agent/configuration'
100
100
  require 'new_relic/agent/rules_engine'
101
+ require 'new_relic/agent/uri_util'
102
+ require 'new_relic/agent/system_info'
101
103
 
102
104
  require 'new_relic/agent/instrumentation/controller_instrumentation'
103
105
 
@@ -341,7 +343,7 @@ module NewRelic
341
343
  # any. Only affects the transaction started on this thread once
342
344
  # it has started and before it has completed.
343
345
  def abort_transaction!
344
- NewRelic::Agent::Instrumentation::MetricFrame.abort_transaction!
346
+ Transaction.abort_transaction!
345
347
  end
346
348
 
347
349
  # Yield to the block without collecting any metrics or traces in
@@ -361,13 +363,13 @@ module NewRelic
361
363
  untraced = Thread.current[:newrelic_untraced]
362
364
  untraced.nil? || untraced.last != false
363
365
  end
364
-
366
+
365
367
  # helper method to check the thread local to determine whether the
366
368
  # transaction in progress is traced or not
367
369
  def is_transaction_traced?
368
370
  Thread::current[:record_tt] != false
369
371
  end
370
-
372
+
371
373
  # helper method to check the thread local to determine whether sql
372
374
  # is being recorded or not
373
375
  def is_sql_recorded?
@@ -402,16 +404,16 @@ module NewRelic
402
404
  # Anything left over is treated as custom params.
403
405
  #
404
406
  def notice_error(exception, options={})
405
- NewRelic::Agent::Instrumentation::MetricFrame.notice_error(exception, options)
407
+ Transaction.notice_error(exception, options)
406
408
  end
407
409
 
408
410
  # Add parameters to the current transaction trace (and traced error if any)
409
411
  # on the call stack.
410
412
  #
411
413
  def add_custom_parameters(params)
412
- NewRelic::Agent::Instrumentation::MetricFrame.add_custom_parameters(params)
414
+ Transaction.add_custom_parameters(params)
413
415
  end
414
-
416
+
415
417
  # Set attributes about the user making this request. These attributes will be automatically
416
418
  # appended to any Transaction Trace or Error that is collected. These attributes
417
419
  # will also be collected for RUM requests.
@@ -422,7 +424,48 @@ module NewRelic
422
424
  # * <tt>:product</tt> => product name or level
423
425
  #
424
426
  def set_user_attributes(attributes)
425
- NewRelic::Agent::Instrumentation::MetricFrame.set_user_attributes(attributes)
427
+ Transaction.set_user_attributes(attributes)
428
+ end
429
+
430
+ # Set the name of the current running transaction. The agent will
431
+ # apply a reasonable default based on framework routing, but in
432
+ # cases where this is insufficient, this can be used to manually
433
+ # control the name of the transaction.
434
+ # The category of transaction can be specified via the +:category+ option:
435
+ #
436
+ # * <tt>:category => :controller</tt> indicates that this is a
437
+ # controller action and will appear with all the other actions.
438
+ # * <tt>:category => :task</tt> indicates that this is a
439
+ # background task and will show up in New Relic with other background
440
+ # tasks instead of in the controllers list
441
+ # * <tt>:category => :rack</tt> if you are instrumenting a rack
442
+ # middleware call. The <tt>:name</tt> is optional, useful if you
443
+ # have more than one potential transaction in the #call.
444
+ # * <tt>:category => :uri</tt> indicates that this is a
445
+ # web transaction whose name is a normalized URI, where 'normalized'
446
+ # means the URI does not have any elements with data in them such
447
+ # as in many REST URIs.
448
+ #
449
+ # The default category is the same as the running transaction.
450
+ #
451
+ # @api public
452
+ def set_transaction_name(name, options={})
453
+ if Transaction.current
454
+ namer = Instrumentation::ControllerInstrumentation::TransactionNamer.new(self)
455
+ Transaction.current.type = options[:category] if options[:category]
456
+ Transaction.current.name = "#{namer.category_name(options[:category])}/#{name}"
457
+ end
458
+ end
459
+
460
+ # Get the name of the current running transaction. This is useful if you
461
+ # want to modify the default name.
462
+ #
463
+ # @api public
464
+ def get_transaction_name
465
+ if Transaction.current
466
+ namer = Instrumentation::ControllerInstrumentation::TransactionNamer.new(self)
467
+ Transaction.current.name.sub(Regexp.new("\\A#{Regexp.escape(namer.category_name)}/"), '')
468
+ end
426
469
  end
427
470
 
428
471
  # The #add_request_parameters method is aliased to #add_custom_parameters
@@ -438,8 +481,8 @@ module NewRelic
438
481
  # * <tt>method</tt> is the name of the finder method or other
439
482
  # method to identify the operation with.
440
483
  def with_database_metric_name(model, method, &block)
441
- if frame = NewRelic::Agent::Instrumentation::MetricFrame.current
442
- frame.with_database_metric_name(model, method, &block)
484
+ if txn = Transaction.current
485
+ txn.with_database_metric_name(model, method, &block)
443
486
  else
444
487
  yield
445
488
  end
@@ -486,7 +529,7 @@ module NewRelic
486
529
  def browser_timing_footer
487
530
  agent.browser_timing_footer
488
531
  end
489
-
532
+
490
533
  def_delegator :'NewRelic::Agent::PipeChannelManager', :register_report_channel
491
534
  end
492
535
  end
@@ -1,2 +1,2 @@
1
- # GITSHA: 9e91cdd0ed32baa14e6ea1b82f80ce89bf1991b3
2
- module NewRelic; module VERSION; BUILD='83'; end; end
1
+ # GITSHA: bbab5a90983473b31328da7b2339ea57a0a548f6
2
+ module NewRelic; module VERSION; BUILD='85.beta'; end; end
@@ -59,7 +59,6 @@ module NewRelic
59
59
  # is running, if it thinks it's a rake task, or if the agent_enabled is false.
60
60
  ::NewRelic::Agent.logger.info("New Relic Agent not running.")
61
61
  else
62
- ::NewRelic::Agent.logger.info("Starting the New Relic Agent.")
63
62
  install_developer_mode(rails_config) if Agent.config[:developer_mode]
64
63
  install_browser_monitoring(rails_config)
65
64
  install_agent_hooks(rails_config)
@@ -34,6 +34,8 @@ module NewRelic
34
34
 
35
35
  def add_error_collector_middleware
36
36
  rails_config.middleware.use NewRelic::Rack::ErrorCollector
37
+ rescue => e
38
+ NewRelic::Agent.logger.debug("Error encountered installing ErrorCollector: #{e}")
37
39
  end
38
40
 
39
41
  def vendor_root
@@ -14,10 +14,6 @@ module NewRelic
14
14
  end
15
15
  end
16
16
 
17
- def add_error_collector_middleware
18
- # rails_config.middleware.use NewRelic::Rack::ErrorCollector
19
- end
20
-
21
17
  def append_plugin_list
22
18
  # Rails 4 does not allow plugins
23
19
  end
@@ -49,7 +49,11 @@ module NewRelic
49
49
  # init_config({}) which is called one or more times.
50
50
  #
51
51
  def init_plugin(options={})
52
- yaml = Agent::Configuration::YamlSource.new(@config_file_path, options[:env] || env)
52
+ env = options[:env] || self.env
53
+ Agent.logger.info("Starting the New Relic agent in #{env.inspect} environment.")
54
+ Agent.logger.info("To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the #{env.inspect} section of your newrelic.yml.")
55
+
56
+ yaml = Agent::Configuration::YamlSource.new(@config_file_path, env)
53
57
  Agent.config.replace_or_add_config(yaml, 1)
54
58
 
55
59
  Agent.config.replace_or_add_config(Agent::Configuration::ManualSource.new(options), 1)
@@ -114,24 +118,6 @@ module NewRelic
114
118
 
115
119
  protected
116
120
 
117
- # Append framework specific environment information for uploading to
118
- # the server for change detection. Override in subclasses
119
- def append_environment_info; end
120
-
121
- # Asks bundler to tell us which gemspecs are loaded in the
122
- # current process
123
- def bundler_gem_list
124
- if defined?(Bundler) && Bundler.instance_eval do @load end
125
- Bundler.load.specs.map do |spec|
126
- version = (spec.respond_to?(:version) && spec.version)
127
- spec.name + (version ? "(#{version})" : "")
128
- end
129
- else
130
- []
131
- end
132
- end
133
-
134
-
135
121
  def initialize(local_env, config_file_override=nil)
136
122
  @local_env = local_env
137
123
  @instrumentation_files = []
@@ -53,6 +53,8 @@ module NewRelic
53
53
  # here we leave it as a host name since the cert verification
54
54
  # needs it in host form
55
55
  return host if Agent.config[:ssl] && Agent.config[:verify_certificate]
56
+ # We won't talk directly to the host, so no need to resolve if proxy configured
57
+ return host if Agent.config[:proxy_host]
56
58
  return nil if host.nil? || host.downcase == "localhost"
57
59
  ip = resolve_ip_address(host)
58
60
 
@@ -64,40 +64,10 @@ module NewRelic
64
64
  report_on('Ruby patchlevel'){ RUBY_PATCHLEVEL.to_s }
65
65
  report_on('JRuby version') { JRUBY_VERSION }
66
66
  report_on('Java VM version') { ENV_JAVA['java.vm.version']}
67
- report_on 'Processors' do
68
- cpuinfo = ''
69
- proc_file = '/proc/cpuinfo'
70
- File.open(proc_file) do |f|
71
- loop do
72
- begin
73
- cpuinfo << f.read_nonblock(4096).strip
74
- rescue EOFError
75
- break
76
- rescue Errno::EWOULDBLOCK, Errno::EAGAIN
77
- cpuinfo = ''
78
- break # don't select file handle, just give up
79
- end
80
- end
81
- end
82
- processors = cpuinfo.split("\n").select {|line| line =~ /^processor\s*:/ }.size
83
-
84
- if processors == 0
85
- processors = nil # assume there is at least one processor
86
- ::NewRelic::Agent.logger.warn("Cannot determine the number of processors in #{proc_file}")
87
- end
88
- processors
89
- end
90
- report_on 'Arch' do
91
- arch = `uname -p`
92
- arch = ENV['PROCESSOR_ARCHITECTURE'] if arch == ''
93
- arch
94
- end
95
- report_on('OS version'){ `uname -v` }
96
- report_on('OS') do
97
- os = `uname -s`
98
- os = ENV['OS'] if os == ''
99
- os
100
- end
67
+ report_on('Processors') { SystemInfo.processor_count }
68
+ report_on('Arch') { SystemInfo.processor_arch }
69
+ report_on('OS version') { SystemInfo.os_version }
70
+ report_on('OS') { SystemInfo.ruby_os_identifier }
101
71
  report_on 'Database adapter' do
102
72
  ActiveRecord::Base.configurations[NewRelic::Control.instance.env]['adapter']
103
73
  end
@@ -25,7 +25,7 @@ EOS
25
25
  version_count += 1
26
26
  end
27
27
  break if version_count >= 2
28
- changes << line.sub(/^ /, "").chomp
28
+ changes << line.sub(/^ \* /, "* ").chomp
29
29
  end
30
30
 
31
31
  changes << footer
@@ -25,9 +25,6 @@ module NewRelic
25
25
 
26
26
  # used to distinguish instances of a dispatcher from each other, may be nil
27
27
  attr_writer :dispatcher_instance_id
28
- # The number of cpus, if detected, or nil - many platforms do not
29
- # support this :(
30
- attr_reader :processors
31
28
 
32
29
  def initialize
33
30
  # Extend self with any any submodules of LocalEnvironment. These can override
@@ -38,9 +35,6 @@ module NewRelic
38
35
  end
39
36
 
40
37
  discover_dispatcher
41
- @gems = Set.new
42
- @plugins = Set.new
43
- @config = Hash.new
44
38
  end
45
39
 
46
40
 
@@ -15,9 +15,9 @@ class NewRelic::MetricSpec
15
15
  # jruby) for sending responses to ruby agents from the java collector.
16
16
  #
17
17
  def initialize(metric_name = '', metric_scope = nil)
18
- self.name = (metric_name || '') && metric_name[LENGTH_RANGE]
18
+ self.name = (metric_name || '') && metric_name.to_s[LENGTH_RANGE]
19
19
  if metric_scope
20
- self.scope = metric_scope && metric_scope[LENGTH_RANGE]
20
+ self.scope = metric_scope && metric_scope.to_s[LENGTH_RANGE]
21
21
  else
22
22
  self.scope = ''
23
23
  end
@@ -23,10 +23,12 @@ module NewRelic::Rack
23
23
  {'error' => warning}
24
24
  end
25
25
 
26
- NewRelic::Agent.instance.error_collector.notice_error(exception,
27
- :uri => request.path,
28
- :referer => request.referer,
29
- :request_params => params)
26
+ transaction_name = NewRelic::Agent::TransactionInfo.get.transaction.name
27
+ NewRelic::Agent::Transaction.notice_error(exception,
28
+ :uri => request.path,
29
+ :referer => request.referer,
30
+ :metric => transaction_name,
31
+ :request_params => params)
30
32
  end
31
33
  raise exception
32
34
  end
@@ -62,6 +62,11 @@ module NewRelic
62
62
  JSON.dump(self.to_array)
63
63
  end
64
64
 
65
+ def set_custom_param(name, value)
66
+ @params[:custom_params] ||= {}
67
+ @params[:custom_params][name] = value
68
+ end
69
+
65
70
  include NewRelic::Coerce
66
71
 
67
72
  def to_array
@@ -91,7 +96,8 @@ module NewRelic
91
96
  @root_segment.path_string
92
97
  end
93
98
 
94
- def create_segment(relative_timestamp, metric_name, segment_id = nil)
99
+ # relative_timestamp is seconds since the start of the transaction
100
+ def create_segment(relative_timestamp, metric_name=nil, segment_id = nil)
95
101
  raise TypeError.new("Frozen Transaction Sample") if frozen?
96
102
  @params[:segment_count] += 1
97
103
  @segment_count += 1
@@ -12,7 +12,7 @@ module NewRelic
12
12
 
13
13
  MAJOR = 3
14
14
  MINOR = 6
15
- TINY = 0
15
+ TINY = 1
16
16
 
17
17
  begin
18
18
  require File.join(File.dirname(__FILE__), 'build')
data/lib/newrelic_rpm.rb CHANGED
@@ -32,7 +32,7 @@ if defined?(Merb) && defined?(Merb::BootLoader)
32
32
  end
33
33
  end
34
34
  elsif defined? Rails
35
- if Rails.respond_to?(:version) && Rails.version > '3'
35
+ if Rails::VERSION::MAJOR.to_i >= 3
36
36
  module NewRelic
37
37
  class Railtie < Rails::Railtie
38
38
 
@@ -42,7 +42,7 @@ elsif defined? Rails
42
42
  end
43
43
  end
44
44
  else
45
- # After verison 2.0 of Rails we can access the configuration directly.
45
+ # After version 2.0 of Rails we can access the configuration directly.
46
46
  # We need it to add dev mode routes after initialization finished.
47
47
  config = nil
48
48
  config = Rails.configuration if Rails.respond_to?(:configuration)
data/newrelic.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
- # This file configures the New Relic Ruby Agent, New Relic monitors
3
- # Rails applications with deep visibility and low overhead. For more
4
- # information, visit www.newrelic.com.
2
+ # This file configures the New Relic Agent. New Relic monitors
3
+ # Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
4
+ # For more information, visit www.newrelic.com.
5
5
  #
6
6
  # Generated <%= Time.now.strftime('%B %d, %Y') %>, for version <%= NewRelic::VERSION::STRING %>
7
7
  #
@@ -17,11 +17,11 @@ common: &default_settings
17
17
  # New Relic service.
18
18
  license_key: '<%= license_key %>'
19
19
 
20
- # Agent Enabled (Rails Only)
20
+ # Agent Enabled (Ruby/Rails Only)
21
21
  # Use this setting to force the agent to run or not run.
22
22
  # Default is 'auto' which means the agent will install and run only
23
23
  # if a valid dispatcher such as Mongrel is running. This prevents
24
- # it from running with Rake or the console. Set to false to
24
+ # it from running with Rake or the console. Set to false to
25
25
  # completely turn the agent off regardless of the other settings.
26
26
  # Valid values are true, false and auto.
27
27
  #
@@ -47,7 +47,7 @@ common: &default_settings
47
47
  # When "true", the agent collects performance data about your
48
48
  # application and reports this data to the New Relic service at
49
49
  # newrelic.com. This global switch is normally overridden for each
50
- # environment below (formerly called 'enabled').
50
+ # environment below. (formerly called 'enabled')
51
51
  monitor_mode: true
52
52
 
53
53
  # Developer mode should be off in every environment but
@@ -85,7 +85,7 @@ common: &default_settings
85
85
  # into web pages. Set this attribute to false to turn off this behavior.
86
86
  auto_instrument: true
87
87
 
88
- # Proxy settings for connecting to the service.
88
+ # Proxy settings for connecting to the New Relic server.
89
89
  #
90
90
  # If a proxy is used, the host setting is required. Other settings
91
91
  # are optional. Default port is 8080.
@@ -108,11 +108,11 @@ common: &default_settings
108
108
  # Rails: the RoR filter_parameter_logging excludes parameters
109
109
  # Java: create a config setting called "ignored_params" and set it to
110
110
  # a comma separated list of HTTP parameter names.
111
- # ex: ignored_params: credit_card, ssn, password
111
+ # ex: ignored_params: credit_card, ssn, password
112
112
  capture_params: false
113
113
 
114
114
  # Transaction tracer captures deep information about slow
115
- # transactions and sends this to the service once a
115
+ # transactions and sends this to the New Relic service once a
116
116
  # minute. Included in the transaction is the exact call sequence of
117
117
  # the transactions including any SQL statements issued.
118
118
  transaction_tracer:
@@ -125,9 +125,9 @@ common: &default_settings
125
125
  # Threshold in seconds for when to collect a transaction
126
126
  # trace. When the response time of a controller action exceeds
127
127
  # this threshold, a transaction trace will be recorded and sent to
128
- # the service. Valid values are any float value, or (default)
129
- # "apdex_f", which will use the threshold for an dissatisfying
130
- # Apdex controller action - four times the Apdex T value.
128
+ # New Relic. Valid values are any float value, or (default) "apdex_f",
129
+ # which will use the threshold for an dissatisfying Apdex
130
+ # controller action - four times the Apdex T value.
131
131
  transaction_threshold: apdex_f
132
132
 
133
133
  # When transaction tracer is on, SQL statements can optionally be
@@ -138,7 +138,7 @@ common: &default_settings
138
138
 
139
139
  # Threshold in seconds for when to collect stack trace for a SQL
140
140
  # call. In other words, when SQL statements exceed this threshold,
141
- # then capture and send the current stack trace. This is
141
+ # then capture and send to New Relic the current stack trace. This is
142
142
  # helpful for pinpointing where long SQL calls originate from.
143
143
  stack_trace_threshold: 0.500
144
144
 
@@ -147,12 +147,12 @@ common: &default_settings
147
147
  # set to false when using other adapters.
148
148
  # explain_enabled: true
149
149
 
150
- # Threshold for query execution time below which query plans will not
150
+ # Threshold for query execution time below which query plans will
151
151
  # not be captured. Relevant only when `explain_enabled` is true.
152
152
  # explain_threshold: 0.5
153
153
 
154
154
  # Error collector captures information about uncaught exceptions and
155
- # sends them to the service for viewing.
155
+ # sends them to New Relic for viewing
156
156
  error_collector:
157
157
 
158
158
  # Error collector is enabled by default. Set this to false to turn
@@ -166,9 +166,9 @@ common: &default_settings
166
166
  capture_source: true
167
167
 
168
168
  # To stop specific errors from reporting to New Relic, set this property
169
- # to comma separated values. Default is to ignore routing errors
169
+ # to comma-separated values. Default is to ignore routing errors,
170
170
  # which are how 404's get triggered.
171
- ignore_errors: ActionController::RoutingError
171
+ ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"
172
172
 
173
173
  # If you're interested in capturing memcache keys as though they
174
174
  # were SQL uncomment this flag. Note that this does increase
@@ -178,10 +178,10 @@ common: &default_settings
178
178
 
179
179
  # Application Environments
180
180
  # ------------------------------------------
181
- # Environment specific settings are in this section.
182
- # For Rails applications, RAILS_ENV is used to determine the environment
181
+ # Environment-specific settings are in this section.
182
+ # For Rails applications, RAILS_ENV is used to determine the environment.
183
183
  # For Java applications, pass -Dnewrelic.environment <environment> to set
184
- # the environment
184
+ # the environment.
185
185
 
186
186
  # NOTE if your application has other named environments, you should
187
187
  # provide newrelic configuration settings for these environments here.
@@ -6,8 +6,8 @@ require 'new_relic/control/frameworks/rails'
6
6
  require 'new_relic/control/frameworks/rails3'
7
7
  require 'new_relic/control/frameworks/rails4'
8
8
 
9
- if defined?(::Rails) && ::Rails.respond_to?(:version)
10
- parent_class = case ::Rails.version.to_i
9
+ if defined?(::Rails)
10
+ parent_class = case ::Rails::VERSION::MAJOR.to_i
11
11
  when 4
12
12
  NewRelic::Control::Frameworks::Rails4
13
13
  when 3
@@ -91,7 +91,7 @@ class AuditLogTest < Test::Unit::TestCase
91
91
  agent.sql_sampler.notice_sql("select * from test",
92
92
  "Database/test/select",
93
93
  nil, 1.5)
94
- agent.sql_sampler.notice_scope_empty
94
+ agent.sql_sampler.notice_scope_empty('txn')
95
95
  agent.send(:harvest_and_send_slowest_sql)
96
96
  end
97
97
  $collector.agent_data.each do |req|
@@ -52,9 +52,7 @@ class CrossProcessTest < Test::Unit::TestCase
52
52
  def test_cross_app_writes_out_information
53
53
  get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
54
54
  assert_not_nil last_response.headers["X-NewRelic-App-Data"]
55
-
56
55
  metric = NewRelic::Agent.instance.stats_engine.lookup_stats('ClientApplication/1#234/all')
57
56
  assert_equal 1, metric.call_count
58
57
  end
59
58
  end
60
-
@@ -36,7 +36,7 @@ class LoggingTest < Test::Unit::TestCase
36
36
  def test_logs_missing_dispatcher
37
37
  running_agent_writes_to_log(
38
38
  {:dispatcher => ''},
39
- "No dispatcher detected")
39
+ "No known dispatcher detected")
40
40
  end
41
41
 
42
42
  def test_logs_raw_sql_warning