module Vitals::Utils
Constants
- BAD_METRICS_CHARS
- SEPARATOR
Public Class Methods
grape_path(route)
click to toggle source
XXX grape specific, move this away some day?
# File lib/vitals/utils.rb, line 15 def self.grape_path(route) if route.respond_to?(:version) && route.respond_to?(:path) version = route.version path = route.path else # deprecated methods version = route.route_version path = route.route_path end path = path.dup[1..-1] # /foo/bar/baz -> foo/bar/baz path.sub!(/\(\..*\)$/, '') # (.json) -> '' path.sub!(":version", version) if version # :version -> v1 path.gsub!(/\//, self.path_sep) # foo/bar -> foo.bar path end
hostname()
click to toggle source
# File lib/vitals/utils.rb, line 8 def self.hostname `hostname -s`.chomp end
normalize_metric(m)
click to toggle source
# File lib/vitals/utils.rb, line 5 def self.normalize_metric(m) m.gsub(BAD_METRICS_CHARS, '_') end
path_sep()
click to toggle source
# File lib/vitals/utils.rb, line 32 def self.path_sep @path_sep end
path_sep=(val)
click to toggle source
# File lib/vitals/utils.rb, line 36 def self.path_sep=(val) @path_sep = val end
sec_to_ms(sec)
click to toggle source
# File lib/vitals/utils.rb, line 11 def self.sec_to_ms(sec) (1000.0 * sec).round end