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) ⇒ Object
Methods inherited from Metric
Constructor Details
#initialize(element, registry, labels) ⇒ Summary
Returns a new instance of Summary.
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/fluent/plugin/prometheus.rb', line 340 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 if @initialized Fluent::Plugin::Prometheus::Metric.init_label_set(@summary, @base_initlabels, @base_labels) end end |
Instance Method Details
#instrument(record, expander) ⇒ Object
357 358 359 360 361 362 363 364 365 366 |
# File 'lib/fluent/plugin/prometheus.rb', line 357 def instrument(record, ) if @key.is_a?(String) value = record[@key] else value = @key.call(record) end if value @summary.observe(value, labels: labels(record, )) end end |