trodo-python 3.0.4__py3-none-any.whl → 3.0.6__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/__init__.py +4 -2
- trodo/_version.py +1 -1
- trodo/client.py +4 -1
- trodo/delivery/sender.py +31 -8
- {trodo_python-3.0.4.dist-info → trodo_python-3.0.6.dist-info}/METADATA +1 -1
- {trodo_python-3.0.4.dist-info → trodo_python-3.0.6.dist-info}/RECORD +8 -8
- {trodo_python-3.0.4.dist-info → trodo_python-3.0.6.dist-info}/WHEEL +0 -0
- {trodo_python-3.0.4.dist-info → trodo_python-3.0.6.dist-info}/top_level.txt +0 -0
trodo/__init__.py
CHANGED
|
@@ -41,7 +41,7 @@ Downstream microservice (join the caller's run instead of making a new one):
|
|
|
41
41
|
|
|
42
42
|
from __future__ import annotations
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
from ._version import SDK_VERSION as __version__
|
|
45
45
|
|
|
46
46
|
from typing import Any, Callable, Dict, List, Optional, Union
|
|
47
47
|
|
|
@@ -813,8 +813,9 @@ def feedback(
|
|
|
813
813
|
feedback: Optional[str] = None,
|
|
814
814
|
distinct_id: Optional[str] = None,
|
|
815
815
|
metadata: Optional[Dict[str, Any]] = None,
|
|
816
|
+
span_id: Optional[str] = None,
|
|
816
817
|
) -> ApiResult:
|
|
817
|
-
"""Attach feedback to a
|
|
818
|
+
"""Attach feedback to a run, or with ``span_id`` to one span of it."""
|
|
818
819
|
return _get_client().feedback(
|
|
819
820
|
run_id,
|
|
820
821
|
satisfaction=satisfaction,
|
|
@@ -823,6 +824,7 @@ def feedback(
|
|
|
823
824
|
feedback=feedback,
|
|
824
825
|
distinct_id=distinct_id,
|
|
825
826
|
metadata=metadata,
|
|
827
|
+
span_id=span_id,
|
|
826
828
|
)
|
|
827
829
|
|
|
828
830
|
|
trodo/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
SDK_VERSION = "3.0.
|
|
1
|
+
SDK_VERSION = "3.0.6"
|
trodo/client.py
CHANGED
|
@@ -608,8 +608,9 @@ class TrodoClient:
|
|
|
608
608
|
feedback: Optional[str] = None,
|
|
609
609
|
distinct_id: Optional[str] = None,
|
|
610
610
|
metadata: Optional[Dict[str, Any]] = None,
|
|
611
|
+
span_id: Optional[str] = None,
|
|
611
612
|
) -> ApiResult:
|
|
612
|
-
"""Attach feedback to a
|
|
613
|
+
"""Attach feedback to a run, or with ``span_id`` to one span of it (3.0.6)."""
|
|
613
614
|
if satisfaction is None and rating is None and not (comment or feedback):
|
|
614
615
|
raise ValueError(
|
|
615
616
|
"At least one of 'satisfaction', 'rating', or 'comment' is required"
|
|
@@ -621,6 +622,8 @@ class TrodoClient:
|
|
|
621
622
|
"distinct_id": distinct_id,
|
|
622
623
|
"attributes": metadata or {},
|
|
623
624
|
}
|
|
625
|
+
if span_id:
|
|
626
|
+
payload["span_id"] = span_id
|
|
624
627
|
# Queued behind the run it belongs to (2.24): never waits on the
|
|
625
628
|
# network, survives an outage, and lands after its run.
|
|
626
629
|
self._sender.enqueue({"run_id": run_id, "feedback": payload})
|
trodo/delivery/sender.py
CHANGED
|
@@ -31,7 +31,10 @@ and PostHog have converged on (1 Oct 2026 survey):
|
|
|
31
31
|
sent while exiting (or in ``shutdown``) are marked ``exiting`` (3.0.4):
|
|
32
32
|
Trodo takes the whole batch into its backlog at once instead of storing
|
|
33
33
|
each trace while the request waits, so a short script hands over
|
|
34
|
-
hundreds of traces in its last seconds.
|
|
34
|
+
hundreds of traces in its last seconds. At exit the sender opens as many
|
|
35
|
+
requests again as ``max_in_flight`` (3.0.5): ordinary requests sent just
|
|
36
|
+
before the exit can take seconds each, and the hand-off must not wait
|
|
37
|
+
behind them.
|
|
35
38
|
- the server holds over-rate items itself (202 ``queued``) and stores them
|
|
36
39
|
at the team's rate; the sender says so on stderr once per 10 minutes.
|
|
37
40
|
- ``immediate`` mode for platforms that freeze between requests (Lambda,
|
|
@@ -134,7 +137,9 @@ class Sender:
|
|
|
134
137
|
self._not_before: float = 0.0 # backoff after a failed batch
|
|
135
138
|
self._stopped = False
|
|
136
139
|
self._flush_requested = False
|
|
137
|
-
self._in_flight = 0
|
|
140
|
+
self._in_flight = 0 # requests
|
|
141
|
+
self._in_flight_items = 0
|
|
142
|
+
self._in_flight_units = 0
|
|
138
143
|
self._stats = {"sent": 0, "dropped": 0, "dropped_by_reason": {}}
|
|
139
144
|
self._unreported = {"count": 0, "by_reason": {}}
|
|
140
145
|
self._warned_drop = False
|
|
@@ -215,7 +220,10 @@ class Sender:
|
|
|
215
220
|
|
|
216
221
|
def _ensure_thread_locked(self) -> None:
|
|
217
222
|
self._threads = [t for t in self._threads if t.is_alive()]
|
|
218
|
-
|
|
223
|
+
slots = max(1, int(self._o["max_in_flight"]))
|
|
224
|
+
if self._exiting:
|
|
225
|
+
slots *= 2 # the hand-off goes out beside requests still in flight
|
|
226
|
+
while len(self._threads) < slots:
|
|
219
227
|
t = threading.Thread(target=self._run, name=f"trodo-sender-{len(self._threads) + 1}", daemon=True)
|
|
220
228
|
self._threads.append(t)
|
|
221
229
|
t.start()
|
|
@@ -249,12 +257,17 @@ class Sender:
|
|
|
249
257
|
runs = _run_ids(batch)
|
|
250
258
|
for r in runs:
|
|
251
259
|
self._runs_in_flight[r] = self._runs_in_flight.get(r, 0) + 1
|
|
260
|
+
units = sum(_units_of(q.item) for q in batch)
|
|
252
261
|
self._in_flight += 1
|
|
262
|
+
self._in_flight_items += len(batch)
|
|
263
|
+
self._in_flight_units += units
|
|
253
264
|
try:
|
|
254
265
|
self._send_batch(batch)
|
|
255
266
|
finally:
|
|
256
267
|
with self._lock:
|
|
257
268
|
self._in_flight -= 1
|
|
269
|
+
self._in_flight_items -= len(batch)
|
|
270
|
+
self._in_flight_units -= units
|
|
258
271
|
for r in runs:
|
|
259
272
|
left = self._runs_in_flight.get(r, 1) - 1
|
|
260
273
|
if left > 0:
|
|
@@ -575,12 +588,13 @@ class Sender:
|
|
|
575
588
|
except Exception:
|
|
576
589
|
pass
|
|
577
590
|
with self._lock:
|
|
578
|
-
left = len(self._queue)
|
|
591
|
+
left = len(self._queue)
|
|
579
592
|
units = sum(_units_of(q.item) for q in self._queue)
|
|
580
|
-
|
|
581
|
-
|
|
593
|
+
unconfirmed = self._in_flight_items
|
|
594
|
+
if left or unconfirmed:
|
|
595
|
+
self._warn_undelivered(left, units, unconfirmed)
|
|
582
596
|
|
|
583
|
-
def _warn_undelivered(self, items: int, units: int) -> None:
|
|
597
|
+
def _warn_undelivered(self, items: int, units: int, unconfirmed: int = 0) -> None:
|
|
584
598
|
"""Always on stderr, whatever was said before: data is about to be lost."""
|
|
585
599
|
with self._lock:
|
|
586
600
|
rate = self._last_rate if self._paused_until and self._paused_until > self._now() else None
|
|
@@ -590,9 +604,18 @@ class Sender:
|
|
|
590
604
|
elif rate:
|
|
591
605
|
c = rate.get("ceiling")
|
|
592
606
|
why = f" The team is over its rate limit{f' ({c} units/min)' if c else ''} and Trodo could not hold more."
|
|
607
|
+
waited = f"(waited {self._o['exit_flush_s']:g} s)"
|
|
608
|
+
# Sent but unanswered: the request reached Trodo, which most likely stored it.
|
|
609
|
+
sent = f" {unconfirmed} more were sent, but Trodo had not confirmed them yet." if unconfirmed else ""
|
|
610
|
+
if not items:
|
|
611
|
+
sys.stderr.write(
|
|
612
|
+
f"[trodo-python] {unconfirmed} trace item(s) were sent, but Trodo had not confirmed them when the "
|
|
613
|
+
f"process exited {waited}. Call trodo.flush() before exiting to wait for the answer.\n"
|
|
614
|
+
)
|
|
615
|
+
return
|
|
593
616
|
sys.stderr.write(
|
|
594
617
|
f"[trodo-python] {items} trace item(s), {units} units, were NOT delivered before the process exited "
|
|
595
|
-
f"
|
|
618
|
+
f"{waited}.{sent}{why} Call trodo.flush() before exiting (it waits until they are "
|
|
596
619
|
"delivered), or raise delivery_options exit_flush_s.\n"
|
|
597
620
|
)
|
|
598
621
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
trodo/__init__.py,sha256=
|
|
2
|
-
trodo/_version.py,sha256=
|
|
3
|
-
trodo/client.py,sha256=
|
|
1
|
+
trodo/__init__.py,sha256=0x6Zrt4j0wpRaGSxvVzJW8lh_2DNRHcBiVKrMM8mUEk,27233
|
|
2
|
+
trodo/_version.py,sha256=qKwdJvcO3P8QjaYxAoRx_NCIZfhAAd-DtBQpYCR4_Wc,22
|
|
3
|
+
trodo/client.py,sha256=I6SRllM6LbEj4XPoT8UD47lRglI7jhKxgOdYKYs_x-c,23880
|
|
4
4
|
trodo/types.py,sha256=eySgUvCXROG2TxtxgiU0MNr5iH0DEcduK8bmYtTKG44,3138
|
|
5
5
|
trodo/user_context.py,sha256=uHCI2WYoOI3cNwdIUEuZdX4VYSu14pzm348ksn6hn_c,8195
|
|
6
6
|
trodo/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -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=
|
|
15
|
+
trodo/delivery/sender.py,sha256=skmmbNWQ20GxmLk4VmkZdWGQDnk7cc3bGso7X3O15Ko,29598
|
|
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.
|
|
44
|
-
trodo_python-3.0.
|
|
45
|
-
trodo_python-3.0.
|
|
46
|
-
trodo_python-3.0.
|
|
43
|
+
trodo_python-3.0.6.dist-info/METADATA,sha256=vX_4eP5iK-7twSVt1H3g-MxznSLTdbipCK9E1WJxlAg,25307
|
|
44
|
+
trodo_python-3.0.6.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
45
|
+
trodo_python-3.0.6.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
|
|
46
|
+
trodo_python-3.0.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|