Permalink
Browse files

Allow hostname to be excluded.

  • Loading branch information...
1 parent c7bba2c commit 195cd9917fa416747f2d5fbf68207f57d1c6411c @mheffner mheffner committed Dec 7, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/rack_monitor.rb
View
@@ -94,7 +94,8 @@ class ProcessUtilization
# :window - The Integer number of seconds before the
# horizon resets.
# :stats - Optional StatsD client.
- # :hostname - Optional String hostname.
+ # :hostname - Optional String hostname. Set to nil
+ # to exclude.
# :stats_prefix - Optional String prefix for StatsD keys.
# Default: "rack"
def initialize(app, domain, revision, options = {})
@@ -110,8 +111,13 @@ def initialize(app, domain, revision, options = {})
@track_gc = GC.respond_to?(:time)
if @stats = options[:stats]
- @hostname = options[:hostname] || `hostname -s`.chomp
- @stats_prefix = "#{options[:stats_prefix] || :rack}.#{@hostname}"
+ prefix = [options[:stats_prefix] || :rack]
+ if options.has_key?(:hostname)
+ prefix << options[:hostname] unless options[:hostname].nil?
+ else
+ prefix << `hostname -s`.chomp
+ end
+ @stats_prefix = prefix.join(".")
end
end

0 comments on commit 195cd99

Please sign in to comment.