Class: Simple::Metrics::Check
- Inherits:
-
Java::ComYammerMetricsCore::HealthCheck
- Object
- Java::ComYammerMetricsCore::HealthCheck
- Simple::Metrics::Check
- Defined in:
- lib/simple/metrics/healthcheck.rb
Instance Method Summary (collapse)
-
- (Object) check
Call the block and capture the return value.
-
- (Check) initialize(name, &blk)
constructor
A new instance of Check.
Constructor Details
- (Check) initialize(name, &blk)
A new instance of Check
38 39 40 41 |
# File 'lib/simple/metrics/healthcheck.rb', line 38 def initialize(name, &blk) super(name) @blk = blk end |
Instance Method Details
- (Object) check
Call the block and capture the return value. If the result is `Simple::Metrics::HEALTHY`, mark the healthcheck as healthy. If the result is a `Simple::Metrics::WARNING`, mark the healthcheck in the warning state. If the result is a `Simple::Metrics::UNHEALTHY`, or throws an error, mark the healthcheck as unhealthy.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/simple/metrics/healthcheck.rb', line 48 def check begin r = @blk.call case (r.is_a?(Class) ? r.new : r) when Simple::Metrics::HEALTHY Java::ComYammerMetricsCore::HealthCheck::Result.healthy when Simple::Metrics::WARNING Java::ComYammerMetricsCore::HealthCheck::Result.warning when Simple::Metrics::UNHEALTHY Java::ComYammerMetricsCore::HealthCheck::Result.unhealthy(r.) end rescue StandardError => e Java::ComYammerMetricsCore::HealthCheck::Result.unhealthy(e.) end end |