newrelic_rpm 2.13.4.rum6 → 2.13.4

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,7 +1,3 @@
1
- v2.13.4.eum1
2
- * Add preliminary work on end user monitoring
3
- * Moved the API helper to the gihtub newrelic_api gem.
4
-
5
1
  v2.13.4
6
2
  * Update DNS lookup code to remove hardcoded IP addresses
7
3
 
@@ -1,7 +1,5 @@
1
1
  = New Relic RPM
2
2
 
3
-
4
-
5
3
  New Relic RPM is a Ruby performance management system, developed by
6
4
  New Relic, Inc (http://www.newrelic.com). RPM provides you with deep
7
5
  information about the performance of your Ruby on Rails or Merb
@@ -72,7 +72,6 @@ module NewRelic
72
72
  require 'new_relic/timer_lib'
73
73
 
74
74
  require 'new_relic/agent/chained_call'
75
- require 'new_relic/agent/browser_monitoring'
76
75
  require 'new_relic/agent/agent'
77
76
  require 'new_relic/agent/shim_agent'
78
77
  require 'new_relic/agent/method_tracer'
@@ -378,30 +377,5 @@ module NewRelic
378
377
  def record_transaction(response_sec, options = {})
379
378
  agent.record_transaction(response_sec, options)
380
379
  end
381
-
382
- # PRE-RELEASE
383
- # Returns a Javascript string which should be injected into the very top of the response body
384
- #
385
- def browser_timing_header
386
- agent.browser_timing_header
387
- end
388
-
389
- # PRE-RELEASE
390
- # Returns a Javascript string which should be injected into the very bottom of the response body
391
- #
392
- def browser_timing_footer
393
- agent.browser_timing_footer
394
- end
395
-
396
- # FOR BACKWARD COMPATIBILITY (REMOVE BEFORE GA)
397
- def browser_instrumentation_header(options={})
398
- agent.browser_timing_header
399
- end
400
-
401
- # FOR BACKWARD COMPATIBILITY (REMOVE BEFORE GA)
402
- def browser_instrumentation_footer(options={})
403
- agent.browser_timing_footer
404
- end
405
-
406
380
  end
407
381
  end
@@ -61,7 +61,6 @@ module NewRelic
61
61
  attr_reader :histogram
62
62
  attr_reader :metric_ids
63
63
  attr_reader :url_rules
64
- attr_reader :beacon_configuration
65
64
 
66
65
  def record_transaction(duration_seconds, options={})
67
66
  is_error = options['is_error'] || options['error_message'] || options['exception']
@@ -434,7 +433,6 @@ module NewRelic
434
433
  @agent_id = connect_data['agent_run_id']
435
434
  @report_period = connect_data['data_report_period']
436
435
  @url_rules = connect_data['url_rules']
437
- @beacon_configuration = BeaconConfiguration.new(connect_data)
438
436
 
439
437
  control.log! "Connected to NewRelic Service at #{@collector}"
440
438
  log.debug "Agent Run = #{@agent_id}."
@@ -738,7 +736,6 @@ module NewRelic
738
736
 
739
737
  extend ClassMethods
740
738
  include InstanceMethods
741
- include BrowserMonitoring
742
739
  end
743
740
  end
744
741
  end
@@ -394,7 +394,6 @@ module NewRelic
394
394
  if http_entry_time
395
395
  queue_stat = NewRelic::Agent.agent.stats_engine.get_stats_no_scope 'WebFrontend/Mongrel/Average Queue Time'
396
396
  total_time = (now - http_entry_time)
397
- Thread.current[:queue_time] = total_time # HACK ALERT - this is used to communicate with the browser monitoring code
398
397
  queue_stat.trace_call(total_time.to_f) unless total_time.to_f <= 0.0 # using remote timestamps could lead to negative queue time
399
398
  end
400
399
  return http_entry_time ? Time.at(http_entry_time) : now
@@ -138,7 +138,7 @@ module NewRelic
138
138
  NewRelic::Agent.instance.transaction_sampler.notice_scope_empty
139
139
  end
140
140
  NewRelic::Agent.instance.stats_engine.end_transaction
141
- # Thread.current[:newrelic_metric_frame] = nil
141
+ Thread.current[:newrelic_metric_frame] = nil
142
142
  else # path stack not empty
143
143
  # change the transaction name back to whatever was on the stack.
144
144
  NewRelic::Agent.instance.stats_engine.scope_name = metric_name
@@ -16,13 +16,6 @@ if defined? ActionController
16
16
  ActionView::Template.class_eval do
17
17
  add_method_tracer :render, 'View/#{(path_without_extension || @view.controller.newrelic_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering'
18
18
  end
19
- # ActionView::Template.class_eval do
20
- # alias_method :source_without_newrelic, :source
21
- #
22
- # def source
23
- # "text/html" == mime_type ? NewRelic::Agent.autoinstrument_source(source_without_newrelic) : source_without_newrelic
24
- # end
25
- # end if NewRelic::Control.instance['auto_enable_real_user_monitoring']
26
19
 
27
20
  when /^2\./ # Rails 2.2-2.*
28
21
  ActionView::RenderablePartial.module_eval do
@@ -31,14 +24,6 @@ if defined? ActionController
31
24
  ActionView::Template.class_eval do
32
25
  add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
33
26
  end
34
- # ActionView::Template.class_eval do
35
- # alias_method :source_without_newrelic, :source
36
- #
37
- # def source
38
- # "text/html" == mime_type ? NewRelic::Agent.autoinstrument_source(source_without_newrelic) : source_without_newrelic
39
- # end
40
- # end if NewRelic::Control.instance['auto_enable_real_user_monitoring']
41
-
42
27
  end unless NewRelic::Control.instance['disable_view_instrumentation']
43
28
 
44
29
  ActionController::Base.class_eval do
@@ -20,8 +20,6 @@ module NewRelic
20
20
  def shutdown; end
21
21
  def push_trace_execution_flag(*args); end
22
22
  def pop_trace_execution_flag(*args); end
23
- def browser_timing_header; "" end
24
- def browser_timing_footer; "" end
25
23
  end
26
24
  end
27
25
  end
@@ -105,6 +105,7 @@ module Agent
105
105
 
106
106
  if stack && stack.empty?
107
107
  Thread::current[:newrelic_scope_stack] = nil
108
+ Thread::current[:newrelic_scope_name] = nil
108
109
  end
109
110
  end
110
111
 
@@ -42,7 +42,7 @@ module NewRelic
42
42
  def instance
43
43
  @instance ||= new_instance
44
44
  end
45
-
45
+
46
46
  # Create the concrete class for environment specific behavior:
47
47
  def new_instance
48
48
  @local_env = NewRelic::LocalEnvironment.new
@@ -79,16 +79,9 @@ module NewRelic
79
79
  fetch('developer_mode', fetch('developer'))
80
80
  end
81
81
 
82
- def browser_monitoring_auto_instrument?
83
- bm = fetch('browser_monitoring')
84
-
85
- if bm.nil?
86
- false
87
- else
88
- bm.fetch('auto_instrument', false)
89
- end
82
+ def episodes_enabled?
83
+ fetch('episodes_enabled', true)
90
84
  end
91
-
92
85
  # True if the app runs in multi-threaded mode
93
86
  def multi_threaded?
94
87
  fetch('multi_threaded')
@@ -21,16 +21,19 @@ class NewRelic::Control::Frameworks::Rails < NewRelic::Control
21
21
  else
22
22
  log! "Starting the New Relic Agent."
23
23
  install_developer_mode rails_config if developer_mode?
24
- install_browser_monitoring rails_config
24
+ install_episodes rails_config
25
25
  end
26
26
  end
27
27
 
28
- def install_browser_monitoring(config)
29
- return if config.nil? || !config.respond_to?(:middleware) || !browser_monitoring_auto_instrument?
30
-
31
- require 'new_relic/rack/browser_monitoring'
32
- config.middleware.use NewRelic::Rack::BrowserMonitoring
33
- ::RAILS_DEFAULT_LOGGER.info "Installed browser monitoring middleware"
28
+ def install_episodes(config)
29
+ return if config.nil? || !config.respond_to?(:middleware) || !episodes_enabled?
30
+ config.after_initialize do
31
+ if defined?(NewRelic::Rack::Episodes)
32
+ config.middleware.use NewRelic::Rack::Episodes
33
+ log! "Installed episodes middleware"
34
+ ::RAILS_DEFAULT_LOGGER.info "Installed episodes middleware"
35
+ end
36
+ end
34
37
  end
35
38
 
36
39
  def install_developer_mode(rails_config)
@@ -135,9 +135,6 @@ module NewRelic
135
135
  end_time - begin_time
136
136
  end
137
137
 
138
- def midpoint
139
- begin_time + (duration/2)
140
- end
141
138
  def calls_per_minute
142
139
  if duration.zero?
143
140
  0
@@ -47,7 +47,7 @@ module TransactionAnalysis
47
47
  @total_time / @sample.duration
48
48
  end
49
49
 
50
- def ui_name
50
+ def developer_name
51
51
  return @metric_name if @metric_name == 'Remainder'
52
52
  NewRelic::MetricParser::MetricParser.parse(@metric_name).developer_name
53
53
  end
@@ -4,7 +4,7 @@ module NewRelic
4
4
  MAJOR = 2
5
5
  MINOR = 13
6
6
  TINY = 4
7
- BUILD = 'rum6' #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
7
+ BUILD = nil #'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
 
@@ -0,0 +1,276 @@
1
+ # == REST API Helpers
2
+ #
3
+ # Ruby lib for working with the New Relic API's XML interface. Requires Rails 2.0 or later to be loaded.
4
+ #
5
+ # Can also be used as a script using script/runner
6
+ #
7
+ # Authentication is handled using your agent license key or HTTP Basic Authentication. To authenticate
8
+ # using your license key your newrelic.yml configuration file must be in your application config directory
9
+ # and contain your license key. The New Relic account associated with the license key must allow api access.
10
+ # Log into RPM, click Account at the top of the page and check the "Make my account data accessible" checkbox.
11
+ #
12
+ # Basic authentication uses your site credentials to authenticate.
13
+ #
14
+ # # To authenticate using basic authentication, make this call with your username and password:
15
+ # NewRelicApi.authenticate('user@example.com', 'test')
16
+ #
17
+ # This API does not have any agent dependencies. It can be used independent of the agent by copying it into your application.
18
+ #
19
+ # == Examples
20
+ #
21
+ # # Fetching the list of applications for an account
22
+ # NewRelicApi::Account.find(:first).applications
23
+ #
24
+ # # Fetching the health values for all account applications
25
+ # NewRelicApi::Account.application_health
26
+ #
27
+ # # Fetching the health values for an application
28
+ # NewRelicApi::Account.find(:first).applications.first.threshold_values
29
+ #
30
+ # # Finding an application by name
31
+ # NewRelicApi::Account.find(:first).applications(:params => {:conditions => {:name => 'My App'}})
32
+ #
33
+
34
+ module NewRelicApi
35
+
36
+ # This mixin defines ActiveRecord style associations (like has_many) for ActiveResource objects.
37
+ # ActiveResource objects using this mixin must define the method 'query_params'.
38
+ module ActiveResourceAssociations #:nodoc:
39
+ class << self
40
+ protected
41
+ def included(base)
42
+ class << base
43
+ # a special activeresource implementation of has_many
44
+ def has_many(*associations)
45
+ associations.to_a.each do |association|
46
+ define_method association do |*args|
47
+ val = attributes[association.to_s] # if we've already fetched the relationship in the initial fetch, return it
48
+ return val if val
49
+
50
+ options = args.extract_options!
51
+ type = args.first || :all
52
+
53
+ begin
54
+ # look for the class definition within the current class
55
+ clazz = ( self.class.name + '::' + association.to_s.camelize.singularize).constantize
56
+ rescue
57
+ # look for the class definition in the NRAPI module
58
+ clazz = ( 'NewRelicApi::' + association.to_s.camelize.singularize).constantize
59
+ end
60
+ params = (options[:params] || {}).update(self.query_params)
61
+ options[:params] = params
62
+ clazz.find(type, options)
63
+
64
+ #clazz.find(type, :params => options.update(self.query_params))
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ class << self
74
+ attr_accessor :email, :password, :license_key, :ssl, :host, :port
75
+
76
+ # Sets up basic authentication credentials for all the resources. This is not necessary if you are
77
+ # using agent license key authentication.
78
+ def authenticate(email, password)
79
+ @password = password
80
+ @email = email
81
+ end
82
+
83
+ # Resets the base path of all resources. This should be called when overridding the newrelic.yml settings
84
+ # using the ssl, host or port accessors.
85
+ def reset!
86
+ @classes.each {|klass| klass.reset!} if @classes
87
+ NewRelicApi::Account.site_url
88
+ end
89
+
90
+
91
+ def track_resource(klass) #:nodoc:
92
+ (@classes ||= []) << klass
93
+ end
94
+ end
95
+
96
+ class BaseResource < ActiveResource::Base #:nodoc:
97
+ include ActiveResourceAssociations
98
+
99
+ class << self
100
+ def inherited(klass) #:nodoc:
101
+ NewRelicApi.track_resource(klass)
102
+ end
103
+
104
+ def headers
105
+ h = {'x-license-key' => NewRelicApi.license_key || NewRelic::Control.instance['license_key']}
106
+ h['Authorization'] = 'Basic ' + ["#{NewRelicApi.email}:#{NewRelicApi.password}"].pack('m').delete("\r\n") if NewRelicApi.email
107
+ h
108
+ end
109
+
110
+ def site_url
111
+ host = NewRelicApi.host || NewRelic::Control.instance.api_server.name
112
+ port = NewRelicApi.port || NewRelic::Control.instance.api_server.port
113
+ "#{port == 443 ? 'https' : 'http'}://#{host}:#{port}"
114
+ end
115
+
116
+ def reset!
117
+ self.site = self.site_url
118
+ end
119
+
120
+ protected
121
+
122
+ def fix_fields(*fields)
123
+ fields.to_a.each do |field|
124
+ define_method field do
125
+ yield super
126
+ end
127
+ end
128
+ end
129
+
130
+ def fix_integer_fields(*fields)
131
+ fix_fields(*fields) { |sup| sup.to_i }
132
+ end
133
+
134
+ def fix_float_fields(*fields)
135
+ fix_fields(*fields) { |sup| sup.to_f }
136
+ end
137
+
138
+ end
139
+ self.site = self.site_url
140
+ end
141
+ ACCOUNT_RESOURCE_PATH = '/accounts/:account_id/' #:nodoc:
142
+ ACCOUNT_AGENT_RESOURCE_PATH = ACCOUNT_RESOURCE_PATH + 'agents/:agent_id/' #:nodoc:
143
+ ACCOUNT_APPLICATION_RESOURCE_PATH = ACCOUNT_RESOURCE_PATH + 'applications/:application_id/' #:nodoc:
144
+
145
+ module AccountResource #:nodoc:
146
+ def account_id
147
+ prefix_options[:account_id]
148
+ end
149
+ def account_query_params(extra_params = {})
150
+ {:account_id => account_id}.merge(extra_params)
151
+ end
152
+
153
+ def query_params#:nodoc:
154
+ account_query_params
155
+ end
156
+ end
157
+
158
+ module AgentResource #:nodoc:
159
+ include ActiveResourceAssociations
160
+ end
161
+
162
+ # An application has many:
163
+ # +agents+:: the agent instances associated with this app
164
+ # +threshold_values+:: the health indicators for this application.
165
+ class Application < BaseResource
166
+ include AccountResource
167
+ include AgentResource
168
+
169
+ has_many :agents, :threshold_values
170
+
171
+ self.prefix = ACCOUNT_RESOURCE_PATH
172
+
173
+ def query_params#:nodoc:
174
+ account_query_params(:application_id => id)
175
+ end
176
+
177
+ class Agent < BaseResource
178
+ include AccountResource
179
+ include AgentResource
180
+
181
+ self.prefix = ACCOUNT_APPLICATION_RESOURCE_PATH
182
+
183
+ def query_params#:nodoc:
184
+ super.merge(:application_id => cluster_agent_id)
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+ # A threshold value represents a single health indicator for an application such as CPU, memory or response time.
191
+ #
192
+ # ==Fields
193
+ # +name+:: The name of the threshold setting associated with this threshold value.
194
+ # +threshold_value+:: A value of 0, 1, 2 or 3 representing gray (not reporting), green, yellow and red
195
+ # +metric_value+:: The metric value associated with this threshold
196
+ class ThresholdValue < BaseResource
197
+ self.prefix = ACCOUNT_APPLICATION_RESOURCE_PATH
198
+ # attr_reader :name, :begin_time, :metric_value, :threshold_value
199
+
200
+ fix_integer_fields :threshold_value
201
+ fix_float_fields :metric_value
202
+
203
+ # Returns the color value for this threshold (Gray, Green, Yellow or Red).
204
+ def color_value
205
+ case threshold_value
206
+ when 3: 'Red'
207
+ when 2: 'Yellow'
208
+ when 1: 'Green'
209
+ else 'Gray'
210
+ end
211
+ end
212
+
213
+ def to_s #:nodoc:
214
+ "#{name}: #{color_value} (#{formatted_metric_value})"
215
+ end
216
+ end
217
+
218
+ # An account contains your basic account information.
219
+ #
220
+ # Accounts have many
221
+ # +applications+:: the applications contained within the account
222
+ #
223
+ # Find Accounts
224
+ #
225
+ # NewRelicApi::Account.find(:all) # find all accounts for the current user.
226
+ # NewRelicApi::Account.find(44) # find individual account by ID
227
+ #
228
+ class Account < BaseResource
229
+ has_many :applications
230
+ has_many :account_views
231
+
232
+ def query_params #:nodoc:
233
+ {:account_id => id}
234
+ end
235
+
236
+ # Returns an account including all of its applications and the threshold values for each application.
237
+ def self.application_health(type = :first)
238
+ find(type, :params => {:include => :application_health})
239
+ end
240
+
241
+ class AccountView < BaseResource
242
+ self.prefix = ACCOUNT_RESOURCE_PATH
243
+
244
+ def query_params(extra_params = {}) #:nodoc:
245
+ {:account_id => account_id}.merge(extra_params)
246
+ end
247
+
248
+ def user
249
+ @attributes['user']
250
+ end
251
+ end
252
+
253
+ class AccountUsage < BaseResource
254
+ end
255
+ end
256
+
257
+ # This model is used to mark production deployments in RPM
258
+ # Only create is supported.
259
+ # ==Examples
260
+ # # Creating a new deployment
261
+ # NewRelicApi::Deployment.create
262
+ #
263
+ class Deployment < BaseResource
264
+ end
265
+
266
+ class Subscription < BaseResource
267
+ def query_params(extra_params = {}) #:nodoc:
268
+ {:account_id => account_id}.merge(extra_params)
269
+ end
270
+ end
271
+
272
+ class User < BaseResource
273
+ end
274
+
275
+ end
276
+