Permalink
Browse files

Merge branch '3.0.0_dev' of chi-repo.newrelic.com:/git/ruby_agent int…

…o 3.0.0_dev
  • Loading branch information...
2 parents c5e1fe8 + 5c36504 commit dd421e240e320bbcbeafe9d6eaa4d9df7ff1c9fe @jaggederest jaggederest committed May 4, 2011
View
@@ -389,28 +389,17 @@ def record_transaction(response_sec, options = {})
agent.record_transaction(response_sec, options)
end
- # PRE-RELEASE
# Returns a Javascript string which should be injected into the very top of the response body
#
def browser_timing_header
agent.browser_timing_header
end
- # PRE-RELEASE
# Returns a Javascript string which should be injected into the very bottom of the response body
#
def browser_timing_footer
agent.browser_timing_footer
end
- # FOR BACKWARD COMPATIBILITY (REMOVE BEFORE GA)
- def browser_instrumentation_header(options={})
- agent.browser_timing_header
- end
-
- # FOR BACKWARD COMPATIBILITY (REMOVE BEFORE GA)
- def browser_instrumentation_footer(options={})
- agent.browser_timing_footer
- end
end
end
@@ -50,18 +50,18 @@ def build_browser_timing_header(connect_data)
module BrowserMonitoring
def browser_timing_header
- #return no header if already instrumented with a header
- return "" if Thread.current[:newrelic_most_recent_transaction][:rum_header_added]
+ #return no header if outside a transaction, if already instrumented with a header, or if tracing is disabled
+ return "" if Thread.current[:newrelic_most_recent_transaction].nil? || Thread.current[:newrelic_most_recent_transaction][:rum_header_added]
return "" if NewRelic::Agent.instance.beacon_configuration.nil?
-
return "" if !NewRelic::Agent.is_transaction_traced? || !NewRelic::Agent.is_execution_traced?
+
Thread.current[:newrelic_most_recent_transaction][:rum_header_added] = true
NewRelic::Agent.instance.beacon_configuration.browser_timing_header
end
def browser_timing_footer
#return no footer if already instrumented or if the footer is requested before/without a header
- return "" if Thread.current[:newrelic_most_recent_transaction][:rum_footer_added] || !Thread.current[:newrelic_most_recent_transaction][:rum_header_added]
+ return "" if Thread.current[:newrelic_most_recent_transaction].nil? || Thread.current[:newrelic_most_recent_transaction][:rum_footer_added] || !Thread.current[:newrelic_most_recent_transaction][:rum_header_added]
config = NewRelic::Agent.instance.beacon_configuration
return "" if config.nil? || !config.rum_enabled
View
@@ -4,16 +4,16 @@
# require 'new_relic/recipes'
# to your deploy.rb
#
-# Defined deploy:notify_rpm which will send information about the deploy to RPM.
+# Defined deploy:notify_rpm which will send information about the deploy to New Relic.
# The task will run on app servers except where no_release is true.
# If it fails, it will not affect the task execution or do a rollback.
#
make_notify_task = Proc.new do
namespace :newrelic do
- # on all deployments, notify RPM
- desc "Record a deployment in New Relic RPM (rpm.newrelic.com)"
+ # on all deployments, notify New Relic
+ desc "Record a deployment in New Relic (rpm.newrelic.com)"
task :notice_deployment, :roles => :app, :except => {:no_release => true } do
rails_env = fetch(:newrelic_rails_env, fetch(:rails_env, "production"))
require File.join(File.dirname(__FILE__), 'command.rb')
@@ -33,6 +33,13 @@ def test_browser_timing_header
assert_equal "<script>var NREUMQ=[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()</script>", header
end
+ def test_browser_timing_header_outside_transaction
+ Thread.current[:newrelic_most_recent_transaction] = nil
+ header = browser_timing_header
+ assert_equal "", header
+ end
+
+
def test_browser_timing_header_twice
header = browser_timing_header
assert_equal "<script>var NREUMQ=[];NREUMQ.push([\"mark\",\"firstbyte\",new Date().getTime()]);(function(){var d=document;var e=d.createElement(\"script\");e.type=\"text/javascript\";e.async=true;e.src=\"this_is_my_file\";var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(e,s);})()</script>", header
@@ -78,6 +85,12 @@ def test_browser_timing_footer
assert footer.include?("<script type=\"text/javascript\" charset=\"utf-8\">NREUMQ.push([\"nrf2\",")
end
+ def test_browser_timing_footer_outside_transaction
+ Thread.current[:newrelic_most_recent_transaction] = nil
+ footer = browser_timing_footer
+ assert_equal "", footer
+ end
+
def test_browser_timing_footer_without_calling_header
footer = browser_timing_footer
assert_equal "", footer
@@ -2,7 +2,7 @@
xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="/newrelic/file/javascript/jquery-1.4.2.js"></script>
-<title>New Relic RPM Developer Mode</title>
+<title>New Relic Developer Mode</title>
<link href="/newrelic/file/stylesheets/style.css"
media="screen" rel="stylesheet" type="text/css" />
</head>
@@ -12,7 +12,7 @@
<table width="100%" height="60">
<tr>
<td valign="middle">
- <a href='/newrelic'><img src="/newrelic/file/images/new_relic_rpm_desktop.gif" hspace="10" alt="New Relic RPM"/></a>
+ <a href='/newrelic'><img src="/newrelic/file/images/new_relic_rpm_desktop.gif" hspace="10" alt="New Relic"/></a>
</td>
<td class="top_nav" valign="bottom">
<ul id="navlist">

0 comments on commit dd421e2

Please sign in to comment.