trodo-python 2.23.2__py3-none-any.whl → 2.23.3__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/otel/auto_instrument.py +45 -0
- {trodo_python-2.23.2.dist-info → trodo_python-2.23.3.dist-info}/METADATA +1 -1
- {trodo_python-2.23.2.dist-info → trodo_python-2.23.3.dist-info}/RECORD +5 -5
- {trodo_python-2.23.2.dist-info → trodo_python-2.23.3.dist-info}/WHEEL +0 -0
- {trodo_python-2.23.2.dist-info → trodo_python-2.23.3.dist-info}/top_level.txt +0 -0
trodo/otel/auto_instrument.py
CHANGED
|
@@ -554,6 +554,33 @@ def _register_instrumentors() -> None:
|
|
|
554
554
|
]
|
|
555
555
|
|
|
556
556
|
|
|
557
|
+
# Framework instrumentors that call a provider client we ALSO instrument.
|
|
558
|
+
#
|
|
559
|
+
# langchain-openai depends on the `openai` package, langchain-anthropic on
|
|
560
|
+
# `anthropic` -- so one chain invocation is also a genuine provider client call.
|
|
561
|
+
# With both instrumentors registered that single call emits TWO sibling llm
|
|
562
|
+
# spans carrying the same tokens, and the run's totals come out doubled.
|
|
563
|
+
# Measured on the Node side against real traffic: a 45/2 call reported 90/4.
|
|
564
|
+
#
|
|
565
|
+
# The provider span is the better of the two: it carries the real model id, so
|
|
566
|
+
# it can be priced, while the framework's reported model=unknown and could not
|
|
567
|
+
# be. So the framework instrumentor defers.
|
|
568
|
+
#
|
|
569
|
+
# Only providers registered BEFORE the framework in _INSTRUMENTORS may appear
|
|
570
|
+
# here -- the check reads `active`, which is built in registration order. That
|
|
571
|
+
# order is anthropic, openai, openai_v2, langchain, ... so those are covered;
|
|
572
|
+
# listing bedrock or cohere would read correctly and never fire.
|
|
573
|
+
_ROUTES_THROUGH: dict[str, tuple[str, ...]] = {
|
|
574
|
+
"langchain": ("openai", "openai_v2", "anthropic"),
|
|
575
|
+
"llama_index": ("openai", "openai_v2", "anthropic"),
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def _superseding_providers(name: str, active: List[str]) -> List[str]:
|
|
580
|
+
"""Provider instrumentors already active that `name` would double-count."""
|
|
581
|
+
return [p for p in _ROUTES_THROUGH.get(name, ()) if p in active]
|
|
582
|
+
|
|
583
|
+
|
|
557
584
|
def enable_auto_instrument(
|
|
558
585
|
processor: TrodoSpanProcessor,
|
|
559
586
|
disable: Optional[Iterable[str]] = None,
|
|
@@ -590,6 +617,24 @@ def enable_auto_instrument(
|
|
|
590
617
|
for name, register in _INSTRUMENTORS:
|
|
591
618
|
if name in disabled:
|
|
592
619
|
continue
|
|
620
|
+
# BEFORE registering: a framework instrumentor whose model calls are
|
|
621
|
+
# already captured by an active provider instrumentor would double every
|
|
622
|
+
# token. Checked here rather than after, because instrumentors patch on
|
|
623
|
+
# instrument() and undoing it afterwards is too late.
|
|
624
|
+
superseded = _superseding_providers(name, active)
|
|
625
|
+
if superseded:
|
|
626
|
+
_warn_once(
|
|
627
|
+
f"superseded-{name}",
|
|
628
|
+
f"auto-instrument: '{name}' was NOT loaded because "
|
|
629
|
+
f"{', '.join(superseded)} instrumentation is already active and "
|
|
630
|
+
f"{name} calls those clients directly -- running both makes one "
|
|
631
|
+
f"model call emit two llm spans and doubles its tokens and cost. "
|
|
632
|
+
f"Your {name} calls are still captured, by the provider "
|
|
633
|
+
f"instrumentation, which also records the real model id so the "
|
|
634
|
+
f"span can be priced. To choose the other way round, pass "
|
|
635
|
+
f"disable=['{superseded[0]}'].",
|
|
636
|
+
)
|
|
637
|
+
continue
|
|
593
638
|
try:
|
|
594
639
|
register()
|
|
595
640
|
active.append(name)
|
|
@@ -16,7 +16,7 @@ trodo/managers/people_manager.py,sha256=mMVnx40Mlifx6NGgChvohC9ViK6dQu2mkXNHbV8p
|
|
|
16
16
|
trodo/managers/prompt_manager.py,sha256=qFVHgh7PW-SlgHp62ybirdYsJBg-fcQVMTTU3jPqFvo,13435
|
|
17
17
|
trodo/managers/user_manager.py,sha256=faJYX3CHrD7ulYiShV7FhThSMX9aJ3kdOgU4Qtdy5FM,2844
|
|
18
18
|
trodo/otel/__init__.py,sha256=yiRFXWUU45bAM2CV37XeO7zf1hmnmjufdP4XO50yEyE,624
|
|
19
|
-
trodo/otel/auto_instrument.py,sha256=
|
|
19
|
+
trodo/otel/auto_instrument.py,sha256=I_F3NCvc0JML2UpX9PaxFM3OGzMSuEYYfxZYTwkQDuo,26224
|
|
20
20
|
trodo/otel/context.py,sha256=Jd0aTc0Q-1dM5kXXinhZD8YtnpdKgvneNiODyboVGKY,1418
|
|
21
21
|
trodo/otel/helpers.py,sha256=XOMWcgZHaq5SQbkFxDaXPE4CDFjn01xjJmJ1vIxvwpw,20730
|
|
22
22
|
trodo/otel/processor.py,sha256=LKlXxP3BeQ7DP8SzYAgXZZOeJ6-6b7e43i19gCUC_0Y,7939
|
|
@@ -36,7 +36,7 @@ trodo/session/server_session.py,sha256=McsudEiq33XDq3nqxgzBcUvIjQxCMscwEuAPnYXrT
|
|
|
36
36
|
trodo/session/session_manager.py,sha256=7ht5LeeZX1HLLfPeNV_a8NkXGbHl3up0CRtCGr3EzjQ,2995
|
|
37
37
|
trodo/util/__init__.py,sha256=Z9c4rPPdKg06Kk3byKheDqksSgR4WNvS475oQ5sNljc,54
|
|
38
38
|
trodo/util/lru.py,sha256=QIsM7s6J_E9ZjiXatSyReZIEeGypTAcgrPWWy8YsRa4,2465
|
|
39
|
-
trodo_python-2.23.
|
|
40
|
-
trodo_python-2.23.
|
|
41
|
-
trodo_python-2.23.
|
|
42
|
-
trodo_python-2.23.
|
|
39
|
+
trodo_python-2.23.3.dist-info/METADATA,sha256=Jim05wcQ2OduKmnK4NYi19Hp3fFf2FrD8E575KKzShc,25308
|
|
40
|
+
trodo_python-2.23.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
41
|
+
trodo_python-2.23.3.dist-info/top_level.txt,sha256=VCQu1CJWFmNsqTs1YxMcw4Mq35Tc3z3uI9RwHEXAayQ,6
|
|
42
|
+
trodo_python-2.23.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|