Method: Wavefront::Validators#wf_metric_name?

Defined in:
lib/wavefront-sdk/validators.rb

#wf_metric_name?(metric) ⇒ Boolean

Ensure the given argument is a valid Wavefront metric name, or path.

is not valid.

Parameters:

  • metric (String)

    the metric name to validate

Returns:

  • (Boolean)

    True if the metric name is valid

Raises:

  • Wavefront::Exception::InvalidMetricName if metric name



49
50
51
52
53
54
55
56
57
# File 'lib/wavefront-sdk/validators.rb', line 49

def wf_metric_name?(metric)
  if metric.is_a?(String) && metric.size < 1024 &&
     (metric.match(/^#{DELTA}?[\w\-.]+$/o) ||
      metric.match(%r{^"#{DELTA}?[\w\-./,]+"$}o))
    return true
  end

  raise Wavefront::Exception::InvalidMetricName, metric
end