From 2102c92636392a39f298415427e97602ddf5ebeb Mon Sep 17 00:00:00 2001 From: Pablo Pardo Garcia Date: Tue, 17 Nov 2026 09:30:18 +0100 Subject: [PATCH 1/2] fix: require openinference-instrumentation-anthropic 3.1.1 Releases before 3.1.1 record a second span for each call with anthropic 1.14 or later. Raise the floor in the anthropic extra and the instruments group, and drop the README advice to stay on 2.x. --- README.md | 2 +- pyproject.toml | 4 ++-- uv.lock | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 38791cc..3e994e7 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ which it already is in any project that calls Anthropic. When an instrumentation's library is missing or too old, `init()` logs a warning naming the version it needs and leaves that one integration off. For example, `openinference-instrumentation-anthropic` 3.x needs `anthropic>=1.8.0`; with -an older `anthropic`, upgrade it or keep the instrumentation on 2.x. +an older `anthropic`, upgrade it. ```python rius.init() # auto-enables installed instrumentors diff --git a/pyproject.toml b/pyproject.toml index 83c70ff..188ed97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,13 +57,13 @@ dependencies = [ # installed `mcp` would be the one place the SDK added a runtime library to a # user's environment, which is exactly what the rule above exists to prevent. openai = ["openinference-instrumentation-openai>=0.1.52"] -anthropic = ["openinference-instrumentation-anthropic>=2.1.0"] +anthropic = ["openinference-instrumentation-anthropic>=3.1.1"] langchain = ["openinference-instrumentation-langchain>=0.1.67"] llama-index = ["openinference-instrumentation-llama-index>=4.4.3"] litellm = ["openinference-instrumentation-litellm>=0.1.34"] instruments = [ "openinference-instrumentation-openai>=0.1.52", - "openinference-instrumentation-anthropic>=2.1.0", + "openinference-instrumentation-anthropic>=3.1.1", "openinference-instrumentation-langchain>=0.1.67", "openinference-instrumentation-llama-index>=4.4.3", "openinference-instrumentation-litellm>=0.1.34", diff --git a/uv.lock b/uv.lock index 4fcd2ff..f0b587a 100644 --- a/uv.lock +++ b/uv.lock @@ -1050,8 +1050,8 @@ dev = [ [package.metadata] requires-dist = [ - { name = "openinference-instrumentation-anthropic", marker = "extra == 'anthropic'", specifier = ">=2.1.0" }, - { name = "openinference-instrumentation-anthropic", marker = "extra == 'instruments'", specifier = ">=2.1.0" }, + { name = "openinference-instrumentation-anthropic", marker = "extra == 'anthropic'", specifier = ">=3.1.1" }, + { name = "openinference-instrumentation-anthropic", marker = "extra == 'instruments'", specifier = ">=3.1.1" }, { name = "openinference-instrumentation-langchain", marker = "extra == 'instruments'", specifier = ">=0.1.67" }, { name = "openinference-instrumentation-langchain", marker = "extra == 'langchain'", specifier = ">=0.1.67" }, { name = "openinference-instrumentation-litellm", marker = "extra == 'instruments'", specifier = ">=0.1.34" }, From e5acdf5e408f992aef658d0049b2ca36bfa3fa2e Mon Sep 17 00:00:00 2001 From: Pablo Pardo Garcia Date: Tue, 17 Nov 2026 09:40:12 +0100 Subject: [PATCH 2/2] fix: date the stopped anthropic SDK chat span to OpenInference 3.1.1 The 3.1.1 wheel already stops the SDK's chat span for a call it traces; 3.2.0 only added Python 3.15 support. --- tests/test_anthropic_native_span.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_anthropic_native_span.py b/tests/test_anthropic_native_span.py index 05cf096..a058097 100644 --- a/tests/test_anthropic_native_span.py +++ b/tests/test_anthropic_native_span.py @@ -7,7 +7,7 @@ and cost counted twice, a second ``error.type`` spelled ``not_found_error``, and an unflagged duplicate after ``mark_compaction()``. When rius registered that instrumentor, the SDK's chat span is exported as a plain client span. -From openinference-instrumentation-anthropic 3.2.0, OpenInference stops the +From openinference-instrumentation-anthropic 3.1.1, OpenInference stops the SDK from starting that chat span at all, so the demotion has nothing to do. These run each scenario in a fresh interpreter (``anthropic_native_span_run.py``): @@ -92,7 +92,7 @@ def _sdk_traces() -> bool: def _openinference_leaves_the_sdk_chat_span() -> bool: """Whether the SDK's chat span still starts beside OpenInference's. - From openinference-instrumentation-anthropic 3.2.0 it does not: OpenInference + From openinference-instrumentation-anthropic 3.1.1 it does not: OpenInference stops the SDK from starting a chat span for a call it traces, so there is nothing to demote. The SDK's tool-runner and other API spans still start. """ @@ -102,7 +102,7 @@ def _openinference_leaves_the_sdk_chat_span() -> bool: _NO_SDK_TRACING = "this anthropic has no tracing of its own (it starts in 1.14.0)" _SDK_CHAT_SPAN_LEFT = "this OpenInference leaves the SDK's chat span; the demotion tests cover it" _NO_SDK_CHAT_SPAN = ( - "OpenInference stops the SDK's chat span (3.2.0 on): nothing to demote; " + "OpenInference stops the SDK's chat span (3.1.1 on): nothing to demote; " "see test_openinference_that_stops_the_sdk_chat_span_leaves_one_llm_span" ) @@ -314,7 +314,7 @@ def test_bridged_to_another_sdk_each_call_still_counts_once(case: str) -> None: @pytest.mark.integration @pytest.mark.parametrize("case", [*_CASES, "compaction", "rate_limited"]) def test_openinference_that_stops_the_sdk_chat_span_leaves_one_llm_span(case: str) -> None: - # The SDK traces on its own, but OpenInference (3.2.0 on) keeps it from + # The SDK traces on its own, but OpenInference (3.1.1 on) keeps it from # starting a chat span for the calls it traces: no duplicate to demote. if not _sdk_traces(): pytest.skip(_NO_SDK_TRACING)