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.
251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/fluent/plugin/prometheus.rb', line 251 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
#instrument(record, expander) ⇒ Object
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/fluent/plugin/prometheus.rb', line 264 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 |