Class: Metrics::Backend::Test::Metric

Inherits:
Metric
  • Object
show all
Defined in:
lib/metrics/backend/test.rb

Instance Attribute Summary

Attributes inherited from Metric

#description, #name, #type, #unit

Instance Method Summary collapse

Methods inherited from Metric

#initialize

Constructor Details

This class inherits a constructor from Metrics::Metric

Instance Method Details

#emit(value, tags: nil, sample_rate: 1.0) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/metrics/backend/test.rb', line 15

def emit(value, tags: nil, sample_rate: 1.0)
  unless value.is_a?(Numeric)
    raise ArgumentError, "Value must be numeric!"
  end
  
  tags&.each do |tag|
    raise ArgumentError, "Invalid tag (must be String): #{tag.inspect}!" unless tag.is_a?(String)
    
    # We should let the underlying backend handle any tag limitations, e.g. converting invalid characters to underscores, etc.
    #
    # unless tag =~ VALID_TAG
    #   raise ArgumentError, "Invalid tag (must match #{VALID_TAG}): #{tag.inspect}!"
    # end
  end
end