Class: Prometheus::Client::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/prometheus/client/metric.rb

Overview

Metric

Direct Known Subclasses

Counter, Gauge, Summary

Instance Method Summary collapse

Constructor Details

#initializeMetric

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

#typeObject

Returns the metric type

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/prometheus/client/metric.rb', line 14

def type
  raise NotImplementedError
end