Class: Fluent::Plugin::Prometheus::Summary
- Inherits:
-
Metric
- Object
- Metric
- Fluent::Plugin::Prometheus::Summary
show all
- Defined in:
- lib/fluent/plugin/prometheus.rb
Instance Attribute Summary
Attributes inherited from Metric
#desc, #key, #name, #type
Instance Method Summary
collapse
Methods inherited from Metric
get, #labels
Constructor Details
#initialize(element, registry, labels) ⇒ Summary
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/fluent/plugin/prometheus.rb', line 237
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) ⇒ Object
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/fluent/plugin/prometheus.rb', line 250
def instrument(record, expander)
if @key.is_a?(String)
value = record[@key]
else
value = @key.call(record)
end
if value
@summary.observe(labels(record, expander), value)
end
end
|