Module: ActiveMeasure::Tagging::InstanceMethods

Defined in:
lib/active_measure/tagging.rb

Overview

Add tags support to the client, the tags have to be passed in at initialization or at the time of the metric tags are a hash of key value pairs

Instance Method Summary collapse

Instance Method Details

#check_tags(tags) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
# File 'lib/active_measure/tagging.rb', line 10

def check_tags(tags)
  raise InvalidMetric, 'Tags must be a hash' unless tags.is_a?(Hash)
  ## All keys need to be string and start with a letter, they can contain letters, numbers, underscores.
  # They cannot contain spaces, dashes, or other special characters.
  # They cannot be longer than 32 characters
  # They cannot be empty
  raise InvalidMetric, 'Tags keys must be basic string' unless tags.keys.all? { |k| k.is_a?(String) && k.match?(/^[a-zA-Z][a-zA-Z0-9_]{0,31}$/) }
  raise InvalidMetric, 'Tags must be a hash of key value pairs' unless tags.values.all? { |v| v.is_a?(String) }
end