lib/fozzie/configuration.rb in fozzie-0.0.26 vs lib/fozzie/configuration.rb in fozzie-0.0.27

- old
+ new

@@ -8,11 +8,11 @@ # Fozzie configuration allows assignment of global properties # that will be used within the Fozzie codebase. class Configuration include Sys - attr_accessor :env, :config_path, :host, :port, :appname, :namespaces, :timeout, :monitor_classes, :sniff_envs, :ignore_prefix + attr_accessor :env, :config_path, :host, :port, :appname, :namespaces, :timeout, :monitor_classes, :sniff_envs, :ignore_prefix, :prefix def initialize(args = {}) merge_and_assign_config(args) self.origin_name end @@ -22,15 +22,21 @@ end # Returns the prefix for any stat requested to be registered def data_prefix return nil if @ignore_prefix + return @data_prefix if @data_prefix - @data_prefix ||= [appname, origin_name, env].collect do |s| - s.empty? ? nil : s.gsub('.', '-') - end.compact.join('.').strip - (@data_prefix.empty? ? nil : @data_prefix) + data_prefix = @prefix.collect do |me| + (me.kind_of?(Symbol) && self.respond_to?(me.to_sym) ? self.send(me) : me.to_s) + end + + data_prefix = data_prefix.collect do |s| + s.empty? ? nil : s.gsub(Socket::DELIMETER, '-') + end.compact.join(Socket::DELIMETER).strip + + @data_prefix ||= (data_prefix.empty? ? nil : data_prefix) end # Returns the origin name of the current machine to register the stat against def origin_name @origin_name ||= Uname.nodename @@ -53,9 +59,10 @@ # Default configuration settings def self.default_configuration { :host => '127.0.0.1', + :prefix => [:appname, :origin_name, :env], :port => 8125, :config_path => '', :env => (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'), :appname => '', :namespaces => %w{Stats S Statistics Warehouse}, \ No newline at end of file