Skip to content

Add shared metric type check for Collector#default_value_from #18

@rafamanzo

Description

@rafamanzo

From kolekti_analizo (https://github.com/mezuro/kolekti_analizo/blob/master/lib/kolekti_analizo/collector.rb#L25) we have:

metric = !metric_configuration.nil? ? metric_configuration.metric : nil
if metric.nil? || metric.type != 'NativeMetricSnapshot' || metric.metric_collector_name != self.name
  raise ArgumentError.new("Metric configuration does not belong to Analizo")
end

This logic will be repeated through other uses like MetricFu.

We can extract it into a new method, use it inside default_value_from and preserve the raise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions