8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/resque/metrics/server.rb', line 8
def self.included(base)
base.class_eval do
helpers do
def local_template(path)
File.read(File.join(File.dirname(__FILE__), "server/views/#{path}"))
end
def metrics_formatted_ms(milliseconds)
seconds = milliseconds / 1000
hours = (seconds / 3600).floor
minutes = (seconds % 3600) / 60
seconds = seconds % 60
millis = (milliseconds - (milliseconds / 1000) * 1000)
str = []
str << "#{hours} hours" if hours > 0
str << "#{minutes} min" if minutes > 0
str << "#{seconds} sec" if seconds > 0
str << "#{millis} ms" if millis > 0
str.join(" ")
end
end
get "/metrics" do
erb local_template("metrics.erb")
end
end
end
|