teams-alerter 0.1.7__py3-none-any.whl → 0.1.8__py3-none-any.whl
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.
- teams_alerter/core.py +14 -27
- {teams_alerter-0.1.7.dist-info → teams_alerter-0.1.8.dist-info}/METADATA +1 -1
- teams_alerter-0.1.8.dist-info/RECORD +7 -0
- teams_alerter-0.1.7.dist-info/RECORD +0 -7
- {teams_alerter-0.1.7.dist-info → teams_alerter-0.1.8.dist-info}/WHEEL +0 -0
- {teams_alerter-0.1.7.dist-info → teams_alerter-0.1.8.dist-info}/top_level.txt +0 -0
teams_alerter/core.py
CHANGED
@@ -10,51 +10,38 @@ class TeamsAlerter:
|
|
10
10
|
def __init__(
|
11
11
|
self,
|
12
12
|
utils: ErrorUtils,
|
13
|
-
detail,
|
14
|
-
level,
|
15
|
-
environment=None,
|
16
|
-
url_log=None,
|
17
|
-
timestamp=None,
|
18
|
-
teams_template=None,
|
19
13
|
):
|
20
14
|
self.utils = utils
|
21
|
-
self.detail = detail
|
22
|
-
self.environment = environment
|
23
|
-
self.level = level
|
24
|
-
self.timestamp = timestamp
|
25
|
-
self.url_log = url_log
|
26
|
-
self.teams_template = teams_template
|
27
15
|
|
28
16
|
@staticmethod
|
29
17
|
def handle_error(error: Exception, utils: ErrorUtils) -> None:
|
30
18
|
error_type = type(error).__name__
|
31
19
|
error_message = str(error)
|
32
20
|
error_traceback = traceback.format_exc()
|
33
|
-
|
34
|
-
teams_alerter = TeamsAlerter(
|
35
|
-
utils=utils,
|
36
|
-
detail=f"Error type: {error_type}\nError message: {error_message}\nError traceback: {error_traceback}",
|
37
|
-
level="ERROR",
|
38
|
-
)
|
39
|
-
|
40
|
-
teams_alerter.publish_alert()
|
41
|
-
|
42
|
-
def publish_alert(self):
|
43
|
-
# Formatage du payload
|
44
21
|
utc_timestamp = DateUtils.get_str_utc_timestamp()
|
45
22
|
utc_timestamp_minus_5min = DateUtils.get_str_utc_timestamp_minus_5min()
|
46
23
|
utc_timestamp_plus_5min = DateUtils.get_str_utc_timestamp_plus_5min()
|
24
|
+
url_log = f"https://console.cloud.google.com/logs/query;cursorTimestamp={utc_timestamp};startTime={utc_timestamp_minus_5min};endTime={utc_timestamp_plus_5min}?referrer=search&hl=fr&inv=1&invt=Ab5Y1Q&project={utils['app_project_id']}"
|
25
|
+
detail = f"Error type: {error_type}\nError message: {error_message}\nError traceback: {error_traceback}"
|
26
|
+
level = "ERROR"
|
47
27
|
|
28
|
+
teams_alerter = TeamsAlerter(utils)
|
29
|
+
|
30
|
+
teams_alerter.publish_alert(detail, level, url_log, "card", utc_timestamp)
|
31
|
+
|
32
|
+
def publish_alert(self, detail, level, url_log, teams_template, utc_timestamp):
|
33
|
+
|
34
|
+
# Formatage du payload
|
48
35
|
payload = json.dumps(
|
49
36
|
{
|
50
37
|
"app_name": self.utils["app_name"],
|
51
38
|
"teams_channel": self.utils["teams_channel"],
|
52
|
-
"detail":
|
53
|
-
"level":
|
39
|
+
"detail": detail,
|
40
|
+
"level": level,
|
54
41
|
"environment": self.utils["env"],
|
55
|
-
"url_log":
|
42
|
+
"url_log": url_log,
|
56
43
|
"timestamp": utc_timestamp,
|
57
|
-
"teams_template":
|
44
|
+
"teams_template": teams_template,
|
58
45
|
}
|
59
46
|
)
|
60
47
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
teams_alerter/__init__.py,sha256=J6zyyTfUNVElXD0wsTqBwp-VtcApbzYGUPpChrdcbpY,131
|
2
|
+
teams_alerter/core.py,sha256=tw3YUAG-73rAPdye3pHdcgBsCd9jFcshjCxSjUvCoOw,2297
|
3
|
+
teams_alerter/utils.py,sha256=FIv5LaU7Ff4mB9PRvYILCq3DJJKDImbgDx_pCTGbp9k,861
|
4
|
+
teams_alerter-0.1.8.dist-info/METADATA,sha256=3d8P7Jz-d48kD3pOaM_Gn1f2Utz-14mynBNpYdykQJ8,2194
|
5
|
+
teams_alerter-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
teams_alerter-0.1.8.dist-info/top_level.txt,sha256=Qt8-VgHT7YPTbMzYkAomK9itC-w4YpV7IJ5X6b-TC-4,14
|
7
|
+
teams_alerter-0.1.8.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
teams_alerter/__init__.py,sha256=J6zyyTfUNVElXD0wsTqBwp-VtcApbzYGUPpChrdcbpY,131
|
2
|
-
teams_alerter/core.py,sha256=VVDeIinTjTVFWwJbbRj2DDzzl7qHvjlRd5Q5m3JBmfY,2564
|
3
|
-
teams_alerter/utils.py,sha256=FIv5LaU7Ff4mB9PRvYILCq3DJJKDImbgDx_pCTGbp9k,861
|
4
|
-
teams_alerter-0.1.7.dist-info/METADATA,sha256=Nm3-cuxodc_uFSp1HN2-dLHSLBbrlOXpNj6RlwUTukw,2194
|
5
|
-
teams_alerter-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
-
teams_alerter-0.1.7.dist-info/top_level.txt,sha256=Qt8-VgHT7YPTbMzYkAomK9itC-w4YpV7IJ5X6b-TC-4,14
|
7
|
-
teams_alerter-0.1.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|