feat(transport): Add EnvelopePrinterTransport for debug logging #6181
2 issues
Medium
EnvelopePrinterTransport performs serialization and file I/O even when debug logging is disabled - `sentry_sdk/transport.py:1098-1121`
capture_envelope unconditionally calls json.dumps on envelope/item headers and item.get_bytes() on every item before passing the args to logger.debug. Because logger.debug only formats arguments when the debug level is enabled, the wrapper still pays the full cost (including potential disk reads inside Item.get_bytes when the payload is backed by a file path) on every send, regardless of log level. This contradicts the PR description's claim of 'no runtime cost' when enabled but logger is not at debug, and adds latency/allocations on the hot send path.
Low
Overriding __class__ to masquerade as the inner transport can break isinstance/type checks elsewhere - `sentry_sdk/transport.py:1094-1096`
The __class__ property returns self._inner.__class__, causing type(wrapper) and isinstance(wrapper, ...) to report the wrapped transport's class. Code elsewhere that branches on transport type (e.g. checks for HttpTransport vs AsyncHttpTransport, or that uses type(...).__name__ for diagnostics) will be silently misled, and the same applies to debuggers and error reporting. This is a non-obvious side effect that could confuse future maintainers and tooling.
4 skills analyzed
| Skill | Findings | Duration | Cost |
|---|---|---|---|
| code-review | 2 | 49.6s | $0.57 |
| find-bugs | 0 | 52.0s | $0.62 |
| skill-scanner | 0 | 15.2s | $0.28 |
| security-review | 0 | 16.9s | $0.26 |
Duration: 2m 14s · Tokens: 477.8k in / 4.3k out · Cost: $1.74 (+merge: $0.00, +dedup: $0.01)