class Fluent::Plugin::Prometheus::ExpandBuilder::PlaceholderExpander
Constants
- PLACEHOLDER_REGEX
Attributes
Public Class Methods
Source
# File lib/fluent/plugin/prometheus/placeholder_expander.rb, line 91 def initialize(log, placeholder) @placeholder = placeholder @log = log @expander_cache = {} end
Public Instance Methods
Source
# File lib/fluent/plugin/prometheus/placeholder_expander.rb, line 101 def expand(str, dynamic_placeholders: nil) expander = if dynamic_placeholders if @expander_cache[dynamic_placeholders] @expander_cache[dynamic_placeholders] else e = ExpandBuilder.build(dynamic_placeholders, log: @log) e.merge_placeholder(@placeholder) @expander_cache[dynamic_placeholders] = e e end else self end expander.expand!(str) end
Source
# File lib/fluent/plugin/prometheus/placeholder_expander.rb, line 97 def merge_placeholder(placeholder) @placeholder.merge!(placeholder) end
Protected Instance Methods
Source
# File lib/fluent/plugin/prometheus/placeholder_expander.rb, line 120 def expand!(str) str.gsub(PLACEHOLDER_REGEX) { |value| @placeholder.fetch(value) do @log.warn("unknown placeholder `#{value}` found") value # return as it is end } end