debugbundle-python 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
debugbundle/core.py CHANGED
@@ -2,9 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  import asyncio
4
4
  import logging
5
+ import os
5
6
  import platform
7
+ import socket
6
8
  import sys
7
9
  import threading
10
+ import time
8
11
  import traceback
9
12
  import uuid
10
13
  from collections import deque
@@ -32,10 +35,16 @@ from .suppression import EventSuppressionTracker
32
35
  from .transport import HttpTransport, Transport, coerce_transport_response
33
36
  from .trigger_token import resolve_request_trigger_directives
34
37
 
38
+ try:
39
+ import resource
40
+ except ImportError: # pragma: no cover - resource is unavailable on some platforms.
41
+ resource = None # type: ignore[assignment]
42
+
35
43
  DEFAULT_BATCH_SIZE = 25
36
44
  DEFAULT_FLUSH_INTERVAL = 5.0
37
45
  DEFAULT_ENDPOINT = "https://api.debugbundle.com/v1/events"
38
46
  DEFAULT_LOG_LEVEL = "warning"
47
+ PROCESS_START_MONOTONIC = time.monotonic()
39
48
  SCHEMA_VERSION = "2026-03-01"
40
49
  LEVEL_RANKS = {
41
50
  "debug": 10,
@@ -225,7 +234,7 @@ class DebugBundleSdk:
225
234
  "handled": handled,
226
235
  "request": request_payload,
227
236
  "response": response_payload,
228
- "runtime": {"version": platform.python_version()},
237
+ "runtime": _runtime_process_facts(),
229
238
  }
230
239
  if self._probe_flush_on_error:
231
240
  probe_data = self._build_probe_data()
@@ -699,6 +708,51 @@ def _redact_mapping(value: object, redact_fields: set[str]) -> Any:
699
708
  return value
700
709
 
701
710
 
711
+ def _runtime_process_facts() -> dict[str, object]:
712
+ return {
713
+ "version": platform.python_version(),
714
+ "platform": sys.platform,
715
+ "arch": platform.machine() or None,
716
+ "pid": os.getpid(),
717
+ "cwd": _safe_cwd(),
718
+ "uptime_sec": round(max(0.0, time.monotonic() - PROCESS_START_MONOTONIC), 3),
719
+ "hostname": _safe_hostname(),
720
+ "thread_id": threading.get_ident(),
721
+ "memory": _memory_facts(),
722
+ }
723
+
724
+
725
+ def _safe_cwd() -> str | None:
726
+ try:
727
+ return os.getcwd()
728
+ except OSError:
729
+ return None
730
+
731
+
732
+ def _safe_hostname() -> str | None:
733
+ try:
734
+ return socket.gethostname()
735
+ except OSError:
736
+ return None
737
+
738
+
739
+ def _memory_facts() -> dict[str, object]:
740
+ memory: dict[str, object] = {
741
+ "rss": None,
742
+ "heap_total": None,
743
+ "heap_used": None,
744
+ "external": None,
745
+ "peak": None,
746
+ }
747
+ if resource is None:
748
+ return memory
749
+
750
+ usage = resource.getrusage(resource.RUSAGE_SELF)
751
+ # ru_maxrss is KiB on Linux and bytes on macOS/BSD.
752
+ memory["peak"] = usage.ru_maxrss if sys.platform == "darwin" else usage.ru_maxrss * 1024
753
+ return memory
754
+
755
+
702
756
  def _backend_exception_request_payload(candidate: object | None) -> dict[str, object]:
703
757
  mapping = _dict_from_object(candidate)
704
758
  payload: dict[str, object] = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: debugbundle-python
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: DebugBundle SDK for Python
5
5
  Author: DebugBundle
6
6
  License-Expression: AGPL-3.0-only
@@ -59,8 +59,28 @@ debugbundle.flush()
59
59
 
60
60
  ## Status
61
61
 
