Module: Vitals::Utils
- Defined in:
- lib/vitals/utils.rb
Constant Summary collapse
- BAD_METRICS_CHARS =
Regexp.compile('[\/\-:\s]').freeze
- SEPARATOR =
'.'.freeze
Class Method Summary collapse
-
.grape_path(route) ⇒ Object
XXX grape specific, move this away some day?.
- .hostname ⇒ Object
- .normalize_metric(m) ⇒ Object
- .sec_to_ms(sec) ⇒ Object
Class Method Details
.grape_path(route) ⇒ Object
XXX grape specific, move this away some day?
15 16 17 18 19 20 21 22 |
# File 'lib/vitals/utils.rb', line 15 def self.grape_path(route) version = route.route_version path = route.route_path.dup[1..-1] path.sub!(/\(\..*\)$/, '') path.sub!(":version", version) if version path.gsub!(/\//, ".") path end |
.hostname ⇒ Object
8 9 10 |
# File 'lib/vitals/utils.rb', line 8 def self.hostname `hostname -s`.chomp end |
.normalize_metric(m) ⇒ Object
5 6 7 |
# File 'lib/vitals/utils.rb', line 5 def self.normalize_metric(m) m.gsub(BAD_METRICS_CHARS, '_') end |
.sec_to_ms(sec) ⇒ Object
11 12 13 |
# File 'lib/vitals/utils.rb', line 11 def self.sec_to_ms(sec) (1000.0 * sec).round end |