Sha256: 59cb316532fef6d9cd291c3246921f8fc03b6a320c7b5bfe2cb067ddc3c0e141

Contents?: true

Size: 753 Bytes

Versions: 4

Compression:

Stored size: 753 Bytes

Contents

module Vitals
  module Utils
    BAD_METRICS_CHARS = Regexp.compile('[\/\-:\s]').freeze
    SEPARATOR = '.'.freeze
    def self.normalize_metric(m)
      m.gsub(BAD_METRICS_CHARS, '_')
    end
    def self.hostname
      `hostname -s`.chomp
    end
    def self.sec_to_ms(sec)
      (1000.0 * sec).round
    end
    # XXX grape specific, move this away some day?
    def self.grape_path(route)
      version = route.route_version
      path = route.route_path.dup[1..-1]          # /foo/bar/baz -> foo/bar/baz
      path.sub!(/\(\..*\)$/, '')                  # (.json) -> ''
      path.sub!(":version", version) if version   # :version -> v1
      path.gsub!(/\//, ".")     # foo/bar -> foo.bar
      path.gsub!(/\//, ".")
      path
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vitals-0.8.0 lib/vitals/utils.rb
vitals-0.7.0 lib/vitals/utils.rb
vitals-0.6.0 lib/vitals/utils.rb
vitals-0.5.0 lib/vitals/utils.rb