62
- This repository currently contains the full Phase 18 Python SDK scope in eleven implementation slices: core SDK surface, buffering, redaction, duplicate suppression, probe buffering, vanilla runtime hooks, framework integrations for Django, Flask, and FastAPI, remote config polling and capture-policy enforcement, optional `structlog` and `loguru` auto-detection when `capture_logging()` is enabled, contract-aligned `EventEnvelope` emission for log, request, exception, suppression, and probe payloads, explicit public wrapper signatures and a validated buildable typed package artifact, real HTTP integration coverage against a lightweight mock ingestion server, vendored machine-readable schema validation for all event types the Python SDK currently emits, a standalone CI workflow that validates Ruff, mypy, pytest, and package builds for the Python 3.10+ support floor actually used by the package, an enforced per-file coverage gate that keeps every shipped Python SDK module at or above the required 80% minimum, and request-local framework correlation binding so `X-DebugBundle-Trace-Id` flows through Django, Flask, and FastAPI into the emitted event correlation metadata for cross-context linking.
62
+ This repository currently contains the full Phase 18 Python SDK scope in eleven implementation slices: core SDK surface, buffering, redaction, duplicate suppression, probe buffering, vanilla runtime hooks, framework integrations for Django, Flask, and FastAPI, remote config polling and capture-policy enforcement, optional `structlog` and `loguru` auto-detection when `capture_logging()` is enabled, contract-aligned `EventEnvelope` emission for log, request, exception, suppression, and probe payloads, explicit public wrapper signatures and a validated buildable typed package artifact, real HTTP integration coverage against a lightweight mock ingestion server, vendored machine-readable schema validation for all event types the Python SDK currently emits, a standalone CI workflow that validates Ruff, mypy, pytest, and package builds for the Python 3.10+ support floor actually used by the package, an enforced per-file coverage gate that keeps every shipped Python SDK module at or above the required 80% minimum, request-local framework correlation binding so `X-DebugBundle-Trace-Id` flows through Django, Flask, and FastAPI into the emitted event correlation metadata for cross-context linking, and safe backend runtime process facts on exception payloads without reading environment variables.
63
+
64
+ ## Runtime Context
65
+
66
+ Backend exception events now include safe runtime process facts when the host exposes them, including:
67
+
68
+ - Python version
69
+ - platform
70
+ - architecture
71
+ - pid
72
+ - cwd
73
+ - uptime
74
+ - hostname
75
+ - thread id
76
+ - best-effort memory metadata
77
+
78
+ The SDK does not read or emit environment variables in this runtime block.
63
79
 
64
80
  ## Docs
65
81
 
66
82
  https://debugbundle.com/docs/sdk-python
83
+
84
+ ## License
85
+
86
+ AGPL-3.0-only
@@ -1,6 +1,6 @@
1
1
  debugbundle/__init__.py,sha256=mqibduUrdcr_fnb6k3Gwf93H7iqVBS8zd6SceX-U3Q4,5011
2
2
  debugbundle/config.py,sha256=2dLHEsh79mUaa6p7pkrQM849khwSBPg68Aq9RaeXf-8,6105
3
- debugbundle/core.py,sha256=WbPaZjfYvnaL-a2j38t_RiCuvXgY0zOZf3gA0qZojgY,32817
3
+ debugbundle/core.py,sha256=KIXboK-n1zbgmTCMO1kf-v_jtAA4SOFQvd0BahEt29s,34204
4
4
  debugbundle/logger_integrations.py,sha256=RuTNaD9RRVmiE-BBkksAXWVEGaMzLrWavVpQdgGZBpE,4564
5
5
  debugbundle/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  debugbundle/redaction.py,sha256=QTaPkSsYv54yR1mz8SB6Q4vWjvp7Ddcui4WXaH2RVz8,736
@@ -16,8 +16,8 @@ debugbundle/integrations/flask.py,sha256=cgyHbsAH96gpNPf_5IGJYzp2va28JdDgXROBsF-
16
16
  debugbundle/integrations/relay_django.py,sha256=_2TiH-oS0DOwThyfMJZ6ZJr5MkXEekEDaBUfPapMxt8,1523
17
17
  debugbundle/integrations/relay_fastapi.py,sha256=Z2spWy3wufVrBjYwRDDOL5Dsjgwcd5g72L23_sdulvo,1512
18
18
  debugbundle/integrations/relay_flask.py,sha256=WHk_ALOtT0xUuI1eINWFyLig9eRjSmIBpQ39xdkV608,1329
19
- debugbundle_python-0.1.1.dist-info/licenses/LICENSE,sha256=AKZZ5DQAHrOKGwt24VoRd-SXJLM9OloxlsX8ZgENdEY,735
20
- debugbundle_python-0.1.1.dist-info/METADATA,sha256=zl-nrFAiJBSsX9rKJI8pvTncCi3FU1i2pYFRn7kKLF4,3148
21
- debugbundle_python-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
22
- debugbundle_python-0.1.1.dist-info/top_level.txt,sha256=RCB9STTFnl1OKdojxz-xhaks2zkRFs1meZXsKnm18LM,12
23
- debugbundle_python-0.1.1.dist-info/RECORD,,
19
+ debugbundle_python-0.1.2.dist-info/licenses/LICENSE,sha256=AKZZ5DQAHrOKGwt24VoRd-SXJLM9OloxlsX8ZgENdEY,735
20
+ debugbundle_python-0.1.2.dist-info/METADATA,sha256=sJOxeZhAm37kzC-TtO0SWrIZ5FEckB8oSNGZ78RCOsY,3589
21
+ debugbundle_python-0.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
22
+ debugbundle_python-0.1.2.dist-info/top_level.txt,sha256=RCB9STTFnl1OKdojxz-xhaks2zkRFs1meZXsKnm18LM,12
23
+ debugbundle_python-0.1.2.dist-info/RECORD,,