rails-informant 0.3.2 → 0.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3d333268d4996b1ccee39e08ad675d133b067be5b89b57dff6c553951fed09f
|
|
4
|
+
data.tar.gz: c6b1be1a6c014ce1c5a58ab90138a16e9a93cefdeb741b59d77dccd8a2387ec6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74f455bafd7f95401387211d742e2ddff3c56ed7bef1483a12835c3b7573cbbd69a8985d0792e4d8f7f45dfde7eb65012e49ad62c22d15cf9a590fe0e96908e1
|
|
7
|
+
data.tar.gz: 4b303b1ebc02fa906ba8cec9e78121784394cdc246b9963b69c3604824d78d75d4a6d27044cab95d148583c7cd95d9d0fcd675c5304115a01aa4b32a71435c11
|
|
@@ -47,6 +47,7 @@ module RailsInformant
|
|
|
47
47
|
keep_ids = group.occurrences.order(created_at: :desc).limit(MAX_OCCURRENCES_PER_GROUP).select(:id)
|
|
48
48
|
Occurrence.where(error_group_id: group.id).where.not(id: keep_ids).delete_all
|
|
49
49
|
end
|
|
50
|
+
|
|
50
51
|
def notify(group)
|
|
51
52
|
return if Notifiers::CircuitBreaker.open?
|
|
52
53
|
return unless RailsInformant.config.notifiers.any? { it.should_notify?(group) }
|
data/lib/rails_informant/mcp.rb
CHANGED
|
@@ -3,26 +3,36 @@ module RailsInformant
|
|
|
3
3
|
class CircuitBreaker
|
|
4
4
|
FAILURE_THRESHOLD = 5
|
|
5
5
|
RESET_TIMEOUT = 10.minutes
|
|
6
|
+
MUTEX = Mutex.new
|
|
7
|
+
private_constant :MUTEX
|
|
6
8
|
|
|
7
9
|
class << self
|
|
8
10
|
def open?
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
MUTEX.synchronize do
|
|
12
|
+
return false if failure_count < FAILURE_THRESHOLD
|
|
13
|
+
last_failure_at > RESET_TIMEOUT.ago
|
|
14
|
+
end
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def record_failure
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
MUTEX.synchronize do
|
|
19
|
+
@failure_count = failure_count + 1
|
|
20
|
+
@last_failure_at = Time.current
|
|
21
|
+
end
|
|
17
22
|
end
|
|
18
23
|
|
|
19
24
|
def record_success
|
|
20
|
-
|
|
25
|
+
MUTEX.synchronize do
|
|
26
|
+
@failure_count = 0
|
|
27
|
+
@last_failure_at = nil
|
|
28
|
+
end
|
|
21
29
|
end
|
|
22
30
|
|
|
23
31
|
def reset!
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
MUTEX.synchronize do
|
|
33
|
+
@failure_count = 0
|
|
34
|
+
@last_failure_at = nil
|
|
35
|
+
end
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
private
|
|
@@ -18,7 +18,7 @@ module RailsInformant
|
|
|
18
18
|
|
|
19
19
|
def build_payload(error_group, occurrence)
|
|
20
20
|
{
|
|
21
|
-
text: "#{error_group.error_class}: #{error_group.message
|
|
21
|
+
text: "#{error_group.error_class}: #{error_group.message&.truncate(200)}",
|
|
22
22
|
blocks: [
|
|
23
23
|
header_block(error_group, occurrence),
|
|
24
24
|
error_class_block(error_group),
|
|
@@ -44,7 +44,7 @@ module RailsInformant
|
|
|
44
44
|
type: "section",
|
|
45
45
|
text: {
|
|
46
46
|
type: "mrkdwn",
|
|
47
|
-
text: "*#{error_group.error_class}*\n#{error_group.message
|
|
47
|
+
text: "*#{error_group.error_class}*\n#{error_group.message&.truncate(200)}"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
end
|