Skip to content

Commit

Permalink
Merge branch '3.0.0_dev' of chi-repo.newrelic.com:/git/ruby_agent int…
Browse files Browse the repository at this point in the history
…o 3.0.0_dev
  • Loading branch information
jaggederest committed Apr 29, 2011
2 parents 233a78e + 9d103c6 commit dfdb4f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 8 additions & 0 deletions lib/new_relic/agent.rb
Expand Up @@ -292,6 +292,14 @@ def disable_all_tracing
def is_execution_traced?
Thread.current[:newrelic_untraced].nil? || Thread.current[:newrelic_untraced].last != false
end

def is_transaction_traced?
Thread::current[:record_tt] != false
end

def is_sql_recorded?
Thread::current[:record_sql] != false
end

# Set a filter to be applied to errors that RPM will track. The
# block should evalute to the exception to track (which could be
Expand Down
12 changes: 6 additions & 6 deletions lib/new_relic/agent/browser_monitoring.rb
Expand Up @@ -52,20 +52,20 @@ module BrowserMonitoring
def browser_timing_header
return "" if NewRelic::Agent.instance.beacon_configuration.nil?

return "" if Thread::current[:record_tt] == false || !NewRelic::Agent.is_execution_traced?

return "" if !NewRelic::Agent.is_transaction_traced? || !NewRelic::Agent.is_execution_traced?
NewRelic::Agent.instance.beacon_configuration.browser_timing_header
end

def browser_timing_footer
config = NewRelic::Agent.instance.beacon_configuration
return "" if config.nil?
return "" if !config.rum_enabled
return "" if config.nil? || !config.rum_enabled

license_key = config.browser_monitoring_key
return "" if license_key.nil?

return "" if Thread::current[:record_tt] == false || !NewRelic::Agent.is_execution_traced?

return "" if !NewRelic::Agent.is_transaction_traced? || !NewRelic::Agent.is_execution_traced?
application_id = config.application_id
beacon = config.beacon

Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/transaction_sampler.rb
Expand Up @@ -274,7 +274,7 @@ def append_backtrace(segment, duration)
# config is the driver configuration for the connection
# duration is seconds, float value.
def notice_sql(sql, config, duration)
if Thread::current[:record_sql] != false
if NewRelic::Agent.is_sql_recorded?
notice_extra_data(sql, duration, :sql, config, :connection_config)
end
end
Expand Down Expand Up @@ -355,7 +355,7 @@ def reset!
# new transaction sample builder with the stated time as a
# starting point and saves it in the thread local variable
def start_builder(time=nil)
if disabled || Thread::current[:record_tt] == false || !NewRelic::Agent.is_execution_traced?
if disabled || !NewRelic::Agent.is_transaction_traced? || !NewRelic::Agent.is_execution_traced?
clear_builder
else
Thread::current[BUILDER_KEY] ||= TransactionSampleBuilder.new(time)
Expand Down
10 changes: 5 additions & 5 deletions test/new_relic/agent/rpm_agent_test.rb
Expand Up @@ -90,15 +90,15 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
end
should "set_record_sql" do
@agent.set_record_sql(false)
assert !Thread::current[:record_sql]
assert !NewRelic::Agent.is_sql_recorded?
NewRelic::Agent.disable_sql_recording do
assert_equal false, Thread::current[:record_sql]
assert_equal false, NewRelic::Agent.is_sql_recorded?
NewRelic::Agent.disable_sql_recording do
assert_equal false, Thread::current[:record_sql]
assert_equal false, NewRelic::Agent.is_sql_recorded?
end
assert_equal false, Thread::current[:record_sql]
assert_equal false, NewRelic::Agent.is_sql_recorded?
end
assert !Thread::current[:record_sql]
assert !NewRelic::Agent.is_sql_recorded?
@agent.set_record_sql(nil)
end

Expand Down

0 comments on commit dfdb4f3

Please sign in to comment.