lib/heroku/scalr/metric.rb in heroku-scalr-0.2.2 vs lib/heroku/scalr/metric.rb in heroku-scalr-0.2.3
- old
+ new
@@ -24,10 +24,18 @@
0
end
protected
+ def http_get
+ Excon.head(@app.url)
+ rescue Excon::Errors::Timeout
+ Excon::Response.new(status: 598)
+ rescue Excon::Errors::Error
+ Excon::Response.new(status: 444)
+ end
+
def compare(ms, low, high)
ms <= low ? -1 : (ms >= high ? 1 : 0)
end
def log(*args)
@@ -41,11 +49,11 @@
# @see Heroku::Scalr::Metric::Abstract#by
def by
status = nil
real = Benchmark.realtime do
- status = @app.http.get.status
+ status = http_get.status
end
unless status == 200
log :warn, "unable to ping, server responded with #{status}"
return 0
@@ -61,10 +69,10 @@
class Wait < Abstract
# @see Heroku::Scalr::Metric::Abstract#by
def by
- ms = @app.http.get.headers["X-Heroku-Queue-Wait"]
+ ms = http_get.headers["X-Heroku-Queue-Wait"]
unless ms
log :warn, "unable to determine queue wait time"
return 0
end