Class: Fluent::Plugin::Prometheus::Summary
- Defined in:
- lib/fluent/plugin/prometheus.rb
Instance Attribute Summary
Attributes inherited from Metric
Instance Method Summary collapse
-
#initialize(element, registry, labels) ⇒ Summary
constructor
A new instance of Summary.
- #instrument(record, expander, placeholders) ⇒ Object
Methods inherited from Metric
Constructor Details
#initialize(element, registry, labels) ⇒ Summary
Returns a new instance of Summary.
218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/fluent/plugin/prometheus.rb', line 218 def initialize(element, registry, labels) super if @key.nil? raise ConfigError, "summary metric requires 'key' option" end begin @summary = registry.summary(element['name'].to_sym, element['desc']) rescue ::Prometheus::Client::Registry::AlreadyRegisteredError @summary = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :summary, element['desc']) end end |
Instance Method Details
#instrument(record, expander, placeholders) ⇒ Object
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/fluent/plugin/prometheus.rb', line 231 def instrument(record, , placeholders) if @key.is_a?(String) value = record[@key] else value = @key.call(record) end if value @summary.observe(labels(record, , placeholders), value) end end |