Skip to content

Commit

Permalink
plugin_helper: metrics: Add actual plugin name prefix for unspecified
Browse files Browse the repository at this point in the history
`@id` plugins

Signed-off-by: Hiroshi Hatake <hatake@calyptia.com>
  • Loading branch information
cosmo0920 committed Jul 8, 2021
1 parent 23a0183 commit 66b6501
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/fluent/plugin_helper/metrics.rb
Expand Up @@ -35,6 +35,12 @@ def initialize

def configure(conf)
super

@plugin_type_or_id = if self.plugin_id_configured?
self.plugin_id
else
"#{conf["@type"] || conf["type"]}.#{self.plugin_id}"
end
end

def metrics_create(namespace: "Fluentd", subsystem: "metrics", name:, help_text:, labels: {}, prefer_gauge: false)
Expand All @@ -54,9 +60,10 @@ def metrics_create(namespace: "Fluentd", subsystem: "metrics", name:, help_text:
if Fluent::Engine.system_config.workers > 1
labels.merge!(worker_id: fluentd_worker_id.to_s)
end
labels.merge!(plugin: @plugin_type_or_id)
metrics.create(namespace: namespace, subsystem: subsystem, name: name, help_text: help_text, labels: labels)

@_metrics["#{self.plugin_id}_#{namespace}_#{subsystem}_#{name}"] = metrics
@_metrics["#{@plugin_type_or_id}_#{namespace}_#{subsystem}_#{name}"] = metrics

metrics
end
Expand Down

0 comments on commit 66b6501

Please sign in to comment.