trodo-python 3.0.3__py3-none-any.whl → 3.0.4__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.
trodo/_version.py CHANGED
@@ -1 +1 @@
1
- SDK_VERSION = "3.0.3"
1
+ SDK_VERSION = "3.0.4"
trodo/delivery/sender.py CHANGED
@@ -27,7 +27,11 @@ and PostHog have converged on (1 Oct 2026 survey):
27
27
  oversized item is dropped as ``too_large``; any other 4xx is a bad item:
28
28
  dropped as ``rejected``, reported once.
29
29
  - exit: ``atexit`` flushes (bounded by ``exit_flush_s``) and says on stderr
30
- how many traces were still undelivered, and why, if any were.
30
+ how many traces were still undelivered, and why, if any were. Requests
31
+ sent while exiting (or in ``shutdown``) are marked ``exiting`` (3.0.4):
32
+ Trodo takes the whole batch into its backlog at once instead of storing
33
+ each trace while the request waits, so a short script hands over
34
+ hundreds of traces in its last seconds.
31
35
  - the server holds over-rate items itself (202 ``queued``) and stores them
32
36
  at the team's rate; the sender says so on stderr once per 10 minutes.
33
37
  - ``immediate`` mode for platforms that freeze between requests (Lambda,
@@ -137,6 +141,7 @@ class Sender:
137
141
  self._unit_cap: Optional[int] = None # the team's ceiling, once a 429 names it
138
142
  self._last_rate: Optional[Dict[str, Any]] = None
139
143
  self._warned_paced_at = 0.0
144
+ self._exiting = False # set by the exit flush and shutdown: the server holds the batch
140
145
  self._threads: List[threading.Thread] = []
141
146
  self._runs_in_flight: Dict[str, int] = {} # run_id -> requests carrying it
142
147
  if self.mode == "background" and register_atexit:
@@ -184,6 +189,7 @@ class Sender:
184
189
  self._flush_requested = False
185
190
 
186
191
  def shutdown(self, timeout_s: Optional[float] = None) -> None:
192
+ self._exiting = True
187
193
  self.flush(self._o["exit_flush_s"] if timeout_s is None else timeout_s)
188
194
  with self._lock:
189
195
  self._stopped = True
@@ -338,8 +344,8 @@ class Sender:
338
344
  first_error = first_error or f"HTTP {st}: {r.get('error', '')}"
339
345
  if rejected:
340
346
  self._drop(rejected, "rejected", f"{rejected} item(s) rejected by the server ({first_error})")
341
- if queued:
342
- self._warn_paced(body.get("paced") if isinstance(body.get("paced"), dict) else {})
347
+ if queued and isinstance(body.get("paced"), dict): # held for rate, not an exit hand-off
348
+ self._warn_paced(body["paced"])
343
349
  ra = body.get("retry_after_ms")
344
350
  if ra:
345
351
  self._pause(float(ra) / 1000.0)
@@ -470,11 +476,13 @@ class Sender:
470
476
  self._drop(n, "queue_full", f"the delivery queue is full ({self._o['max_queue_items']} items / {self._o['max_queue_bytes'] // 1048576} MB); the {n} oldest were dropped")
471
477
 
472
478
  def _envelope(self, batch: List[_Queued]) -> Dict[str, Any]:
473
- items = [q.item for q in batch]
479
+ env: Dict[str, Any] = {"items": [q.item for q in batch]}
480
+ if self._exiting:
481
+ env["exiting"] = True
474
482
  with self._lock:
475
- if not self._unreported["count"]:
476
- return {"items": items}
477
- return {"items": items, "dropped": {"count": self._unreported["count"], "by_reason": dict(self._unreported["by_reason"])}}
483
+ if self._unreported["count"]:
484
+ env["dropped"] = {"count": self._unreported["count"], "by_reason": dict(self._unreported["by_reason"])}
485
+ return env
478
486
 
479
487
  def _reported(self) -> None:
480
488
  with self._lock:
@@ -561,6 +569,7 @@ class Sender:
561
569
  self._sleep(wait)
562
570
 
563
571
  def _atexit(self) -> None:
572
+ self._exiting = True
564
573
  try:
565
574
  self.flush(self._o["exit_flush_s"])
566
575
  except Exception:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trodo-python
3
- Version: 3.0.3
3
+ Version: 3.0.4
4
4
  Summary: Trodo Analytics SDK for Python — server-side event tracking
5
5
  License: ISC
6
6
  Keywords: analytics,tracking,trodo,server-side
@@ -1,5 +1,5 @@
1
1
  trodo/__init__.py,sha256=b6NdLadR5zQ_wPNLhHXFGLJgoDNNeaI9iNpeSoG9sdw,27118
2
- trodo/_version.py,sha256=mHUYAxoRGG4Dl3kgX7AySWcAjRVyw9veTe7GVztx0Zk,22
2
+ trodo/_version.py,sha256=y0TahmkeA2lcQvDmzzINYsMfnygwWPlG5FpphC5u4sc,22
3
3
  trodo/client.py,sha256=eaZtHMtOI-VLgfoqM_KVWMuP_I5Ivs7VFnR0oU96Yqk,23743
4
4
  trodo/types.py,sha256=eySgUvCXROG2TxtxgiU0MNr5iH0DEcduK8bmYtTKG44,3138
5
5
  trodo/user_context.py,sha256=uHCI2WYoOI3cNwdIUEuZdX4VYSu14pzm348ksn6hn_c,8195
@@ -12,7 +12,7 @@ trodo/api/management.py,sha256=uwhr0ZI1pvguz5-itW1KcgRj0TXM2n4KDa-hGIaBdTA,4023
12
12
  trodo/auto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  trodo/auto/auto_event_manager.py,sha256=cztuRsRkNoJE5R4NfSfTrTJTGl4jx2Yb-Ncy0aVAPo8,4247
14
14
  trodo/delivery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- trodo/delivery/sender.py,sha256=l3itziOJ3-DRRir9-zL7LPf36npzM-whZXzkNbwHuW4,27802
15
+ trodo/delivery/sender.py,sha256=H57Yi7rZBq8mC85P0nAFR0Pk7ebjSG67ktoChNC0HEg,28304
16
16
  trodo/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  trodo/managers/dataset_manager.py,sha256=HTFszK-wKmwjW-aw7xJWr5EKvDpJ_om496MLDr3gelg,13920
18
18
  trodo/managers/group_manager.py,sha256=ki3Se3qEoSZfREX63oeDeBmEfZF-ISHLE8azEtLg0tM,3542
@@ -40,7 +40,7 @@ trodo/session/server_session.py,sha256=McsudEiq33XDq3nqxgzBcUvIjQxCMscwEuAPnYXrT
40
40
  trodo/session/session_manager.py,sha256=7ht5LeeZX1HLLfPeNV_a8NkXGbHl3up0CRtCGr3EzjQ,2995
41
41
  trodo/util/__init__.py,sha256=Z9c4rPPdKg06Kk3byKheDqksSgR4WNvS475oQ5sNljc,54
42
42
  trodo/util/lru.py,sha256=QIsM7s6J_E9ZjiXatSyReZIEeGypTAcgrPWWy8YsRa4,2465
43
- trodo_python-3.0.3.dist-info/METADATA,sha256=efWaheZ0wohogmc70u4LjB59TDMqVLKL5wF8w9okSok,25307
44
- trodo_python-3.0.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
45
- trodo_python-3.0.3.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
46
- trodo_python-3.0.3.dist-info/RECORD,,
43
+ trodo_python-3.0.4.dist-info/METADATA,sha256=NKqJ4bcclLdVo-9rehbHYr2jdpzJWaiKK-VxUv8QR0s,25307
44
+ trodo_python-3.0.4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
45
+ trodo_python-3.0.4.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
46
+ trodo_python-3.0.4.dist-info/RECORD,,