Skip to content

Commit

Permalink
better error logs in datadog (#104)
Browse files Browse the repository at this point in the history
* better error logs in datadog

* changelog

* prepare 0.3.0 release (#105)
  • Loading branch information
Matt Kafonek authored Apr 26, 2023
1 parent 20dd137 commit 5158dc6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.3.0] - 2023-04-26
### Added
- Standard Noteable open source patterns
- Contributing / Code of Conduct files
Expand All @@ -21,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `WebsocketManager` backend uses vanilla `logging` instead of `structlog`, remove need for `structlog` dependency once `managed-service-fixtures` also drops it
- `JupyterBackend` introduce a short sleep in its poll loop while investigating 100% CPU usage
- `JupyterBackend` zmq polling changed fairly significantly to avoid missing messages while reconnecting socket after a max message size disconnect
- Try to include tracebacks during exception logs for inbound / outbound / process workers

## [0.2.2] - 2022-07-28
### Changed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sending"
version = "0.2.2"
version = "0.3.0"
description = "Library for pub/sub usage within an async application"
authors = ["Nicholas Wold <[email protected]>"]

Expand Down
24 changes: 18 additions & 6 deletions sending/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import abc
import asyncio
import enum
import traceback
from collections import defaultdict, namedtuple
from functools import partial, wraps
from typing import Callable, Dict, List, Optional, Set
Expand Down Expand Up @@ -302,8 +303,11 @@ async def _outbound_worker(self):
message = message._replace(contents=await coro(message.contents))
logger.debug(f"Sending message to topic: {message.topic}")
await self._publish(message)
except Exception:
logger.exception("Uncaught exception found while publishing message")
except Exception as e:
tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
logger.exception(
"Uncaught exception found while publishing message", exc_info="".join(tb_str)
)
finally:
self.outbound_queue.task_done()

Expand Down Expand Up @@ -334,8 +338,12 @@ async def _inbound_worker(self):
await asyncio.gather(
*[self._delegate_to_callback(message, cb_id) for cb_id in callback_ids]
)
except Exception:
logger.exception("Uncaught exception found while processing inbound message")
except Exception as e:
tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
logger.exception(
"Uncaught exception found while processing inbound message",
exc_info="".join(tb_str),
)
finally:
self.inbound_queue.task_done()

Expand All @@ -360,8 +368,12 @@ async def _delegate_to_callback(self, message: QueuedMessage, callback_id: UUID)
logger.debug(
f"Skipping callback '{cb.qualname}' because predicate returned False"
)
except Exception:
logger.exception("Uncaught exception encountered while delegating to callback")
except Exception as e:
tb_str = traceback.format_exception(etype=type(e), value=e, tb=e.__traceback__)
logger.exception(
"Uncaught exception encountered while delegating to callback",
exc_info="".join(tb_str),
)

async def _poll_loop(self):
while True:
Expand Down

0 comments on commit 5158dc6

Please sign in to comment.