From 2d5bbbb9a78ceff5e56edb2177955f0e6a35e053 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Mon, 22 Apr 2024 15:29:15 -0400 Subject: [PATCH 1/2] Use format_exception() instead of exception() --- src/nextline_alert/emitter.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/nextline_alert/emitter.py b/src/nextline_alert/emitter.py index 8a44beb..dca54d6 100644 --- a/src/nextline_alert/emitter.py +++ b/src/nextline_alert/emitter.py @@ -1,4 +1,3 @@ -import traceback from logging import getLogger import httpx @@ -17,17 +16,16 @@ def __init__(self, url: str, platform: str): async def on_end_run(self, context: Context) -> None: run_arg = context.run_arg nextline = context.nextline - if e := nextline.exception(): + if fmt_exc := nextline.format_exception(): run_no_str = 'unknown' if run_arg is None else f'{run_arg.run_no}' alertname = f'Run {run_no_str} failed' - desc = ''.join(traceback.format_exception(type(e), e, e.__traceback__)) self._logger.info(f"Emitting alert: '{alertname}'") labels = {'alertname': alertname, 'platform': self._platform} try: - await emit(url=self._url, labels=labels, description=desc) + await emit(url=self._url, labels=labels, description=fmt_exc) except BaseException: self._logger.exception(f"Failed to emit alert: '{alertname}'") - self._logger.debug(f'Alert description: {desc!r}') + self._logger.debug(f'Alert description: {fmt_exc!r}') async def emit(url: str, labels: dict[str, str], description: str) -> None: From 8811334a5954af469a94ea6ec0fdc6feda655868 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Mon, 22 Apr 2024 16:24:05 -0400 Subject: [PATCH 2/2] Require nextline-graphql 0.7.3 or later --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 00419b3..fba0bb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] -dependencies = ["nextline-graphql>=0.7.3", "httpx>=0.26"] +dependencies = ["nextline-graphql>=0.7.6", "httpx>=0.26"] dynamic = ["version"] [project.optional-dependencies]