trodo-python 2.10.6__tar.gz → 2.10.8__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-2.10.6 → trodo_python-2.10.8}/PKG-INFO +1 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/pyproject.toml +1 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/__init__.py +34 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/client.py +3 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/register.py +1 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo_python.egg-info/PKG-INFO +1 -1
- {trodo_python-2.10.6 → trodo_python-2.10.8}/README.md +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/setup.cfg +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_anon_distinct_id 2.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_anon_distinct_id.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_auto_instrument_fixes.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_cross_process_session.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_end_run.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_error_enrichment.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_llm_usage_cost.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_processor_methods.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_register_otel.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_start_run.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/tests/test_wrap_agent_unchanged.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/api/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/api/async_client.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/api/endpoints.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/api/http_client.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/auto/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/auto/auto_event_manager.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/managers/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/managers/group_manager.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/managers/people_manager.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/auto_instrument.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/context.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/helpers.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/processor.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/transport.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/otel/wrap_agent.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/queue/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/queue/batch_flusher.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/queue/event_queue.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/session/__init__.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/session/server_session.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/session/session_manager.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/types.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo/user_context.py +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo_python.egg-info/SOURCES.txt +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo_python.egg-info/dependency_links.txt +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo_python.egg-info/requires.txt +0 -0
- {trodo_python-2.10.6 → trodo_python-2.10.8}/trodo_python.egg-info/top_level.txt +0 -0
|
@@ -40,7 +40,7 @@ Downstream microservice (join the caller's run instead of making a new one):
|
|
|
40
40
|
|
|
41
41
|
from __future__ import annotations
|
|
42
42
|
|
|
43
|
-
__version__ = "2.10.
|
|
43
|
+
__version__ = "2.10.8"
|
|
44
44
|
|
|
45
45
|
from typing import Any, Callable, Dict, List, Optional, Union
|
|
46
46
|
|
|
@@ -71,6 +71,8 @@ __all__ = [
|
|
|
71
71
|
"for_user",
|
|
72
72
|
"track",
|
|
73
73
|
"identify",
|
|
74
|
+
"people_set",
|
|
75
|
+
"people_set_once",
|
|
74
76
|
"wallet_address",
|
|
75
77
|
"reset",
|
|
76
78
|
"enable_auto_events",
|
|
@@ -130,6 +132,7 @@ def init(
|
|
|
130
132
|
on_error: Optional[Any] = None,
|
|
131
133
|
debug: bool = False,
|
|
132
134
|
auto_instrument: bool = True,
|
|
135
|
+
disable_instrumentations: Optional[List[str]] = None,
|
|
133
136
|
otel_mode: str = "trodo",
|
|
134
137
|
) -> TrodoClient:
|
|
135
138
|
"""Initialise the singleton SDK instance.
|
|
@@ -138,6 +141,11 @@ def init(
|
|
|
138
141
|
Anthropic, OpenAI, LangChain, LlamaIndex, Google Generative AI and
|
|
139
142
|
any other installed opentelemetry-instrumentation-* package, so
|
|
140
143
|
LLM calls emit token/cost spans with no further code.
|
|
144
|
+
|
|
145
|
+
``disable_instrumentations`` turns OFF specific instrumentors by id
|
|
146
|
+
(e.g. ``['openai']`` when LangChain is your primary framework, to avoid
|
|
147
|
+
double-counting the same model call). Mirrors Node's
|
|
148
|
+
``disableInstrumentations``.
|
|
141
149
|
"""
|
|
142
150
|
global _client
|
|
143
151
|
_client = TrodoClient(
|
|
@@ -152,6 +160,7 @@ def init(
|
|
|
152
160
|
on_error=on_error,
|
|
153
161
|
debug=debug,
|
|
154
162
|
auto_instrument=auto_instrument,
|
|
163
|
+
disable_instrumentations=disable_instrumentations,
|
|
155
164
|
otel_mode=otel_mode,
|
|
156
165
|
)
|
|
157
166
|
return _client
|
|
@@ -219,6 +228,18 @@ def identify(identify_id: str, session_id: Optional[str] = None) -> UserContext:
|
|
|
219
228
|
return _get_client().identify(identify_id, session_id)
|
|
220
229
|
|
|
221
230
|
|
|
231
|
+
def people_set(distinct_id: str, properties: Dict[str, Any]):
|
|
232
|
+
"""Set profile properties for a user — module-level convenience mirroring
|
|
233
|
+
``trodo.people.set(distinctId, props)`` in trodo-node. Equivalent to
|
|
234
|
+
``trodo.for_user(distinct_id).people.set(properties)``."""
|
|
235
|
+
return _get_client().people_set(distinct_id, properties)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def people_set_once(distinct_id: str, properties: Dict[str, Any]):
|
|
239
|
+
"""set_once variant of :func:`people_set` — only fills missing keys."""
|
|
240
|
+
return _get_client().people_set_once(distinct_id, properties)
|
|
241
|
+
|
|
242
|
+
|
|
222
243
|
def wallet_address(distinct_id: str, wallet_addr: str) -> WalletAddressResult:
|
|
223
244
|
return _get_client().wallet_address(distinct_id, wallet_addr)
|
|
224
245
|
|
|
@@ -400,6 +421,7 @@ def llm(
|
|
|
400
421
|
provider: Optional[str] = None,
|
|
401
422
|
temperature: Optional[float] = None,
|
|
402
423
|
extract_usage: Optional[Callable[[Any], Any]] = None,
|
|
424
|
+
extract_usage_map: Optional[Callable[[Any], Optional[Dict[str, float]]]] = None,
|
|
403
425
|
) -> Any:
|
|
404
426
|
"""Wrap an LLM call — auto-captures tokens from OpenAI/Anthropic/Gemini
|
|
405
427
|
response shapes. Dual-form helper and decorator."""
|
|
@@ -411,6 +433,7 @@ def llm(
|
|
|
411
433
|
provider=provider,
|
|
412
434
|
temperature=temperature,
|
|
413
435
|
extract_usage=extract_usage,
|
|
436
|
+
extract_usage_map=extract_usage_map,
|
|
414
437
|
)
|
|
415
438
|
|
|
416
439
|
|
|
@@ -448,6 +471,11 @@ def track_llm_call(
|
|
|
448
471
|
provider: Optional[str] = None,
|
|
449
472
|
input_tokens: Optional[int] = None,
|
|
450
473
|
output_tokens: Optional[int] = None,
|
|
474
|
+
cache_read_tokens: Optional[int] = None,
|
|
475
|
+
cache_write_tokens: Optional[int] = None,
|
|
476
|
+
usage_details: Optional[Dict[str, float]] = None,
|
|
477
|
+
usage: Any = None,
|
|
478
|
+
cost_details: Optional[Dict[str, float]] = None,
|
|
451
479
|
prompt: Any = None,
|
|
452
480
|
completion: Any = None,
|
|
453
481
|
temperature: Optional[float] = None,
|
|
@@ -462,6 +490,11 @@ def track_llm_call(
|
|
|
462
490
|
provider=provider,
|
|
463
491
|
input_tokens=input_tokens,
|
|
464
492
|
output_tokens=output_tokens,
|
|
493
|
+
cache_read_tokens=cache_read_tokens,
|
|
494
|
+
cache_write_tokens=cache_write_tokens,
|
|
495
|
+
usage_details=usage_details,
|
|
496
|
+
usage=usage,
|
|
497
|
+
cost_details=cost_details,
|
|
465
498
|
prompt=prompt,
|
|
466
499
|
completion=completion,
|
|
467
500
|
temperature=temperature,
|
|
@@ -57,6 +57,7 @@ class TrodoClient:
|
|
|
57
57
|
on_error: Optional[Any] = None,
|
|
58
58
|
debug: bool = False,
|
|
59
59
|
auto_instrument: bool = True,
|
|
60
|
+
disable_instrumentations: Optional[List[str]] = None,
|
|
60
61
|
otel_mode: str = "trodo",
|
|
61
62
|
) -> None:
|
|
62
63
|
if not site_id:
|
|
@@ -100,13 +101,14 @@ class TrodoClient:
|
|
|
100
101
|
import os
|
|
101
102
|
if os.environ.get("TRODO_LEGACY_INIT") == "1":
|
|
102
103
|
# Pre-2.4 escape hatch for one minor version.
|
|
103
|
-
enable_auto_instrument(self._span_processor)
|
|
104
|
+
enable_auto_instrument(self._span_processor, disable=disable_instrumentations)
|
|
104
105
|
else:
|
|
105
106
|
_register_otel(
|
|
106
107
|
site_id=site_id,
|
|
107
108
|
processor=self._span_processor,
|
|
108
109
|
mode=otel_mode,
|
|
109
110
|
endpoint=api_base,
|
|
111
|
+
disable_instrumentations=disable_instrumentations,
|
|
110
112
|
)
|
|
111
113
|
|
|
112
114
|
def _get_span_processor(self) -> TrodoSpanProcessor:
|
|
@@ -93,7 +93,7 @@ def register_otel(
|
|
|
93
93
|
endpoint = (endpoint or "https://sdkapi.trodo.ai").rstrip("/")
|
|
94
94
|
|
|
95
95
|
if mode == "trodo":
|
|
96
|
-
active = enable_auto_instrument(processor)
|
|
96
|
+
active = enable_auto_instrument(processor, disable=disable_instrumentations)
|
|
97
97
|
elif mode == "otlp":
|
|
98
98
|
active = _setup_otlp_mode(
|
|
99
99
|
site_id=site_id,
|
|
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
|