routes_alerts 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecbf799815921708dcf6c02fa0b3be3a875137d3aa5a29cc749f67d3bfc74d59
4
- data.tar.gz: f3ade9fcd19d6514d909c97701cab988540511b0d926759f147bb54299c40378
3
+ metadata.gz: 507916212fa50b3f50d12971679eb82284846784e43ff9d42f45a424ed540872
4
+ data.tar.gz: 3c8dd268b44a2e2edcdd66dbe6a8cfcd3d9882e40e0613a8901a1c8036b2851b
5
5
  SHA512:
6
- metadata.gz: 225620e5aedda1351b54cc988bcf3a0f346bf99335597c79c9dd25fb48ad136a27c5eae313f5a657a9d01963a82c7a9d77230048cfc1a707c236cbf0c5ff6870
7
- data.tar.gz: a65bb10dbe40449b672ce32a491045c19f099d6c369763db001b802a73d2afe3fbca9a0feb92bd40336087bd45b751b8793f2981c0e56dd08edf9945ab99880f
6
+ metadata.gz: 716989e6b4be6e7b78ed39ccf87308e516f49b310e9e52cb6b17dde1f53112eb941ce4da130d862c4de093fb078bd2f06bda6379d361dc677b955cba20fbfd97
7
+ data.tar.gz: 6d112924ece3d3c1c71470fd536641631b7565c78be35090b2ce6f926dd763d815df995b2ee1e548f645cd9aec4ae848ffdb5d1d83babb421658f1f5933140a4
@@ -20,7 +20,8 @@ module RoutesAlerts
20
20
  :default_log_group_name,
21
21
  :default_namespace,
22
22
  :cloudwatch_logs,
23
- :default_actions
23
+ :default_actions,
24
+ :prefix
24
25
 
25
26
  def initialize
26
27
  @cloudwatch_logs = Aws::CloudWatchLogs::Client.new(region: "us-west-2")
@@ -32,6 +33,7 @@ module RoutesAlerts
32
33
  @default_metrics = RoutesAlerts::Metrics::DEFAULT_METRICS
33
34
  @routes = []
34
35
  @default_actions = []
36
+ @prefix = ""
35
37
  end
36
38
 
37
39
  def add_route(path:, method:, max_duration: nil, min_count: nil, success_rate: nil, alarm_period: nil, number_of_datapoints: nil, metrics: nil, namespace: nil, log_group_name: nil, actions: nil)
@@ -46,7 +48,8 @@ module RoutesAlerts
46
48
  log_group_name: (log_group_name || default_log_group_name),
47
49
  namespace: (namespace || default_namespace),
48
50
  actions: (actions || default_actions),
49
- metrics: (metrics || default_metrics)
51
+ metrics: (metrics || default_metrics),
52
+ prefix: prefix
50
53
  )
51
54
  self.routes << route_info
52
55
  end
@@ -34,4 +34,12 @@ class RoutesAlerts::Base
34
34
  def actions
35
35
  route_info.actions.any? ? route_info.actions : nil
36
36
  end
37
+
38
+ def prefix
39
+ if route_info.prefix.empty?
40
+ ""
41
+ else
42
+ "#{route_info.prefix}-"
43
+ end
44
+ end
37
45
  end
@@ -24,7 +24,7 @@ class RoutesAlerts::Count < RoutesAlerts::Base
24
24
 
25
25
  def alarm_params
26
26
  {
27
- alarm_name: "Alarm-#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
27
+ alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::COUNT_METRIC_NAME}-#{route_name}",
28
28
  actions_enabled: !!actions&.any?,
29
29
  ok_actions: actions,
30
30
  alarm_actions: actions,
@@ -24,7 +24,7 @@ class RoutesAlerts::Duration < RoutesAlerts::Base
24
24
 
25
25
  def alarm_params
26
26
  {
27
- alarm_name: "Alarm-#{RoutesAlerts::Metrics::DURATION_METRIC_NAME}-#{route_name}",
27
+ alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::DURATION_METRIC_NAME}-#{route_name}",
28
28
  actions_enabled: !!actions&.any?,
29
29
  ok_actions: actions,
30
30
  alarm_actions: actions,
@@ -24,7 +24,7 @@ class RoutesAlerts::SuccessRate < RoutesAlerts::Base
24
24
 
25
25
  def alarm_params
26
26
  {
27
- alarm_name: "Alarm-#{RoutesAlerts::Metrics::SUCCESS_METRIC_NAME}-#{route_name}",
27
+ alarm_name: "#{prefix}Alarm-#{RoutesAlerts::Metrics::SUCCESS_METRIC_NAME}-#{route_name}",
28
28
  actions_enabled: !!actions&.any?,
29
29
  ok_actions: actions,
30
30
  alarm_actions: actions,
@@ -2,9 +2,9 @@
2
2
  class RoutesAlerts::RouteInfo
3
3
  attr_reader :path, :method, :max_duration, :min_count, :success_rate,
4
4
  :alarm_period, :number_of_datapoints, :metrics, :namespace,
5
- :log_group_name, :actions
5
+ :log_group_name, :actions, :prefix
6
6
 
7
- def initialize(path:, method:, max_duration:, min_count:, success_rate:, alarm_period:, number_of_datapoints:, metrics:, namespace:, log_group_name:, actions:)
7
+ def initialize(path:, method:, max_duration:, min_count:, success_rate:, alarm_period:, number_of_datapoints:, metrics:, namespace:, log_group_name:, actions:, prefix: "")
8
8
  @path = path.to_s
9
9
  @method = method.to_s.upcase
10
10
  @max_duration = max_duration.to_f
@@ -16,5 +16,6 @@ class RoutesAlerts::RouteInfo
16
16
  @namespace = namespace.to_s
17
17
  @log_group_name = log_group_name.to_s
18
18
  @actions = actions || []
19
+ @prefix = prefix.to_s
19
20
  end
20
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routes_alerts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''