Class: Librato::Metrics::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/librato/metrics/util.rb

Constant Summary collapse

SEPARATOR =
"%%"

Class Method Summary collapse

Class Method Details

.build_key_for(metric_name, tags) ⇒ String

Builds a Hash key from metric name and tags.

Parameters:

  • metric_name (String)

    The unique identifying metric name of the property being tracked.

  • tags (Hash)

    A set of name=value tag pairs that describe the particular data stream.

Returns:

  • (String)

    the Hash key


12
13
14
15
16
17
18
19
20
# File 'lib/librato/metrics/util.rb', line 12

def self.build_key_for(metric_name, tags)
  key_name = metric_name
  tags.sort.each do |key, value|
    k = key.to_s.downcase
    v = value.is_a?(String) ? value.downcase : value
    key_name = "#{key_name}#{SEPARATOR}#{k}=#{v}"
  end
  key_name
end