class Watchman::MetricName

Public Class Methods

construct(base_name, prefix, tags) click to toggle source
# File lib/watchman/metric_name.rb, line 3
def self.construct(base_name, prefix, tags)
  new(base_name, prefix, tags).construct
end
new(base_name, prefix = nil, tags) click to toggle source
# File lib/watchman/metric_name.rb, line 7
def initialize(base_name, prefix = nil, tags)
  @base_name = base_name
  @prefix = prefix
  @tags = tags || []
end

Public Instance Methods

construct() click to toggle source
# File lib/watchman/metric_name.rb, line 13
def construct
  full_name = []

  full_name << "tagged"      if tagged?
  full_name << @prefix       if @prefix
  full_name << formated_tags if tagged?
  full_name << @base_name

  full_name.join(".")
end
formated_tags() click to toggle source
# File lib/watchman/metric_name.rb, line 24
def formated_tags
  @tags
    .map(&:to_s)
    .fill("no_tag", @tags.length, [3 - @tags.length, 0].max)
    .first(3)
    .join(".")
end
tagged?() click to toggle source
# File lib/watchman/metric_name.rb, line 32
def tagged?
  @tags.size > 0
end