Class: Fluent::Plugin::Prometheus::Summary
- Defined in:
- lib/fluent/plugin/prometheus.rb
Instance Attribute Summary
Attributes inherited from Metric
#desc, #key, #name, #retention, #retention_check_interval, #type
Instance Method Summary collapse
-
#initialize(element, registry, labels) ⇒ Summary
constructor
A new instance of Summary.
- #set_value(value, labels) ⇒ Object
- #value(record) ⇒ Object
Methods inherited from Metric
get, #has_retention?, #instrument, #labels, #remove_expired_metrics, #set_value?
Constructor Details
#initialize(element, registry, labels) ⇒ Summary
Returns a new instance of Summary.
357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/fluent/plugin/prometheus.rb', line 357 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, docstring: element['desc'], labels: @base_labels.keys) rescue ::Prometheus::Client::Registry::AlreadyRegisteredError @summary = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :summary, element['desc']) end end |
Instance Method Details
#set_value(value, labels) ⇒ Object
378 379 380 |
# File 'lib/fluent/plugin/prometheus.rb', line 378 def set_value(value, labels) @summary.observe(value, labels: labels) end |
#value(record) ⇒ Object
370 371 372 373 374 375 376 |
# File 'lib/fluent/plugin/prometheus.rb', line 370 def value(record) if @key.is_a?(String) record[@key] else @key.call(record) end end |