Created
April 9, 2014 16:37
-
-
Save ncdc/10289981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node-util/conf/watchman/plugins.d/metrics_plugin.rb b/node-util/conf/watchman/plugins.d/metrics_plugin.rb | |
index b16fb6f..fa99ea9 100644 | |
--- a/node-util/conf/watchman/plugins.d/metrics_plugin.rb | |
+++ b/node-util/conf/watchman/plugins.d/metrics_plugin.rb | |
@@ -71,11 +71,20 @@ module OpenShift | |
@cgroups_keys = @cgroups_keys.split(',').map(&:strip).join(' -r ') | |
end | |
+ Syslog.info "Initializing Watchman metrics plugin" | |
+ | |
# Set the sleep time for the metrics thread | |
# default to running every 60 seconds if not set in node.conf | |
@delay = Integer(@config.get('WATCHMAN_METRICS_INTERVAL')) rescue DEFAULT_INTERVAL | |
- Syslog.info "Initializing Watchman metrics plugin, interval=#{@delay}s" | |
+ # must be at least 10s | |
+ if @delay < 10 | |
+ Syslog.warning "Metrics interval value '#{@delay}' is too small - resetting to 10s" | |
+ @delay = 10 | |
+ end | |
+ | |
+ Syslog.info "Metrics interval = #{@delay}s" | |
+ | |
@mutex = Mutex.new | |
@syslog_line_shipper = SyslogLineShipper.new | |
diff --git a/node/test/unit/metrics_plugin_test.rb b/node/test/unit/metrics_plugin_test.rb | |
index b2d9002..8123272 100644 | |
--- a/node/test/unit/metrics_plugin_test.rb | |
+++ b/node/test/unit/metrics_plugin_test.rb | |
@@ -104,6 +104,14 @@ class MetricsPluginMetricsTest < OpenShift::NodeTestCase | |
assert_equal 123, @metrics.delay | |
end | |
+ def test_delay_too_small | |
+ Syslog.stubs(:info) | |
+ Syslog.stubs(:warning) | |
+ @config.stubs(:get).with('WATCHMAN_METRICS_INTERVAL').returns(1) | |
+ @metrics = OpenShift::Runtime::WatchmanPlugin::Metrics.new(@config) | |
+ assert_equal 10, @metrics.delay | |
+ end | |
+ | |
def test_gears_updated_adds_gears | |
Syslog.stubs(:info) | |
@metrics = OpenShift::Runtime::WatchmanPlugin::Metrics.new(@config) | |
@@ -150,7 +158,8 @@ class MetricsPluginMetricsTest < OpenShift::NodeTestCase | |
end | |
def test_tick_exception | |
- Syslog.expects(:info).with("Initializing Watchman metrics plugin, interval=60s") | |
+ Syslog.expects(:info).with("Initializing Watchman metrics plugin") | |
+ Syslog.expects(:info).with("Metrics interval = 60s") | |
@metrics = OpenShift::Runtime::WatchmanPlugin::Metrics.new(@config) | |
update = %w(uuid2) | |
@metrics.gears_updated(update) | |
@@ -226,7 +235,8 @@ class MetricsPluginMetricsTest < OpenShift::NodeTestCase | |
end | |
def test_publish | |
- Syslog.expects(:info).with("Initializing Watchman metrics plugin, interval=60s") | |
+ Syslog.expects(:info).with("Initializing Watchman metrics plugin") | |
+ Syslog.expects(:info).with("Metrics interval = 60s") | |
@config.stubs(:get).with('METRICS_METADATA').returns('app:OPENSHIFT_APP_NAME,gear:OPENSHIFT_GEAR_UUID') | |
@metrics = OpenShift::Runtime::WatchmanPlugin::Metrics.new(@config) | |
File.expects(:read).with('/var/lib/openshift/uuid1/.env/OPENSHIFT_APP_NAME').returns('appName') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment