debugbundle-python 1.4.2__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/PKG-INFO +12 -5
  2. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/README.md +8 -3
  3. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/pyproject.toml +4 -2
  4. debugbundle_python-2.0.0/src/debugbundle/capture_hooks.py +65 -0
  5. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/core.py +379 -251
  6. debugbundle_python-2.0.0/src/debugbundle/delivery_hooks.py +62 -0
  7. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/event_support.py +1 -1
  8. debugbundle_python-2.0.0/src/debugbundle/exception_snapshot.py +74 -0
  9. debugbundle_python-2.0.0/src/debugbundle/flush_aggregates.py +37 -0
  10. debugbundle_python-2.0.0/src/debugbundle/probe_capture.py +101 -0
  11. debugbundle_python-2.0.0/src/debugbundle/process_support.py +59 -0
  12. debugbundle_python-2.0.0/src/debugbundle/queue_admission.py +39 -0
  13. debugbundle_python-2.0.0/src/debugbundle/redaction.py +226 -0
  14. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/relay.py +8 -0
  15. debugbundle_python-2.0.0/src/debugbundle/request_capture_policy.py +45 -0
  16. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/suppression.py +13 -6
  17. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle_python.egg-info/PKG-INFO +12 -5
  18. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle_python.egg-info/SOURCES.txt +12 -0
  19. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle_python.egg-info/requires.txt +1 -1
  20. debugbundle_python-2.0.0/tests/test_delivery_hooks.py +108 -0
  21. debugbundle_python-2.0.0/tests/test_exception_snapshot.py +95 -0
  22. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_hooks.py +36 -2
  23. debugbundle_python-2.0.0/tests/test_privacy_conformance.py +34 -0
  24. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_relay.py +11 -0
  25. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_remote_config.py +8 -0
  26. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_repository_metadata.py +1 -1
  27. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_schema_validation.py +2 -1
  28. debugbundle_python-2.0.0/tests/test_sdk.py +1213 -0
  29. debugbundle_python-2.0.0/tests/test_suppression.py +9 -0
  30. debugbundle_python-1.4.2/src/debugbundle/redaction.py +0 -29
  31. debugbundle_python-1.4.2/tests/test_sdk.py +0 -544
  32. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/LICENSE +0 -0
  33. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/setup.cfg +0 -0
  34. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/__init__.py +0 -0
  35. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/acknowledgement.py +0 -0
  36. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/before_send.py +0 -0
  37. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/config.py +0 -0
  38. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/__init__.py +0 -0
  39. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/common.py +0 -0
  40. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/django.py +0 -0
  41. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/fastapi.py +0 -0
  42. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/flask.py +0 -0
  43. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/relay_django.py +0 -0
  44. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/relay_fastapi.py +0 -0
  45. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/integrations/relay_flask.py +0 -0
  46. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/logger_integrations.py +0 -0
  47. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/py.typed +0 -0
  48. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/relay_delivery.py +0 -0
  49. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/structlog_integration.py +0 -0
  50. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/transport.py +0 -0
  51. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle/trigger_token.py +0 -0
  52. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle_python.egg-info/dependency_links.txt +0 -0
  53. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/src/debugbundle_python.egg-info/top_level.txt +0 -0
  54. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_before_send.py +0 -0
  55. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_contracts.py +0 -0
  56. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_framework_integrations.py +0 -0
  57. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_http_integration.py +0 -0
  58. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_optional_imports.py +0 -0
  59. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_relay_delivery.py +0 -0
  60. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_smoke_script.py +0 -0
  61. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_structlog_filtering.py +0 -0
  62. {debugbundle_python-1.4.2 → debugbundle_python-2.0.0}/tests/test_trigger_token.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: debugbundle-python
3
- Version: 1.4.2
3
+ Version: 2.0.0
4
4
  Summary: DebugBundle SDK for Python
5
5
  Author: DebugBundle
6
6
  License-Expression: Apache-2.0
@@ -17,6 +17,8 @@ Classifier: Programming Language :: Python :: 3 :: Only
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
20
22
  Classifier: Typing :: Typed
