apisonator 3.3.2 → 3.3.3
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/Gemfile.on_prem.lock +1 -1
- data/lib/3scale/backend/alerts.rb +24 -22
- data/lib/3scale/backend/stats/aggregator.rb +6 -0
- data/lib/3scale/backend/version.rb +1 -1
- data/licenses.xml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a63aa45d4fa6c23fde95de0b422f771fc9fc104fa9dfebbcdc2c9c0d09219a1
|
|
4
|
+
data.tar.gz: 54809f95ad95b7cd4ab835a7ba3238fcd5d3bef1c9243bbabf1eb4fea95a7e97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6810598c592d306959e53c89fa602f1f866613f6b6e9001126785f26d688ca71d909a97caafcff1f56ea368d375f146874ff6fd978260c9a8ecd364725afa95
|
|
7
|
+
data.tar.gz: 011c656c600e048725a869a949316171d583fd0cdac4f7bec84ea7231753571cb6d2b5409a9e41f8600d94c5fbb773a187ffe6a3aa5942e7c6a53c7e8b2e05b7
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to Apisonator will be tracked in this document.
|
|
4
4
|
|
|
5
|
+
## 3.3.3 - 2021-03-09
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Check if alerts can be raised before calculating utilization (perf
|
|
10
|
+
optimization) ([#275](https://github.com/3scale/apisonator/pull/275)).
|
|
11
|
+
|
|
12
|
+
### Removed
|
|
13
|
+
|
|
14
|
+
- Stop maintaining unused "current_max" key in Alerts
|
|
15
|
+
([#272](https://github.com/3scale/apisonator/pull/272)).
|
|
16
|
+
|
|
5
17
|
## 3.3.2 - 2021-02-23
|
|
6
18
|
|
|
7
19
|
### Fixed
|
data/Gemfile.lock
CHANGED
data/Gemfile.on_prem.lock
CHANGED
|
@@ -6,11 +6,10 @@ module ThreeScale
|
|
|
6
6
|
|
|
7
7
|
# The compacted hour in the params refers to the
|
|
8
8
|
# TimeHacks.to_compact_s method.
|
|
9
|
-
def alert_keys(service_id, app_id, discrete_utilization
|
|
9
|
+
def alert_keys(service_id, app_id, discrete_utilization)
|
|
10
10
|
{
|
|
11
11
|
already_notified: key_already_notified(service_id, app_id, discrete_utilization),
|
|
12
12
|
allowed: key_allowed_set(service_id),
|
|
13
|
-
current_max: key_current_max(service_id, app_id, compacted_hour_start),
|
|
14
13
|
current_id: key_current_id
|
|
15
14
|
}
|
|
16
15
|
end
|
|
@@ -31,11 +30,6 @@ module ThreeScale
|
|
|
31
30
|
"#{prefix}allowed_set"
|
|
32
31
|
end
|
|
33
32
|
|
|
34
|
-
def key_current_max(service_id, app_id, compacted_hour_start)
|
|
35
|
-
prefix = key_prefix(service_id, app_id)
|
|
36
|
-
"#{prefix}#{compacted_hour_start}/current_max"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
33
|
def key_current_id
|
|
40
34
|
'alerts/current_id'.freeze
|
|
41
35
|
end
|
|
@@ -43,6 +37,7 @@ module ThreeScale
|
|
|
43
37
|
|
|
44
38
|
extend self
|
|
45
39
|
extend KeyHelpers
|
|
40
|
+
include Memoizer::Decorator
|
|
46
41
|
|
|
47
42
|
ALERT_TTL = 24*3600 # 1 day (only one message per day)
|
|
48
43
|
## zero must be here and sorted, yes or yes
|
|
@@ -50,6 +45,16 @@ module ThreeScale
|
|
|
50
45
|
FIRST_ALERT_BIN = ALERT_BINS.first
|
|
51
46
|
RALERT_BINS = ALERT_BINS.reverse.freeze
|
|
52
47
|
|
|
48
|
+
def can_raise_more_alerts?(service_id, app_id)
|
|
49
|
+
allowed_bins = allowed_set_for_service(service_id).sort
|
|
50
|
+
|
|
51
|
+
return false if allowed_bins.empty?
|
|
52
|
+
|
|
53
|
+
# If the bin with the highest value has already been notified, there's
|
|
54
|
+
# no need to notify anything else.
|
|
55
|
+
not notified?(service_id, app_id, allowed_bins.last)
|
|
56
|
+
end
|
|
57
|
+
|
|
53
58
|
def utilization(app_usage_reports)
|
|
54
59
|
max_utilization = -1.0
|
|
55
60
|
max_record = nil
|
|
@@ -77,25 +82,12 @@ module ThreeScale
|
|
|
77
82
|
|
|
78
83
|
def update_utilization(service_id, app_id, max_utilization, max_record, timestamp)
|
|
79
84
|
discrete = utilization_discrete(max_utilization)
|
|
80
|
-
max_utilization_i = (max_utilization * 100.0).round
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
period_hour = Period::Boundary.hour_start(timestamp).to_compact_s
|
|
84
|
-
# UNIX timestamp for key expiration - add 1 day + 5 mins
|
|
85
|
-
expire_at = (beginning_of_day + 86700).to_i
|
|
86
|
+
keys = alert_keys(service_id, app_id, discrete)
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
already_alerted, allowed, current_max, _ = storage.pipelined do
|
|
88
|
+
already_alerted, allowed = storage.pipelined do
|
|
90
89
|
storage.get(keys[:already_notified])
|
|
91
90
|
storage.sismember(keys[:allowed], discrete)
|
|
92
|
-
storage.get(keys[:current_max])
|
|
93
|
-
storage.expireat(keys[:current_max], expire_at)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
## update the status of utilization
|
|
97
|
-
if max_utilization_i > current_max.to_i
|
|
98
|
-
storage.set(keys[:current_max], max_utilization_i)
|
|
99
91
|
end
|
|
100
92
|
|
|
101
93
|
if already_alerted.nil? && allowed && discrete.to_i > 0
|
|
@@ -129,6 +121,16 @@ module ThreeScale
|
|
|
129
121
|
"#{record.current_value}/#{record.max_value}"
|
|
130
122
|
end
|
|
131
123
|
|
|
124
|
+
def allowed_set_for_service(service_id)
|
|
125
|
+
storage.smembers(key_allowed_set(service_id)).map(&:to_i) # Redis returns strings always
|
|
126
|
+
end
|
|
127
|
+
memoize :allowed_set_for_service
|
|
128
|
+
|
|
129
|
+
def notified?(service_id, app_id, bin)
|
|
130
|
+
storage.get(key_already_notified(service_id, app_id, bin))
|
|
131
|
+
end
|
|
132
|
+
memoize :notified?
|
|
133
|
+
|
|
132
134
|
def storage
|
|
133
135
|
Storage.instance
|
|
134
136
|
end
|
|
@@ -149,6 +149,12 @@ module ThreeScale
|
|
|
149
149
|
# enqueued. No need to update alerts in that case.
|
|
150
150
|
next unless application
|
|
151
151
|
|
|
152
|
+
# The operations below are costly. They load all the usage limits
|
|
153
|
+
# and current usages to find the current utilization levels.
|
|
154
|
+
# That's why before that, we check if there are any alerts that
|
|
155
|
+
# can be raised.
|
|
156
|
+
next unless Alerts.can_raise_more_alerts?(service_id, values[:application_id])
|
|
157
|
+
|
|
152
158
|
application.load_metric_names
|
|
153
159
|
usage = Usage.application_usage(application, current_timestamp)
|
|
154
160
|
status = Transactor::Status.new(service_id: service_id,
|
data/licenses.xml
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apisonator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.3.
|
|
4
|
+
version: 3.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Ciganek
|
|
@@ -16,7 +16,7 @@ authors:
|
|
|
16
16
|
autorequire:
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
|
-
date: 2021-
|
|
19
|
+
date: 2021-03-09 00:00:00.000000000 Z
|
|
20
20
|
dependencies: []
|
|
21
21
|
description: This gem provides a daemon that handles authorization and reporting of
|
|
22
22
|
web services managed by 3scale.
|