nine_one_one 2.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nine_one_one.rb +4 -0
- data/lib/nine_one_one/log_service.rb +2 -0
- data/lib/nine_one_one/notifier.rb +4 -0
- data/lib/nine_one_one/pager_duty_service.rb +19 -19
- data/lib/nine_one_one/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7369af9b16de21e2f270ff4df0b611fcf2e0dc7
|
4
|
+
data.tar.gz: 31abafe8fd9f34161d5ea6a2f13af5ec0a667712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff1db99849019ae185dcf10c82651c41ffaab4cc029744485273a5c9b7645343c544f3dd8116ded309321c9c39d9b1be5f129612990511255f52474a5f51d9bc
|
7
|
+
data.tar.gz: '087a879cbfed16b73df5d6864addd4557149ac529af7187bacfe0ab19ca88e421dee51bb28885761a9efa35ca2a1099caa6341ae98d0889c0fb64f0bee70eb72'
|
data/lib/nine_one_one.rb
CHANGED
@@ -14,25 +14,33 @@ module NineOneOne
|
|
14
14
|
|
15
15
|
def trigger_event(description, source: Socket.gethostname, dedup_key: nil, severity: HIGH_URGENCY_ERROR,
|
16
16
|
details_hash: nil)
|
17
|
+
make_request(request_body('trigger', dedup_key, description, source, severity, details_hash))
|
18
|
+
end
|
19
|
+
|
20
|
+
def resolve_event(dedup_key)
|
21
|
+
make_request(request_body('resolve', dedup_key))
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :api_integration_key, :http
|
27
|
+
|
28
|
+
def make_request(request_body)
|
29
|
+
headers = {'Content-Type' => 'application/json'}
|
17
30
|
response = nil
|
18
31
|
|
19
32
|
retry_on(THROTTLE_HTTP_STATUS, THROTTLE_RETRIES) do
|
20
|
-
|
21
|
-
response = make_request(body)
|
33
|
+
response = http.post(EVENTS_API_V2_ENDPOINT, request_body, headers)
|
22
34
|
response.code.to_i
|
23
35
|
end
|
24
36
|
|
25
37
|
# rubocop:disable Style/GuardClause
|
26
38
|
unless response.is_a?(Net::HTTPSuccess)
|
27
|
-
raise IncidentReportingError, "Failed to
|
39
|
+
raise IncidentReportingError, "Failed to send an event to PagerDuty: #{response.body} #{request_body}"
|
28
40
|
end
|
29
41
|
# rubocop:enable Style/GuardClause
|
30
42
|
end
|
31
43
|
|
32
|
-
private
|
33
|
-
|
34
|
-
attr_reader :api_integration_key, :http
|
35
|
-
|
36
44
|
def retry_on(value, retries_number)
|
37
45
|
retry_number = 0
|
38
46
|
|
@@ -42,16 +50,10 @@ module NineOneOne
|
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
http.post(EVENTS_API_V2_ENDPOINT, body, headers)
|
49
|
-
end
|
50
|
-
|
51
|
-
def request_body(description, source, dedup_key, severity, details_hash)
|
52
|
-
body = {
|
53
|
+
def request_body(event_action, dedup_key, description = nil, source = nil, severity = nil, details_hash = nil)
|
54
|
+
{
|
53
55
|
routing_key: api_integration_key,
|
54
|
-
event_action:
|
56
|
+
event_action: event_action,
|
55
57
|
dedup_key: dedup_key,
|
56
58
|
payload: {
|
57
59
|
summary: description,
|
@@ -59,9 +61,7 @@ module NineOneOne
|
|
59
61
|
severity: severity,
|
60
62
|
custom_details: details_hash
|
61
63
|
}.reject { |_, v| v.nil? }
|
62
|
-
}.reject { |_, v| v.nil? }
|
63
|
-
|
64
|
-
body.to_json
|
64
|
+
}.reject { |_, v| v.nil? || v.empty? }.to_json
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/lib/nine_one_one/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nine_one_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kacper Madej
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.6.
|
217
|
+
rubygems_version: 2.6.14.1
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Alerts and notifications via PagerDuty and Slack for Ruby apps
|