Class: PrometheusClientAddons::Prometheus::Client::MultiMetric

Inherits:
Prometheus::Client::Metric
  • Object
show all
Defined in:
lib/prometheus_client_addons/prometheus/client/multi_metric.rb

Direct Known Subclasses

ActiveRecord, GC, Puma

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix: '', base_labels: {}) ⇒ MultiMetric

Returns a new instance of MultiMetric.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 10

def initialize(prefix: '', base_labels: {})
  prefix = "#{prefix}_" unless prefix == ''

  @prefix = prefix
  @name = prefix
  @base_labels = base_labels

  multi_name_type.keys.each { |name| validate_name("#{prefix}#{name}".to_sym) }
  multi_name_docstring.keys.each { |name| validate_name("#{prefix}#{name}".to_sym) }
  multi_name_docstring.values.each(&method(:validate_docstring))
  @validator = ::Prometheus::Client::LabelSetValidator.new
  @validator.valid?(base_labels)
end

Instance Attribute Details

#base_labelsObject (readonly)

Returns the value of attribute base_labels.



8
9
10
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 8

def base_labels
  @base_labels
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 8

def name
  @name
end

#prefixObject (readonly)

Returns the value of attribute prefix.



8
9
10
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 8

def prefix
  @prefix
end

Instance Method Details

#multi_name_docstringObject



28
29
30
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 28

def multi_name_docstring
  fail('Should return hash {name => docstrings}')
end

#multi_name_typeObject



24
25
26
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 24

def multi_name_type
  fail('Should return hash {name => type}')
end

#multi_valuesObject



32
33
34
# File 'lib/prometheus_client_addons/prometheus/client/multi_metric.rb', line 32

def multi_values
  fail('Should return hash {name => {label_set => value, label_set => value, }}')
end