module Invoca::Metrics

Constants

CONFIG_FIELDS
VERSION

Attributes

service_name[W]

Public Class Methods

config() click to toggle source
# File lib/invoca/metrics.rb, line 30
def config
  @config ||= {}
end
config=(config_hash) click to toggle source
# File lib/invoca/metrics.rb, line 34
def config=(config_hash)
  config_valid?(config_hash) or raise ArgumentError, "Invalid config #{config_hash}. Allowed fields for config key: #{CONFIG_FIELDS}."
  @config = config_hash
end
default_client_config() click to toggle source
# File lib/invoca/metrics.rb, line 39
def default_client_config
  {
    service_name:    Invoca::Metrics.service_name,
    server_name:     Invoca::Metrics.server_name,
    cluster_name:    Invoca::Metrics.cluster_name,
    statsd_host:     Invoca::Metrics.statsd_host,
    statsd_port:     Invoca::Metrics.statsd_port,
    sub_server_name: Invoca::Metrics.sub_server_name
  }.merge(config[default_config_key] || {})
end
initialized?() click to toggle source
# File lib/invoca/metrics.rb, line 26
def initialized?
  @service_name
end
service_name() click to toggle source
# File lib/invoca/metrics.rb, line 22
def service_name
  @service_name or raise ArgumentError, "You must assign a value to Invoca::Metrics.service_name"
end

Private Class Methods

config_valid?(config_hash) click to toggle source
# File lib/invoca/metrics.rb, line 52
def config_valid?(config_hash)
  config_hash.nil? || config_hash.all? { |_config_key, config_key_hash| (config_key_hash.keys - CONFIG_FIELDS).empty?  }
end