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



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

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)
		
		unless tag =~ VALID_TAG
			raise ArgumentError, "Invalid tag (must match #{VALID_TAG}): #{tag.inspect}!"
		end
	end
end