Class: Prometheus::Client::Metric
- Inherits:
-
Object
- Object
- Prometheus::Client::Metric
- Defined in:
- lib/prometheus/client/metric.rb
Overview
Metric
Instance Method Summary collapse
-
#get(labels = {}) ⇒ Object
Returns the value for the given label set.
-
#initialize ⇒ Metric
constructor
A new instance of Metric.
-
#to_json(*json) ⇒ Object
Generates JSON representation.
-
#type ⇒ Object
Returns the metric type.
Constructor Details
#initialize ⇒ Metric
Returns a new instance of Metric.
8 9 10 11 |
# File 'lib/prometheus/client/metric.rb', line 8 def initialize @mutex = Mutex.new @values = Hash.new { |hash, key| hash[key] = default } end |
Instance Method Details
#get(labels = {}) ⇒ Object
Returns the value for the given label set
19 20 21 |
# File 'lib/prometheus/client/metric.rb', line 19 def get(labels = {}) @values[label_set_for(labels)] end |
#to_json(*json) ⇒ Object
Generates JSON representation
24 25 26 27 28 29 |
# File 'lib/prometheus/client/metric.rb', line 24 def to_json(*json) { 'type' => type, 'value' => value }.to_json(*json) end |
#type ⇒ Object
Returns the metric type
14 15 16 |
# File 'lib/prometheus/client/metric.rb', line 14 def type raise NotImplementedError end |