newrelic_rpm 2.13.4.rum5 → 2.13.4.rum6
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/lib/new_relic/agent.rb +2 -14
- data/lib/new_relic/agent/agent.rb +2 -8
- data/lib/new_relic/agent/browser_monitoring.rb +40 -27
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +15 -0
- data/lib/new_relic/agent/shim_agent.rb +2 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +0 -1
- data/lib/new_relic/control/configuration.rb +9 -2
- data/lib/new_relic/control/frameworks/rails.rb +7 -10
- data/lib/new_relic/rack/browser_monitoring.rb +61 -0
- data/lib/new_relic/version.rb +1 -1
- data/newrelic_rpm.gemspec +3 -2
- metadata +22 -51
data/lib/new_relic/agent.rb
CHANGED
@@ -381,23 +381,11 @@ module NewRelic
|
|
381
381
|
|
382
382
|
# PRE-RELEASE
|
383
383
|
# Returns a Javascript string which should be injected into the very top of the response body
|
384
|
-
# == options
|
385
|
-
# * <tt>:protocol => if nil then autodetect the protocol for loading the javascript file from newrelic. If set, use specified protocol.
|
386
|
-
# Legal values "http" and "https"
|
387
384
|
#
|
388
|
-
def browser_timing_header
|
389
|
-
agent.browser_timing_header
|
385
|
+
def browser_timing_header
|
386
|
+
agent.browser_timing_header
|
390
387
|
end
|
391
388
|
|
392
|
-
|
393
|
-
# PRE-RELEASE
|
394
|
-
# Returns a Javascript string which should be injected into the very top of the response body. Use this
|
395
|
-
# if you bundle our eum.js file manually
|
396
|
-
#
|
397
|
-
def browser_timing_short_header
|
398
|
-
agent.browser_timing_short_header
|
399
|
-
end
|
400
|
-
|
401
389
|
# PRE-RELEASE
|
402
390
|
# Returns a Javascript string which should be injected into the very bottom of the response body
|
403
391
|
#
|
@@ -61,10 +61,7 @@ module NewRelic
|
|
61
61
|
attr_reader :histogram
|
62
62
|
attr_reader :metric_ids
|
63
63
|
attr_reader :url_rules
|
64
|
-
attr_reader :
|
65
|
-
attr_reader :application_id
|
66
|
-
attr_reader :beacon
|
67
|
-
attr_reader :episodes_file
|
64
|
+
attr_reader :beacon_configuration
|
68
65
|
|
69
66
|
def record_transaction(duration_seconds, options={})
|
70
67
|
is_error = options['is_error'] || options['error_message'] || options['exception']
|
@@ -437,10 +434,7 @@ module NewRelic
|
|
437
434
|
@agent_id = connect_data['agent_run_id']
|
438
435
|
@report_period = connect_data['data_report_period']
|
439
436
|
@url_rules = connect_data['url_rules']
|
440
|
-
@
|
441
|
-
@application_id = connect_data['application_id']
|
442
|
-
@beacon = connect_data['beacon']
|
443
|
-
@episodes_file = connect_data['episodes_file']
|
437
|
+
@beacon_configuration = BeaconConfiguration.new(connect_data)
|
444
438
|
|
445
439
|
control.log! "Connected to NewRelic Service at #{@collector}"
|
446
440
|
log.debug "Agent Run = #{@agent_id}."
|
@@ -2,44 +2,56 @@ require 'base64'
|
|
2
2
|
|
3
3
|
module NewRelic
|
4
4
|
module Agent
|
5
|
-
|
5
|
+
class BeaconConfiguration
|
6
|
+
attr_reader :browser_timing_header
|
7
|
+
attr_reader :application_id
|
8
|
+
attr_reader :browser_monitoring_key
|
9
|
+
attr_reader :beacon
|
6
10
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def browser_timing_header(protocol=nil)
|
14
|
-
|
15
|
-
return "" if NewRelic::Agent.instance.browser_monitoring_key.nil?
|
11
|
+
def initialize(connect_data)
|
12
|
+
@browser_monitoring_key = connect_data['browser_key']
|
13
|
+
@application_id = connect_data['application_id']
|
14
|
+
@beacon = connect_data['beacon']
|
16
15
|
|
17
|
-
|
16
|
+
@browser_timing_header = build_browser_timing_header(connect_data)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_browser_timing_header(connect_data)
|
20
|
+
return "" if @browser_monitoring_key.nil?
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
load_js = "(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=#{protocol}#{episodes_file}\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()"
|
22
|
+
episodes_url = connect_data['episodes_url']
|
23
|
+
load_episodes_file = connect_data['rum.load_episodes_file']
|
24
|
+
load_episodes_file = true if load_episodes_file.nil?
|
25
|
+
|
26
|
+
load_js = load_episodes_file ? "(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=\"#{episodes_url}\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()" : ""
|
27
|
+
|
26
28
|
"<script>var NREUMQ=[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);#{load_js}</script>"
|
27
29
|
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module BrowserMonitoring
|
33
|
+
|
34
|
+
def browser_timing_header
|
35
|
+
return "" if NewRelic::Agent.instance.beacon_configuration.nil?
|
36
|
+
NewRelic::Agent.instance.beacon_configuration.browser_timing_header
|
37
|
+
end
|
28
38
|
|
29
39
|
def browser_timing_footer
|
30
|
-
|
31
|
-
|
40
|
+
config = NewRelic::Agent.instance.beacon_configuration
|
41
|
+
return "" if config.nil?
|
42
|
+
license_key = config.browser_monitoring_key
|
32
43
|
|
33
44
|
return "" if license_key.nil?
|
34
45
|
|
35
|
-
application_id =
|
36
|
-
beacon =
|
37
|
-
transaction_name = Thread::current[:newrelic_scope_name] || "<unknown>"
|
38
|
-
obf = obfuscate(transaction_name)
|
46
|
+
application_id = config.application_id
|
47
|
+
beacon = config.beacon
|
39
48
|
|
49
|
+
transaction_name = Thread::current[:newrelic_scope_name] || "<unknown>"
|
40
50
|
frame = Thread.current[:newrelic_metric_frame]
|
41
51
|
|
42
52
|
if frame && frame.start
|
53
|
+
obf = obfuscate(transaction_name)
|
54
|
+
|
43
55
|
# HACK ALERT - there's probably a better way for us to get the queue-time
|
44
56
|
queue_time = ((Thread.current[:queue_time] || 0).to_f * 1000.0).round
|
45
57
|
app_time = ((Time.now - frame.start).to_f * 1000.0).round
|
@@ -47,6 +59,8 @@ module NewRelic
|
|
47
59
|
<<-eos
|
48
60
|
<script type="text/javascript" charset="utf-8">NREUMQ.push(["nrf2","#{beacon}","#{license_key}",#{application_id},"#{obf}",#{queue_time},#{app_time}])</script>
|
49
61
|
eos
|
62
|
+
else
|
63
|
+
""
|
50
64
|
end
|
51
65
|
end
|
52
66
|
|
@@ -54,11 +68,10 @@ eos
|
|
54
68
|
|
55
69
|
def obfuscate(text)
|
56
70
|
obfuscated = ""
|
57
|
-
|
58
|
-
key = NewRelic::Control.instance.license_key
|
71
|
+
@@license_bytes ||= NewRelic::Control.instance.license_key.bytes.to_a
|
59
72
|
|
60
73
|
text.bytes.each_with_index do |byte, i|
|
61
|
-
obfuscated.concat((byte ^
|
74
|
+
obfuscated.concat((byte ^ @@license_bytes[i % 13]))
|
62
75
|
end
|
63
76
|
|
64
77
|
[obfuscated].pack("m0").chomp
|
@@ -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,6 +16,13 @@ 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']
|
19
26
|
|
20
27
|
when /^2\./ # Rails 2.2-2.*
|
21
28
|
ActionView::RenderablePartial.module_eval do
|
@@ -24,6 +31,14 @@ if defined? ActionController
|
|
24
31
|
ActionView::Template.class_eval do
|
25
32
|
add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
|
26
33
|
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
|
+
|
27
42
|
end unless NewRelic::Control.instance['disable_view_instrumentation']
|
28
43
|
|
29
44
|
ActionController::Base.class_eval do
|
@@ -20,9 +20,8 @@ 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
|
24
|
-
def
|
25
|
-
def browser_timing_footer; end
|
23
|
+
def browser_timing_header; "" end
|
24
|
+
def browser_timing_footer; "" end
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -79,9 +79,16 @@ module NewRelic
|
|
79
79
|
fetch('developer_mode', fetch('developer'))
|
80
80
|
end
|
81
81
|
|
82
|
-
def
|
83
|
-
fetch('
|
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
|
84
90
|
end
|
91
|
+
|
85
92
|
# True if the app runs in multi-threaded mode
|
86
93
|
def multi_threaded?
|
87
94
|
fetch('multi_threaded')
|
@@ -21,19 +21,16 @@ 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
|
-
|
24
|
+
install_browser_monitoring rails_config
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
return if config.nil? || !config.respond_to?(:middleware) || !
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
::RAILS_DEFAULT_LOGGER.info "Installed episodes middleware"
|
35
|
-
end
|
36
|
-
end
|
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"
|
37
34
|
end
|
38
35
|
|
39
36
|
def install_developer_mode(rails_config)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module NewRelic::Rack
|
4
|
+
class BrowserMonitoring
|
5
|
+
|
6
|
+
def initialize(app, options = {})
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
# method required by Rack interface
|
11
|
+
def call(env)
|
12
|
+
result = @app.call(env) # [status, headers, response]
|
13
|
+
|
14
|
+
if (NewRelic::Agent.browser_timing_header != "") && should_instrument?(result[0], result[1])
|
15
|
+
response_string = autoinstrument_source(result[2], result[1])
|
16
|
+
|
17
|
+
if (response_string)
|
18
|
+
Rack::Response.new(response_string, result[0], result[1]).finish
|
19
|
+
else
|
20
|
+
result
|
21
|
+
end
|
22
|
+
else
|
23
|
+
result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def should_instrument?(status, headers)
|
28
|
+
status == 200 && headers["Content-Type"] && headers["Content-Type"].include?("text/html")
|
29
|
+
end
|
30
|
+
|
31
|
+
def autoinstrument_source(response, headers)
|
32
|
+
source = nil
|
33
|
+
response.each {|fragment| (source) ? (source << f) : (source = fragment)}
|
34
|
+
|
35
|
+
body_start = source.index("<body")
|
36
|
+
body_close = source.rindex("</body>")
|
37
|
+
|
38
|
+
if body_start && body_close
|
39
|
+
footer = NewRelic::Agent.browser_timing_footer
|
40
|
+
header = NewRelic::Agent.browser_timing_header
|
41
|
+
|
42
|
+
head_open = source.index("<head")
|
43
|
+
|
44
|
+
if head_open
|
45
|
+
head_close = source.index(">", head_open)
|
46
|
+
|
47
|
+
head_pos = head_close + 1
|
48
|
+
else
|
49
|
+
# put the header right above body start
|
50
|
+
head_pos = body_start
|
51
|
+
end
|
52
|
+
|
53
|
+
source = source[0..(head_pos-1)] + header + source[head_pos..(body_close-1)] + footer + source[body_close..-1]
|
54
|
+
|
55
|
+
headers['Content-Length'] = source.length.to_s if headers['Content-Length']
|
56
|
+
end
|
57
|
+
|
58
|
+
source
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/new_relic/version.rb
CHANGED
@@ -4,7 +4,7 @@ module NewRelic
|
|
4
4
|
MAJOR = 2
|
5
5
|
MINOR = 13
|
6
6
|
TINY = 4
|
7
|
-
BUILD = '
|
7
|
+
BUILD = 'rum6' #'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_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.13.4.
|
8
|
+
s.version = "2.13.4.rum6"
|
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", "Justin George"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-29}
|
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
|
@@ -100,6 +100,7 @@ http://github.com/newrelic/rpm/tree/master.
|
|
100
100
|
"lib/new_relic/metric_spec.rb",
|
101
101
|
"lib/new_relic/metrics.rb",
|
102
102
|
"lib/new_relic/noticed_error.rb",
|
103
|
+
"lib/new_relic/rack/browser_monitoring.rb",
|
103
104
|
"lib/new_relic/rack/developer_mode.rb",
|
104
105
|
"lib/new_relic/rack/metric_app.rb",
|
105
106
|
"lib/new_relic/rack/mongrel_rpm.ru",
|
metadata
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 13
|
9
|
-
- 4
|
10
|
-
- rum5
|
11
|
-
version: 2.13.4.rum5
|
4
|
+
prerelease: 7
|
5
|
+
version: 2.13.4.rum6
|
12
6
|
platform: ruby
|
13
7
|
authors:
|
14
8
|
- Bill Kayser
|
@@ -17,7 +11,7 @@ autorequire:
|
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
13
|
|
20
|
-
date: 2011-03-
|
14
|
+
date: 2011-03-29 00:00:00 -07:00
|
21
15
|
default_executable:
|
22
16
|
dependencies:
|
23
17
|
- !ruby/object:Gem::Dependency
|
@@ -28,9 +22,6 @@ dependencies:
|
|
28
22
|
requirements:
|
29
23
|
- - ">="
|
30
24
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 3
|
32
|
-
segments:
|
33
|
-
- 0
|
34
25
|
version: "0"
|
35
26
|
type: :development
|
36
27
|
version_requirements: *id001
|
@@ -42,9 +33,6 @@ dependencies:
|
|
42
33
|
requirements:
|
43
34
|
- - ">="
|
44
35
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
|
-
segments:
|
47
|
-
- 0
|
48
36
|
version: "0"
|
49
37
|
type: :development
|
50
38
|
version_requirements: *id002
|
@@ -56,9 +44,6 @@ dependencies:
|
|
56
44
|
requirements:
|
57
45
|
- - ">="
|
58
46
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
|
-
- 0
|
62
47
|
version: "0"
|
63
48
|
type: :development
|
64
49
|
version_requirements: *id003
|
@@ -157,6 +142,7 @@ files:
|
|
157
142
|
- lib/new_relic/metric_spec.rb
|
158
143
|
- lib/new_relic/metrics.rb
|
159
144
|
- lib/new_relic/noticed_error.rb
|
145
|
+
- lib/new_relic/rack/browser_monitoring.rb
|
160
146
|
- lib/new_relic/rack/developer_mode.rb
|
161
147
|
- lib/new_relic/rack/metric_app.rb
|
162
148
|
- lib/new_relic/rack/mongrel_rpm.ru
|
@@ -291,32 +277,23 @@ has_rdoc: true
|
|
291
277
|
homepage: http://www.github.com/newrelic/rpm
|
292
278
|
licenses: []
|
293
279
|
|
294
|
-
post_install_message:
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
Please see http://support.newrelic.com/faqs/docs/ruby-agent-release-notes
|
312
|
-
for a complete description of the features and enhancements available
|
313
|
-
in version 2.13 of the Ruby Agent.
|
314
|
-
|
315
|
-
For details on this specific release, refer to the CHANGELOG file.
|
316
|
-
|
317
|
-
Notice: Developer Mode now supports only Rails 2.3+ - refer to README
|
318
|
-
for instructions for previous versions
|
319
|
-
|
280
|
+
post_install_message: "\n\
|
281
|
+
PLEASE NOTE:\n\n\
|
282
|
+
Developer Mode is now a Rack middleware.\n\n\
|
283
|
+
RPM Developer Mode is no longer available in Rails 2.1 and earlier.\n\
|
284
|
+
However, starting in version 2.12 you can use Developer Mode in any\n\
|
285
|
+
Rack based framework, in addition to Rails. To install developer mode\n\
|
286
|
+
in a non-Rails application, just add NewRelic::Rack::DeveloperMode to\n\
|
287
|
+
your middleware stack.\n\n\
|
288
|
+
If you are using JRuby, we recommend using at least version 1.4 or \n\
|
289
|
+
later because of issues with the implementation of the timeout library.\n\n\
|
290
|
+
Refer to the README.md file for more information.\n\n\
|
291
|
+
Please see http://support.newrelic.com/faqs/docs/ruby-agent-release-notes\n\
|
292
|
+
for a complete description of the features and enhancements available\n\
|
293
|
+
in version 2.13 of the Ruby Agent.\n\n\
|
294
|
+
For details on this specific release, refer to the CHANGELOG file.\n\n\
|
295
|
+
Notice: Developer Mode now supports only Rails 2.3+ - refer to README\n\
|
296
|
+
for instructions for previous versions\n\n"
|
320
297
|
rdoc_options:
|
321
298
|
- --line-numbers
|
322
299
|
- --inline-source
|
@@ -329,23 +306,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
329
306
|
requirements:
|
330
307
|
- - ">="
|
331
308
|
- !ruby/object:Gem::Version
|
332
|
-
hash: 3
|
333
|
-
segments:
|
334
|
-
- 0
|
335
309
|
version: "0"
|
336
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
311
|
none: false
|
338
312
|
requirements:
|
339
313
|
- - ">="
|
340
314
|
- !ruby/object:Gem::Version
|
341
|
-
hash: 3
|
342
|
-
segments:
|
343
|
-
- 0
|
344
315
|
version: "0"
|
345
316
|
requirements: []
|
346
317
|
|
347
318
|
rubyforge_project:
|
348
|
-
rubygems_version: 1.
|
319
|
+
rubygems_version: 1.5.0
|
349
320
|
signing_key:
|
350
321
|
specification_version: 3
|
351
322
|
summary: New Relic Ruby Performance Monitoring Agent
|