Skip to content

Commit

Permalink
Merge pull request #6 from simonsobs/dev
Browse files Browse the repository at this point in the history
Require nextline-graphql 0.7.3 or later
  • Loading branch information
TaiSakuma authored Apr 22, 2024
2 parents 9bd3bf0 + 8811334 commit b52f572
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 3 additions & 5 deletions src/nextline_alert/emitter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import traceback
from logging import getLogger

import httpx
Expand All @@ -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:
Expand Down

0 comments on commit b52f572

Please sign in to comment.