21
23
  Requires-Python: >=3.10
22
24
  Description-Content-Type: text/markdown
@@ -24,7 +26,7 @@ License-File: LICENSE
24
26
  Requires-Dist: httpx<0.29,>=0.27
25
27
  Provides-Extra: dev
26
28
  Requires-Dist: build<2,>=1; extra == "dev"
27
- Requires-Dist: django<6,>=5; extra == "dev"
29
+ Requires-Dist: django<7,>=5; extra == "dev"
28
30
  Requires-Dist: fastapi<1,>=0.115; extra == "dev"
29
31
  Requires-Dist: flask<4,>=3; extra == "dev"
30
32
  Requires-Dist: jsonschema<5,>=4.23; extra == "dev"
@@ -49,6 +51,8 @@ Use this package to capture Python backend exceptions, request metadata, structu
49
51
 
50
52
  Requires Python 3.10 or newer.
51
53
 
54
+ Version 2.0.0 protects capture callers with bounded, priority-aware background delivery. Review the [2.0 migration guide](MIGRATION-2.0.md) before upgrading from 1.x.
55
+
52
56
  ## Automatic capture and application filtering
53
57
 
54
58
  `capture_logging()` attaches the stdlib logging handler and detects installed structlog/loguru integrations. Obtain structlog loggers after attachment. Structlog level filters and `DropEvent` processors run before capture; stdlib-backed structlog loggers also honor logger filters, disabled state and `logging.disable()`. Bound context and async logging are supported. SDK disposal stops capture through cached proxies. DebugBundle has its own minimum capture level; destination-specific filters on other handlers or Loguru sinks do not configure the DebugBundle handler.
