Sha256: f614a0d08bf563c2f674474ca49682ef5ed81c056e7c5f1920769d406a7b3339
Contents?: true
Size: 851 Bytes
Versions: 1
Compression:
Stored size: 851 Bytes
Contents
require 'open-uri' require 'benchmark' module Remon module Metrics class Http def initialize(url) @uri = URI.parse(url) end def status(read_timeout: 1, open_timeout: 1) status = nil time = Benchmark.realtime do status = get_status(read_timeout, open_timeout) end return time, status end private def get_status(read_timeout, open_timeout) @uri.open(read_timeout: read_timeout, open_timeout: open_timeout, redirect: false) do |f| f.status[0].to_i end rescue EOFError return 444 rescue Errno::ECONNREFUSED return 502 rescue Net::OpenTimeout return 504 rescue Net::ReadTimeout return 504 rescue OpenURI::HTTPRedirect => e return 301 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
remon-0.1.0 | lib/remon/metrics/http.rb |