trodo-python 3.0.3__tar.gz → 3.0.4__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.
- {trodo_python-3.0.3 → trodo_python-3.0.4}/PKG-INFO +1 -1
- {trodo_python-3.0.3 → trodo_python-3.0.4}/pyproject.toml +1 -1
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_sender.py +33 -0
- trodo_python-3.0.4/trodo/_version.py +1 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/delivery/sender.py +16 -7
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo_python.egg-info/PKG-INFO +1 -1
- trodo_python-3.0.3/trodo/_version.py +0 -1
- {trodo_python-3.0.3 → trodo_python-3.0.4}/README.md +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/setup.cfg +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_anon_distinct_id.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_auto_instrument_fixes.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_cross_process_session.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_datasets.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_end_run.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_end_run_order.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_error_enrichment.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_framework_deference.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_get_prompt_version_types.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_instrumentor_resolution.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_llm_usage_cost.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_long_runs.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_multi_agent_shape.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_processor_methods.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_prompt_fingerprint.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_prompt_trace.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_prompts.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_register_otel.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_start_run.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_user_traits.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/tests/test_wrap_agent_unchanged.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/_retry.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/async_client.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/endpoints.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/http_client.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/api/management.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/auto/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/auto/auto_event_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/client.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/delivery/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/dataset_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/group_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/people_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/prompt_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/managers/user_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/auto_instrument.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/context.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/helpers.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/processor.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/prompt_trace.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/register.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/transport.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/otel/wrap_agent.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/prompts/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/prompts/compile.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/prompts/template.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/prompts/types.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/queue/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/queue/batch_flusher.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/queue/event_queue.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/session/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/session/server_session.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/session/session_manager.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/types.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/user_context.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/util/__init__.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo/util/lru.py +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo_python.egg-info/SOURCES.txt +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo_python.egg-info/dependency_links.txt +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo_python.egg-info/requires.txt +0 -0
- {trodo_python-3.0.3 → trodo_python-3.0.4}/trodo_python.egg-info/top_level.txt +0 -0
|
@@ -388,3 +388,36 @@ def test_feedback_waits_while_its_run_is_in_flight_in_another_request():
|
|
|
388
388
|
assert sender.stats()["sent"] == 3
|
|
389
389
|
by = {("fb" if "feedback" in c["items"][0] else c["items"][0]["run"]["run_id"]): c for c in s.calls}
|
|
390
390
|
assert by["fb"]["start"] >= by["a"]["end"]
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
# ── Exit hand-off (3.0.4) ─────────────────────────────────────────────────────
|
|
395
|
+
|
|
396
|
+
def test_requests_at_exit_are_marked_exiting_and_others_are_not():
|
|
397
|
+
s = Server()
|
|
398
|
+
sender = Sender(s, **fast())
|
|
399
|
+
sender.enqueue(run("live"))
|
|
400
|
+
sender.flush(timeout_s=2)
|
|
401
|
+
sender.enqueue(run("late"))
|
|
402
|
+
sender._atexit()
|
|
403
|
+
assert "exiting" not in s.posts[0]["body"]
|
|
404
|
+
assert s.posts[1]["body"]["exiting"] is True
|
|
405
|
+
assert s.posts[1]["body"]["items"] == [run("late")]
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def test_shutdown_marks_its_requests_exiting():
|
|
409
|
+
s = Server()
|
|
410
|
+
sender = Sender(s, **fast(flush_interval_s=60.0))
|
|
411
|
+
sender.enqueue(run("a"))
|
|
412
|
+
sender.shutdown()
|
|
413
|
+
assert s.posts[0]["body"]["exiting"] is True
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_an_exit_hand_off_is_sent_and_not_called_rate_limiting(capsys):
|
|
417
|
+
handed = (200, None, {"results": [{"status": 202, "queued": True, "exit": True}]})
|
|
418
|
+
s = Server([handed])
|
|
419
|
+
sender = Sender(s, **fast())
|
|
420
|
+
sender.enqueue(run("a"))
|
|
421
|
+
sender._atexit()
|
|
422
|
+
assert sender.stats()["sent"] == 1
|
|
423
|
+
assert "rate limit" not in capsys.readouterr().err
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SDK_VERSION = "3.0.4"
|
|
@@ -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
|
|
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
|
-
|
|
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
|
|
476
|
-
|
|
477
|
-
|
|
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 +0,0 @@
|
|
|
1
|
-
SDK_VERSION = "3.0.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|