Class: Meteorlog::DSL::Context::MetricFilter
- Inherits:
-
Object
- Object
- Meteorlog::DSL::Context::MetricFilter
- Includes:
- Validator, TemplateHelper
- Defined in:
- lib/meteorlog/dsl/context/metric_filter.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #filter_pattern(pattern) ⇒ Object
-
#initialize(name, log_group_name, &block) ⇒ MetricFilter
constructor
A new instance of MetricFilter.
- #metric(attrs) ⇒ Object
Methods included from TemplateHelper
Methods included from Validator
#_call_once, #_expected_length, #_expected_type, #_identify, #_required, #_validate
Constructor Details
#initialize(name, log_group_name, &block) ⇒ MetricFilter
Returns a new instance of MetricFilter.
7 8 9 10 11 12 13 14 |
# File 'lib/meteorlog/dsl/context/metric_filter.rb', line 7 def initialize(name, log_group_name, &block) @error_identifier = "LogGroup `#{log_group_name}` > MetricFilter `#{name}`" @result = OpenStruct.new( :filter_name => name, :metric_transformations => [], ) instance_eval(&block) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/meteorlog/dsl/context/metric_filter.rb', line 5 def result @result end |
Instance Method Details
#filter_pattern(pattern) ⇒ Object
16 17 18 19 20 |
# File 'lib/meteorlog/dsl/context/metric_filter.rb', line 16 def filter_pattern(pattern) _call_once(:filter_pattern) _required(:filter_pattern, pattern) @result.filter_pattern = pattern.to_s end |
#metric(attrs) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/meteorlog/dsl/context/metric_filter.rb', line 22 def metric(attrs) metric_attrs = {} _expected_type(attrs, Hash) { :name => :metric_name, :namespace => :metric_namespace, :value => :metric_value }.each do |attr_name, metric_name| _required("metric[#{attr_name}]", attrs[attr_name]) metric_attrs[metric_name] = attrs[attr_name].to_s end _expected_length(metric_attrs, 3) @result.metric_transformations << metric_attrs end |