Class: Fluent::Prometheus::Gauge
- Defined in:
- lib/fluent/plugin/prometheus.rb
Instance Attribute Summary
Attributes inherited from Metric
Instance Method Summary collapse
-
#initialize(element, registry, labels) ⇒ Gauge
constructor
A new instance of Gauge.
- #instrument(record, expander, placeholders) ⇒ Object
Methods inherited from Metric
Constructor Details
#initialize(element, registry, labels) ⇒ Gauge
Returns a new instance of Gauge.
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/fluent/plugin/prometheus.rb', line 131 def initialize(element, registry, labels) super if @key.nil? raise ConfigError, "gauge metric requires 'key' option" end begin @gauge = registry.gauge(element['name'].to_sym, element['desc']) rescue ::Prometheus::Client::Registry::AlreadyRegisteredError @gauge = Fluent::Prometheus::Metric.get(registry, element['name'].to_sym, :gauge, element['desc']) end end |
Instance Method Details
#instrument(record, expander, placeholders) ⇒ Object
144 145 146 147 148 |
# File 'lib/fluent/plugin/prometheus.rb', line 144 def instrument(record, , placeholders) if record[@key] @gauge.set(labels(record, , placeholders), record[@key]) end end |