Class: RoutesAlerts::Metrics
- Inherits:
-
Object
- Object
- RoutesAlerts::Metrics
- Defined in:
- lib/routes_alerts/metrics.rb
Constant Summary collapse
- COUNT_METRIC_NAME =
"Count"- DURATION_METRIC_NAME =
"Duration"- SUCCESS_METRIC_NAME =
"SuccessRate"- DEFAULT_METRICS =
[ COUNT_METRIC_NAME, DURATION_METRIC_NAME, SUCCESS_METRIC_NAME ]
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #create_metrics!(route_info) ⇒ Object
-
#initialize(config) ⇒ Metrics
constructor
A new instance of Metrics.
Constructor Details
#initialize(config) ⇒ Metrics
Returns a new instance of Metrics.
19 20 21 |
# File 'lib/routes_alerts/metrics.rb', line 19 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
17 18 19 |
# File 'lib/routes_alerts/metrics.rb', line 17 def config @config end |
Instance Method Details
#create_metrics!(route_info) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/routes_alerts/metrics.rb', line 23 def create_metrics!(route_info) route_info.metrics.each do |metric| case metric when COUNT_METRIC_NAME RoutesAlerts::Count.new(config, route_info).create! when DURATION_METRIC_NAME RoutesAlerts::Duration.new(config, route_info).create! when SUCCESS_METRIC_NAME RoutesAlerts::SuccessRate.new(config, route_info).create! else raise "Unknown metric type: #{metric}" end end end |