Class: PrometheusExporter::Client::RemoteMetric

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, help:, type:, client:, opts: nil) ⇒ RemoteMetric

Returns a new instance of RemoteMetric.



12
13
14
15
16
17
18
# File 'lib/prometheus_exporter/client.rb', line 12

def initialize(name:, help:, type:, client:, opts: nil)
  @name = name
  @help = help
  @client = client
  @type = type
  @opts = opts
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



10
11
12
# File 'lib/prometheus_exporter/client.rb', line 10

def help
  @help
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/prometheus_exporter/client.rb', line 10

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/prometheus_exporter/client.rb', line 10

def type
  @type
end

Instance Method Details

#decrement(keys = nil, value = 1) ⇒ Object



41
42
43
# File 'lib/prometheus_exporter/client.rb', line 41

def decrement(keys = nil, value = 1)
  @client.send_json(standard_values(value, keys, :decrement))
end

#increment(keys = nil, value = 1) ⇒ Object



37
38
39
# File 'lib/prometheus_exporter/client.rb', line 37

def increment(keys = nil, value = 1)
  @client.send_json(standard_values(value, keys, :increment))
end

#observe(value = 1, keys = nil) ⇒ Object



33
34
35
# File 'lib/prometheus_exporter/client.rb', line 33

def observe(value = 1, keys = nil)
  @client.send_json(standard_values(value, keys))
end

#standard_values(value, keys, prometheus_exporter_action = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/prometheus_exporter/client.rb', line 20

def standard_values(value, keys, prometheus_exporter_action = nil)
  values = {
    type: @type,
    help: @help,
    name: @name,
    keys: keys,
    value: value
  }
  values[:prometheus_exporter_action] = prometheus_exporter_action if prometheus_exporter_action
  values[:opts] = @opts if @opts
  values
end