@@ -97,6 +101,7 @@ debugbundle.capture_log("payment retry failed", level="warning", context={"order
97
101
  debugbundle.capture_message("worker started")
98
102
  debugbundle.probe("checkout.cart", {"item_count": len(cart.items)})
99
103
 
104
+ # Use only during controlled teardown or tests, never on a request path.
100
105
  debugbundle.flush()
101
106
  ```
102
107
 
@@ -263,8 +268,8 @@ There is no zero-install fallback for the Python SDK itself in V1. The nearest l
263
268
 
264
269
  | Surface | Minimum compatibility version | Recommended production version | Installed-base compatibility lane | Rolling CI lane | Out of scope |
265
270
  | --- | --- | --- | --- | --- | --- |
266
- | Python runtime | 3.10 | 3.12 | 3.10 and 3.11 remain supported for installed-base coverage | 3.12 | 3.9 and older |
267
- | Django | 5.x | latest 5.x patch | 5.x compatibility support | repo release smoke and tests install Django 5.x | Django 4.x and older |
271
+ | Python runtime | 3.10 | 3.14 | 3.10 through 3.13 remain supported for installed-base coverage | 3.10 through 3.14 | 3.9 and older |
272
+ | Django | 5.x | latest 6.1 patch | 5.x compatibility support | Python 3.14 suite exercises Django 6.1 | Django 4.x and older |
268
273
  | Flask | 3.x | latest 3.x patch | 3.x compatibility support | repo release smoke installs Flask 3.x | Flask 2.x and older |
269
274
  | FastAPI | 0.115+ | latest 0.115+ patch line | 0.115+ compatibility support | repo tests install FastAPI 0.115+ | standalone Starlette, older FastAPI lines |
270
275
 
@@ -275,14 +280,16 @@ Post-V1 planned expansions from `spec/sdk-language-targets.md` remain out of sco
275
280
  `debugbundle-python` ships as one package in V1, so there is no multi-package version-alignment step like a BOM or plugin family lock.
276
281
 
277
282
  - Pin one `debugbundle-python` version across your service and worker repos when you want identical SDK behavior everywhere.
278
- - Keep framework dependencies inside the supported lanes above: Django 5.x, Flask 3.x, and FastAPI 0.115+.
283
+ - Keep framework dependencies inside the supported lanes above: Django 5.x or 6.x, Flask 3.x, and FastAPI 0.115+.
279
284
  - The packaged HTTP client dependency is `httpx>=0.27,<0.29`; if you override transport behavior in tests or wrappers, stay inside that range unless you retest the SDK.
280
285
 
281
286
  ## Safety Defaults
282
287
 
283
288
  - SDK failures are caught internally and do not crash the host process.
289
+ - A forked worker starts with a fresh SDK queue, lock, context and built-in HTTP client. Initialize the SDK in each child when remote configuration must poll there; custom transports must be fork-safe.
284
290
  - Sensitive fields are redacted before transport.
285
291
  - Duplicate event storms are suppressed locally.
292
+ - Full-queue capture sheds warning/request noise before context scans. Exceptions, ERROR logs, and 5xx request incidents have priority over pending lower-priority events; all-error overloads are bounded and summarized.
286
293
  - Runtime context excludes environment variables.
287
294
  - Browser relay requests cannot smuggle server-side credentials.
288
295
 
@@ -10,6 +10,8 @@ Use this package to capture Python backend exceptions, request metadata, structu
10
10
 
11
11
  Requires Python 3.10 or newer.
12
12
 
13
+ Version 2.0.0 protects capture callers with bounded, priority-aware background delivery. Review the [2.0 migration guide](MIGRATION-2.0.md) before upgrading from 1.x.
14
+
13
15
  ## Automatic capture and application filtering
14
16
 
15
17
  `capture_logging()` attaches the stdlib logging handler and detects installed structlog/loguru integrations. Obtain structlog loggers after attachment. Structlog level filters and `DropEvent` processors run before capture; stdlib-backed structlog loggers also honor logger filters, disabled state and `logging.disable()`. Bound context and async logging are supported. SDK disposal stops capture through cached proxies. DebugBundle has its own minimum capture level; destination-specific filters on other handlers or Loguru sinks do not configure the DebugBundle handler.
@@ -58,6 +60,7 @@ debugbundle.capture_log("payment retry failed", level="warning", context={"order
58
60
  debugbundle.capture_message("worker started")
59
61
  debugbundle.probe("checkout.cart", {"item_count": len(cart.items)})
60
62
 
63
+ # Use only during controlled teardown or tests, never on a request path.
61
64
  debugbundle.flush()
62
65
  ```
63
66
 
@@ -224,8 +227,8 @@ There is no zero-install fallback for the Python SDK itself in V1. The nearest l
224
227
 
225
228
  | Surface | Minimum compatibility version | Recommended production version | Installed-base compatibility lane | Rolling CI lane | Out of scope |
226
229
  | --- | --- | --- | --- | --- | --- |
227
- | Python runtime | 3.10 | 3.12 | 3.10 and 3.11 remain supported for installed-base coverage | 3.12 | 3.9 and older |
228
- | Django | 5.x | latest 5.x patch | 5.x compatibility support | repo release smoke and tests install Django 5.x | Django 4.x and older |
230
+ | Python runtime | 3.10 | 3.14 | 3.10 through 3.13 remain supported for installed-base coverage | 3.10 through 3.14 | 3.9 and older |
231
+ | Django | 5.x | latest 6.1 patch | 5.x compatibility support | Python 3.14 suite exercises Django 6.1 | Django 4.x and older |
229
232
  | Flask | 3.x | latest 3.x patch | 3.x compatibility support | repo release smoke installs Flask 3.x | Flask 2.x and older |
230
233
  | FastAPI | 0.115+ | latest 0.115+ patch line | 0.115+ compatibility support | repo tests install FastAPI 0.115+ | standalone Starlette, older FastAPI lines |
231
234
 
@@ -236,14 +239,16 @@ Post-V1 planned expansions from `spec/sdk-language-targets.md` remain out of sco
236
239
  `debugbundle-python` ships as one package in V1, so there is no multi-package version-alignment step like a BOM or plugin family lock.
237
240
 
238
241
  - Pin one `debugbundle-python` version across your service and worker repos when you want identical SDK behavior everywhere.
239
- - Keep framework dependencies inside the supported lanes above: Django 5.x, Flask 3.x, and FastAPI 0.115+.
242
+ - Keep framework dependencies inside the supported lanes above: Django 5.x or 6.x, Flask 3.x, and FastAPI 0.115+.
240
243
  - The packaged HTTP client dependency is `httpx>=0.27,<0.29`; if you override transport behavior in tests or wrappers, stay inside that range unless you retest the SDK.
241
244
 
242
245
  ## Safety Defaults
243
246
 
244
247
  - SDK failures are caught internally and do not crash the host process.
248
+ - A forked worker starts with a fresh SDK queue, lock, context and built-in HTTP client. Initialize the SDK in each child when remote configuration must poll there; custom transports must be fork-safe.
245
249
  - Sensitive fields are redacted before transport.
246
250
  - Duplicate event storms are suppressed locally.
251
+ - Full-queue capture sheds warning/request noise before context scans. Exceptions, ERROR logs, and 5xx request incidents have priority over pending lower-priority events; all-error overloads are bounded and summarized.
247
252
  - Runtime context excludes environment variables.
248
253
  - Browser relay requests cannot smuggle server-side credentials.
249
254
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "debugbundle-python"
7
- version = "1.4.2"
7
+ version = "2.0.0"
8
8
  description = "DebugBundle SDK for Python"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -21,6 +21,8 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3.10",
22
22
  "Programming Language :: Python :: 3.11",
23
23
  "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
24
26
  "Typing :: Typed"
25
27
  ]
26
28
  dependencies = [
@@ -30,7 +32,7 @@ dependencies = [
30
32
  [project.optional-dependencies]
31
33
  dev = [
32
34
  "build>=1,<2",
33
- "django>=5,<6",
35
+ "django>=5,<7",
34
36
  "fastapi>=0.115,<1",
35
37
  "flask>=3,<4",
36
38
  "jsonschema>=4.23,<5",
@@ -0,0 +1,65 @@
1
+ """Logger adapter and bounded capture admission for callback-heavy paths."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import re
7
+ import time
8
+ from typing import TYPE_CHECKING
9
+
10
+ from .process_support import ensure_current_process
11
+
12
+ if TYPE_CHECKING:
13
+ from .core import DebugBundleSdk
14
+
15
+
16
+ def try_capture_lock(sdk: DebugBundleSdk) -> bool:
17
+ ensure_current_process(sdk)
18
+ for _ in range(8):
19
+ if sdk._lock.acquire(blocking=False):
20
+ return True
21
+ time.sleep(0)
22
+ return False
23
+
24
+
25
+ class DebugBundleLogHandler(logging.Handler):
26
+ def __init__(self, sdk: DebugBundleSdk) -> None:
27
+ super().__init__()
28
+ self._sdk = sdk
29
+
30
+ def emit(self, record: logging.LogRecord) -> None:
31
+ if not self._sdk._log_level_eligible(record.levelname.lower()):
32
+ return
33
+ self._sdk.capture_log(
34
+ safe_log_message(record),
35
+ level=record.levelname.lower(),
36
+ context={
37
+ "logger_name": record.name,
38
+ "pathname": record.pathname,
39
+ "lineno": record.lineno,
40
+ },
41
+ )
42
+
43
+
44
+ _PLACEHOLDER = re.compile(r"%[sdif]")
45
+
46
+
47
+ def safe_log_message(record: logging.LogRecord) -> str:
48
+ template = record.msg
49
+ if type(template) is not str:
50
+ return "[non-string log message withheld]"
51
+ template = template[:16_384]
52
+ args = record.args
53
+ if not args:
54
+ return template
55
+ if type(args) is not tuple or len(args) > 8:
56
+ return template + " [log arguments withheld]"
57
+ safe_args = [
58
+ value[:1024] if type(value) is str else str(value) if type(value) in (int, float, bool)
59
+ else "[unsupported argument]"
60
+ for value in args
61
+ ]
62
+ if len(_PLACEHOLDER.findall(template)) != len(safe_args):
63
+ return (template + " [args: " + ", ".join(safe_args) + "]")[:16_384]
64
+ iterator = iter(safe_args)
65
+ return _PLACEHOLDER.sub(lambda _match: next(iterator), template)[:16_384]