Skip to content

Commit

Permalink
Use exception logger for Kafka handler errors
Browse files Browse the repository at this point in the history
Turns out structlog does format the exception trace in the structured
log after all, so this is fine.
  • Loading branch information
jonathansick committed Sep 5, 2023
1 parent 6c5ba0d commit a77abf8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/ook/handlers/kafka/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,12 @@ async def start(self) -> None:
)
try:
await self._handle_message(msg)
except Exception as e:
self._logger.error(
except Exception:
self._logger.exception(
"Error handling message",
topic=msg.topic,
partition=msg.partition,
offset=msg.offset,
exception=e,
)
self._logger.debug(
"Finished handling message",
Expand All @@ -177,13 +176,12 @@ async def _handle_message(self, msg: ConsumerRecord) -> None:
try:
key = await self._schema_manager.deserialize(msg.key)
value = await self._schema_manager.deserialize(msg.value)
except UnmanagedSchemaError as e:
self._logger.error(
except UnmanagedSchemaError:
self._logger.exception(
"Could not deserialize message due to unmanaged schema",
topic=msg.topic,
partition=msg.partition,
offset=msg.offset,
exception=str(e),
)
return
message_metadata = MessageMetadata.from_consumer_record(msg)
Expand Down

0 comments on commit a77abf8

Please sign in to comment.