Module: Fluent::LibratoMetricsOutput::MetricsMixin
- Includes:
- Configurable
- Included in:
- Fluent::LibratoMetricsOutput
- Defined in:
- lib/fluent/plugin/out_librato_metrics_mixin.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #each_metrics(tag, time, record, &block) ⇒ Object
- #initialize ⇒ Object
- #new_metrics(conf, pattern) ⇒ Object
Instance Attribute Details
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
29 30 31 |
# File 'lib/fluent/plugin/out_librato_metrics_mixin.rb', line 29 def metrics @metrics end |
Instance Method Details
#configure(conf) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/out_librato_metrics_mixin.rb', line 36 def configure(conf) super defaults = { 'value_key' => @default_value_key, 'count_key' => @default_count_key, 'type' => @default_type, } conf.elements.select {|e| e.name == 'metrics' }.each {|e| defaults.each_pair {|k,v| e[k] = v if v != nil } @metrics << new_metrics(e, e.arg) } if mk = @match_key @match_key_proc = Proc.new {|tag,record| record[mk] } else @match_key_proc = Proc.new {|tag,record| tag } end end |
#each_metrics(tag, time, record, &block) ⇒ Object
208 209 210 211 212 213 214 215 216 |
# File 'lib/fluent/plugin/out_librato_metrics_mixin.rb', line 208 def each_metrics(tag, time, record, &block) mk = @match_key_proc.call(tag, record) return [] unless mk @metrics.map {|m| data = m.evaluate(mk, time, record) next unless data block.call(data) } end |
#initialize ⇒ Object
24 25 26 27 |
# File 'lib/fluent/plugin/out_librato_metrics_mixin.rb', line 24 def initialize super @metrics = [] end |