Permalink
Browse files

RUBY-868 moved apdex_t accessor and cleaned up tests

  • Loading branch information...
1 parent bad3ff4 commit f42b5f5fd0836691b1ec09c0e5f3b3d787e81a6b @gnarg gnarg committed Aug 29, 2012
View
@@ -60,7 +60,6 @@ digraph AgentEnabled {
node[shape=box,color=orange]
"Control#init_plugin"
- "Control#apdex_t"
"Control#api_server"
"Control#proxy_server"
"Control#server_from_host"
@@ -157,7 +156,6 @@ digraph AgentEnabled {
"Control#init_plugin" -> "Control#setup_log"
"Control#init_plugin" -> "[disable_samplers]"
"Control#should_log?" -> "[agent_enabled]"
- "Control#apdex_t" -> "[apdex_t]"
"Control#api_server" -> "[api_host]"
"Control#api_server" -> "[api_port]"
"Control#proxy_server" -> "[proxy_host]"
@@ -193,7 +191,7 @@ digraph AgentEnabled {
"Agent#using_forking_dispatcher?" -> "[dispatcher]"
"Agent#has_license_key?" -> "[license_key]"
"Agent#correct_license_length" -> "[license_key]"
- "Agent#apdex_f" -> "Control#apdex_t"
+ "Agent#apdex_f" -> "[apdex_t]"
"Agent#check_config_and_start_agent" -> "[sync_startup]"
"Agent#install_exit_handler" -> "[send_data_on_exit]"
"Agent#log_app_names" -> "Config#app_names"
@@ -269,10 +267,10 @@ digraph AgentEnabled {
"DelayedJobInjection#depends_on" -> "[disable_dj]"
"DelayedJobInjection#executes" -> "Control#init_plugin"
- "MetricFrame.update_apdex" -> "Control#apdex_t"
+ "MetricFrame.update_apdex" -> "[apdex_t]"
- "TranactionInfo#force_persist_sample?" -> "Control#apdex_t"
- "TranactionInfo#include_guid?" -> "Control#apdex_t"
+ "TranactionInfo#force_persist_sample?" -> "[apdex_t]"
+ "TranactionInfo#include_guid?" -> "[apdex_t]"
"TransactionSampleBuilder#initialize" -> "[transaction_tracer.limit_segments]"
"TransactionSampleBuilder#set_transaction_info" -> "[capture_params]"
@@ -796,7 +796,7 @@ def configure_transaction_tracer!(server_enabled, sample_rate)
# apdex_f is always 4 times the apdex_t
def apdex_f
- (4 * NewRelic::Control.instance.apdex_t).to_f
+ (4 * Agent.config[:apdex_t]).to_f
end
# Sets the sql recording configuration by trying to detect
@@ -320,7 +320,7 @@ def self.record_apdex(current_metric, action_duration, total_duration, is_error)
# the apdex should be recorded as a failure regardless of duration.
def self.update_apdex(stat, duration, failed)
duration = duration.to_f
- apdex_t = NewRelic::Control.instance.apdex_t
+ apdex_t = Agent.config[:apdex_t]
case
when failed
stat.record_apdex_f
@@ -15,11 +15,11 @@ def initialize
end
def force_persist_sample?(sample)
- token && sample.duration > NewRelic::Control.instance.apdex_t
+ token && sample.duration > Agent.config[:apdex_t]
end
def include_guid?
- token && duration > NewRelic::Control.instance.apdex_t
+ token && duration > Agent.config[:apdex_t]
end
def guid
View
@@ -12,7 +12,6 @@
require 'new_relic/control/frameworks'
require 'new_relic/control/profiling'
require 'new_relic/control/logging_methods'
-require 'new_relic/control/configuration'
require 'new_relic/control/server_methods'
require 'new_relic/control/instrumentation'
require 'new_relic/control/class_methods'
@@ -1,12 +0,0 @@
-module NewRelic
- class Control
- # used to contain methods to look up settings from the
- # configuration located in newrelic.yml
- module Configuration
- def apdex_t
- Agent.config[:apdex_t]
- end
- end
- include Configuration
- end
-end
@@ -1,34 +1,9 @@
-require File.expand_path(File.join(File.dirname(__FILE__),'/../../test_helper'))
-
-class NewRelic::Control::ConfigurationTest < Test::Unit::TestCase
- require 'new_relic/control/configuration'
- include NewRelic::Control::Configuration
-
- def setup
- # The log stuff is memoized so let's clear it each time.
- NewRelic::Control.instance.instance_variable_set '@log_path', nil
- NewRelic::Control.instance.instance_variable_set '@log_file', nil
- @root = ::Rails::VERSION::MAJOR == 3 ? Rails.root : RAILS_ROOT
- end
-
- def test_log_path_uses_default_if_not_set
- NewRelic::Control.instance.setup_log
- assert_match(/log\/newrelic_agent.log$/,
- NewRelic::Control.instance.log_file)
- end
-
- def test_log_file_path_uses_given_value
- Dir.stubs(:mkdir).returns(true)
- with_config(:log_file_path => 'lerg') do
- NewRelic::Control.instance.setup_log
- assert_match(/\/lerg\/newrelic_agent.log$/,
- NewRelic::Control.instance.log_file)
- end
- end
+require File.expand_path(File.join(File.dirname(__FILE__),'/../../../test_helper'))
+class NewRelic::Control::Frameworks::RailsTest < Test::Unit::TestCase
def test_install_browser_monitoring
require(File.expand_path(File.join(File.dirname(__FILE__),
- '/../../../lib/new_relic/rack/browser_monitoring')))
+ '/../../../../lib/new_relic/rack/browser_monitoring')))
middleware = stub('middleware config')
config = stub('rails config', :middleware => middleware)
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
@@ -43,7 +18,7 @@ def test_install_browser_monitoring_should_not_install_when_not_configured
config = stub('rails config', :middleware => middleware)
middleware.expects(:use).never
NewRelic::Control.instance.instance_eval { @browser_monitoring_installed = false }
-
+
with_config(:'browser_monitoring.auto_instrument' => false) do
NewRelic::Control.instance.install_browser_monitoring(config)
end
@@ -5,13 +5,15 @@
class BaseLoggingMethods
# stub class to enable testing of the module
include NewRelic::Control::LoggingMethods
- include NewRelic::Control::Configuration
def root; "."; end
end
class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
def setup
@base = BaseLoggingMethods.new
+ NewRelic::Control.instance.instance_variable_set '@log_path', nil
+ NewRelic::Control.instance.instance_variable_set '@log_file', nil
+ @root = ::Rails::VERSION::MAJOR == 3 ? Rails.root : RAILS_ROOT
super
end
@@ -186,6 +188,21 @@ def test_set_file_destination_from_NEW_RELIC_LOG_env_var
reset_environment_config
end
+ def test_log_path_uses_default_if_not_set
+ NewRelic::Control.instance.setup_log
+ assert_match(/log\/newrelic_agent.log$/,
+ NewRelic::Control.instance.log_file)
+ end
+
+ def test_log_file_path_uses_given_value
+ Dir.stubs(:mkdir).returns(true)
+ with_config(:log_file_path => 'lerg') do
+ NewRelic::Control.instance.setup_log
+ assert_match(/\/lerg\/newrelic_agent.log$/,
+ NewRelic::Control.instance.log_file)
+ end
+ end
+
def reset_environment_config
NewRelic::Agent::Configuration.manager.config_stack[0] =
NewRelic::Agent::Configuration::EnvironmentSource.new

0 comments on commit f42b5f5

Please sign in to comment.