Class: Fluent::Plugin::Prometheus::ExpandBuilder::PlaceholderExpander
- Inherits:
-
Object
- Object
- Fluent::Plugin::Prometheus::ExpandBuilder::PlaceholderExpander
- Defined in:
- lib/fluent/plugin/prometheus/placeholder_expander.rb
Constant Summary collapse
- PLACEHOLDER_REGEX =
/(\${[^\[}]+(\[[^\]]+\])?})/.freeze
Instance Attribute Summary collapse
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
Instance Method Summary collapse
- #expand(str, dynamic_placeholders: nil) ⇒ Object
-
#initialize(log, placeholder) ⇒ PlaceholderExpander
constructor
A new instance of PlaceholderExpander.
- #merge_placeholder(placeholder) ⇒ Object
Constructor Details
#initialize(log, placeholder) ⇒ PlaceholderExpander
Returns a new instance of PlaceholderExpander.
91 92 93 94 95 |
# File 'lib/fluent/plugin/prometheus/placeholder_expander.rb', line 91 def initialize(log, placeholder) @placeholder = placeholder @log = log @expander_cache = {} end |
Instance Attribute Details
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
89 90 91 |
# File 'lib/fluent/plugin/prometheus/placeholder_expander.rb', line 89 def placeholder @placeholder end |
Instance Method Details
#expand(str, dynamic_placeholders: nil) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/fluent/plugin/prometheus/placeholder_expander.rb', line 101 def (str, dynamic_placeholders: nil) = 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 .(str) end |
#merge_placeholder(placeholder) ⇒ Object
97 98 99 |
# File 'lib/fluent/plugin/prometheus/placeholder_expander.rb', line 97 def merge_placeholder(placeholder) @placeholder.merge!(placeholder) end |