Class: Healthchecker::MetricsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Healthchecker::MetricsController
show all
- Defined in:
- app/controllers/healthchecker/metrics_controller.rb
Defined Under Namespace
Modules: ConfigurableMetrics
Instance Method Summary
collapse
Instance Method Details
#current_status ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/healthchecker/metrics_controller.rb', line 8
def current_status
Healthchecker.configuration.metrics.reduce(uptime) { |status, metric|
if ConfigurableMetrics.method_defined? metric
status = status.merge(ConfigurableMetrics.send metric)
else
supported_metrics = ConfigurableMetrics.public_instance_methods
message = "#{metric} is not a supported metric. Supported metrics are #{supported_metrics}"
raise Healthchecker::ConfigurationError, message
end
status
}
end
|
#show ⇒ Object
4
5
6
|
# File 'app/controllers/healthchecker/metrics_controller.rb', line 4
def show
render json: current_status
end
|
#uptime ⇒ Object
21
22
23
24
25
|
# File 'app/controllers/healthchecker/metrics_controller.rb', line 21
def uptime
{
uptime: Time.now - Healthchecker::APPLICATION_STARTED_AT
}
end
|