Skip to content

Commit

Permalink
Include exception trace in JSON log
Browse files Browse the repository at this point in the history
Rather than use logging.exception, which places the stack trace outside
the structured log, using logging.error instead and log the exception
within the JSON structured log message.
  • Loading branch information
jonathansick committed Sep 1, 2023
1 parent 1aaec62 commit 5a0000f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ ignore = [
"TD004", # skip requiring TODOs to have issue links
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
"TRY400", # We want JSON formatting of the exception messages
]
select = ["ALL"]
target-version = "py311"
Expand Down
5 changes: 3 additions & 2 deletions src/ook/services/algoliaaudit.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ async def audit_missing_documents(
product_slug=doc.slug, edition_slug="main"
)
reingest_count += 1
except Exception:
self._logger.exception(
except Exception as e:
self._logger.error(
"Failed to queue ingest for missing document",
handle=doc.slug.upper(),
published_url=doc.published_url,
exception=str(e),
)
self._logger.info(
"Queued ingest for missing documents",
Expand Down

0 comments on commit 5a0000f

Please sign in to comment.