From b71f4ff648e0145fa4d4ebc403025456288860e5 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 10 Jun 2026 08:55:18 +0200 Subject: [PATCH 1/3] test: Only capture relevant telemetry --- .../integrations/anthropic/test_anthropic.py | 36 ++++---- tests/integrations/django/test_basic.py | 2 +- .../google_genai/test_google_genai.py | 6 +- .../integrations/langchain/test_langchain.py | 2 +- .../integrations/langgraph/test_langgraph.py | 32 +++---- tests/integrations/litellm/test_litellm.py | 42 ++++----- tests/integrations/openai/test_openai.py | 2 +- .../pydantic_ai/test_pydantic_ai.py | 92 +++++++++---------- tests/integrations/rq/test_rq.py | 2 +- .../rust_tracing/test_rust_tracing.py | 14 +-- 10 files changed, 115 insertions(+), 115 deletions(-) diff --git a/tests/integrations/anthropic/test_anthropic.py b/tests/integrations/anthropic/test_anthropic.py index 7526e6ad3d..75606a1d35 100644 --- a/tests/integrations/anthropic/test_anthropic.py +++ b/tests/integrations/anthropic/test_anthropic.py @@ -3300,7 +3300,7 @@ def test_exception_message_create( ) if span_streaming: - items = capture_items("event", "transaction") + items = capture_items("event") with pytest.raises(AnthropicError): client.messages.create( @@ -3495,7 +3495,7 @@ async def test_exception_message_create_async( ) if span_streaming: - items = capture_items("event", "transaction") + items = capture_items("event") with pytest.raises(AnthropicError): await client.messages.create( @@ -3768,7 +3768,7 @@ def mock_messages_create(*args, **kwargs): test_messages = [test_message] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic tx"): client.messages.create( @@ -5064,7 +5064,7 @@ def test_system_prompt_with_complex_structure( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): response = client.messages.create( @@ -5420,7 +5420,7 @@ def test_message_with_url_image( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -5492,7 +5492,7 @@ def test_message_with_file_image( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -5608,7 +5608,7 @@ def test_message_with_url_pdf( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -5680,7 +5680,7 @@ def test_message_with_file_document( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -5910,7 +5910,7 @@ def test_binary_content_not_stored_when_pii_disabled( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -5974,7 +5974,7 @@ def test_binary_content_not_stored_when_prompts_disabled( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create(max_tokens=1024, messages=messages, model="model") @@ -6035,7 +6035,7 @@ def test_cache_tokens_nonstreaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create( @@ -6117,7 +6117,7 @@ def test_input_tokens_include_cache_write_nonstreaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create( @@ -6203,7 +6203,7 @@ def test_input_tokens_include_cache_read_nonstreaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create( @@ -6295,7 +6295,7 @@ def test_input_tokens_include_cache_read_streaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client._client, @@ -6398,7 +6398,7 @@ def test_stream_messages_input_tokens_include_cache_read_streaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client._client, @@ -6485,7 +6485,7 @@ def test_input_tokens_unchanged_without_caching( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="anthropic"): client.messages.create( @@ -6565,7 +6565,7 @@ def test_cache_tokens_streaming( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client._client, @@ -6663,7 +6663,7 @@ def test_stream_messages_cache_tokens( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client._client, diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index 4ffad98ad1..a05cf0095a 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1629,7 +1629,7 @@ def test_does_not_capture_403( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("span") _, status, _ = unpack_werkzeug_response(client.get(reverse(endpoint))) assert status.lower() == "403 forbidden" diff --git a/tests/integrations/google_genai/test_google_genai.py b/tests/integrations/google_genai/test_google_genai.py index fb50c9cc7d..16c556031b 100644 --- a/tests/integrations/google_genai/test_google_genai.py +++ b/tests/integrations/google_genai/test_google_genai.py @@ -594,7 +594,7 @@ def test_error_handling( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming or stream_gen_ai_spans: - items = capture_items("event", "transaction") + items = capture_items("event") # Mock an error at the HTTP level with mock.patch.object( @@ -1800,7 +1800,7 @@ def test_embed_content_error_handling( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "event") + items = capture_items("event") # Mock an error at the HTTP level with mock.patch.object( @@ -2210,7 +2210,7 @@ async def test_async_embed_content_error_handling( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "event") + items = capture_items("event") # Mock an error at the HTTP level with mock.patch.object( diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index 6617f51103..14f57f0c0a 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -4149,7 +4149,7 @@ def test_langchain_embeddings_span_hierarchy( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") # Mock the actual API call with mock.patch.object( diff --git a/tests/integrations/langgraph/test_langgraph.py b/tests/integrations/langgraph/test_langgraph.py index db41e0e8d7..b70afe598f 100644 --- a/tests/integrations/langgraph/test_langgraph.py +++ b/tests/integrations/langgraph/test_langgraph.py @@ -170,7 +170,7 @@ def original_compile(self, *args, **kwargs): return MockCompiledGraph(self.name) if stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with patch("sentry_sdk.integrations.langgraph.StateGraph"), start_transaction(): wrapped_compile = _wrap_state_graph_compile(original_compile) @@ -299,7 +299,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -485,7 +485,7 @@ async def run_test(): return result if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = asyncio.run(run_test()) assert result is not None @@ -610,7 +610,7 @@ def original_invoke(self, *args, **kwargs): raise Exception("Graph execution failed") if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(), pytest.raises( Exception, match="Graph execution failed" @@ -681,7 +681,7 @@ async def run_error_test(): await wrapped_ainvoke(pregel, test_state) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") asyncio.run(run_error_test()) @@ -792,7 +792,7 @@ def original_invoke(self, *args, **kwargs): return {"result": "test"} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -904,7 +904,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -1028,7 +1028,7 @@ async def run_test(): return result if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = asyncio.run(run_test()) assert result is not None @@ -1151,7 +1151,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -1274,7 +1274,7 @@ async def run_test(): return result if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = asyncio.run(run_test()) assert result is not None @@ -1374,7 +1374,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -1491,7 +1491,7 @@ async def run_test(): return result if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = asyncio.run(run_test()) assert result is not None @@ -1609,7 +1609,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -1737,7 +1737,7 @@ async def run_test(): return result if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = asyncio.run(run_test()) assert result is not None @@ -1881,7 +1881,7 @@ def original_invoke(self, *args, **kwargs): return {"messages": new_messages} if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(): wrapped_invoke = _wrap_pregel_invoke(original_invoke) @@ -1980,7 +1980,7 @@ def __init__(self, content, message_type="human"): pregel = MockPregelInstance(compiled_graph) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="langgraph tx"): # Use the wrapped invoke function directly diff --git a/tests/integrations/litellm/test_litellm.py b/tests/integrations/litellm/test_litellm.py index 831bb90b13..b859dd1222 100644 --- a/tests/integrations/litellm/test_litellm.py +++ b/tests/integrations/litellm/test_litellm.py @@ -618,7 +618,7 @@ async def test_async_streaming_chat_completion( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -722,7 +722,7 @@ def test_embeddings_create( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -843,7 +843,7 @@ async def test_async_embeddings_create( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -960,7 +960,7 @@ def test_embeddings_create_with_list_input( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -1074,7 +1074,7 @@ async def test_async_embeddings_create_with_list_input( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -1188,7 +1188,7 @@ def test_embeddings_no_pii( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -1288,7 +1288,7 @@ async def test_async_embeddings_no_pii( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.embeddings._client._client, @@ -1538,7 +1538,7 @@ def test_span_origin( request_headers={"X-Stainless-Raw-Response": "true"}, ) if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") with mock.patch.object( client.completions._client._client, @@ -1645,7 +1645,7 @@ def test_multiple_providers( ) if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") with mock.patch.object( openai_client.completions._client._client, @@ -1713,7 +1713,7 @@ def test_multiple_providers( # The provider should be detected by litellm.get_llm_provider assert SPANDATA.GEN_AI_SYSTEM in span["attributes"] elif stream_gen_ai_spans: - items = capture_items("transaction") + items = capture_items("span", "transaction") with mock.patch.object( openai_client.completions._client._client, @@ -2077,7 +2077,7 @@ def test_additional_parameters( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2191,7 +2191,7 @@ async def test_async_additional_parameters( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2306,7 +2306,7 @@ def test_no_integration( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2396,7 +2396,7 @@ async def test_async_no_integration( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2479,7 +2479,7 @@ def test_response_without_usage( )() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with start_transaction(name="litellm test"): kwargs = { @@ -2655,7 +2655,7 @@ def test_binary_content_encoding_image_url( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2780,7 +2780,7 @@ async def test_async_binary_content_encoding_image_url( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -2908,7 +2908,7 @@ def test_binary_content_encoding_mixed_content( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -3022,7 +3022,7 @@ async def test_async_binary_content_encoding_mixed_content( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -3136,7 +3136,7 @@ def test_binary_content_encoding_uri_type( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, "send", @@ -3254,7 +3254,7 @@ async def test_async_binary_content_encoding_uri_type( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with mock.patch.object( client.completions._client._client, diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index dc2a046fa7..e37920628f 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -2274,7 +2274,7 @@ def test_span_status_error( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("event", "transaction", "span") + items = capture_items("event", "span") with start_transaction(name="test"): client = OpenAI(api_key="z") diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 9d84c24c71..5a834f633a 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -94,7 +94,7 @@ async def test_agent_run_async( test_agent = get_test_agent() if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") result = await test_agent.run( ["Message demonstrating the absence of truncation.", "Test input"] @@ -262,7 +262,7 @@ def failing_model(messages, info): assert spans[0]["status"] == "error" elif stream_gen_ai_spans: - items = capture_items("event", "transaction", "span") + items = capture_items("event", "span") with pytest.raises(RuntimeError, match="model exploded"): await agent.run("Test input") @@ -314,7 +314,7 @@ def test_agent_run_sync( test_agent = get_test_agent() if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") result = test_agent.run_sync( ["Message demonstrating the absence of truncation.", "Test input"] @@ -428,7 +428,7 @@ def failing_model(messages, info): assert spans[0]["status"] == "error" elif stream_gen_ai_spans: - items = capture_items("event", "transaction", "span") + items = capture_items("event", "span") with pytest.raises(RuntimeError, match="model exploded"): agent.run_sync("Test input") @@ -480,7 +480,7 @@ async def test_agent_run_stream( test_agent = get_test_agent() if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") async with test_agent.run_stream( ["Message demonstrating the absence of truncation.", "Test input"] @@ -633,7 +633,7 @@ async def test_agent_run_stream_events( test_agent = get_test_agent() if span_streaming: - items = capture_items("span") + items = capture_items("span", "transaction") if PYDANTIC_AI_VERSION > (2,): async with test_agent.run_stream_events( @@ -747,7 +747,7 @@ def add_numbers(a: int, b: int) -> int: return a + b if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = await test_agent.run("What is 5 + 3?") @@ -863,7 +863,7 @@ def add_numbers(a: int, b: int) -> float: return a + b if span_streaming or stream_gen_ai_spans: - items = capture_items("event", "transaction", "span") + items = capture_items("event", "span") result = await test_agent.run("What is 5 + 3?") @@ -1000,7 +1000,7 @@ def add_numbers(a: Annotated[int, Field(gt=0, lt=0)], b: int) -> int: return a + b if span_streaming or stream_gen_ai_spans: - items = capture_items("event", "transaction", "span") + items = capture_items("event", "span") result = None with pytest.raises(UnexpectedModelBehavior): @@ -1124,7 +1124,7 @@ def multiply(a: int, b: int) -> int: return a * b if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") async with test_agent.run_stream("What is 7 times 8?") as result: async for _ in result.stream_output(): @@ -1207,7 +1207,7 @@ async def test_model_settings( test_agent_with_settings = get_test_agent_with_settings() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent_with_settings.run("Test input") @@ -1283,7 +1283,7 @@ async def test_system_prompt_attribute( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run("Hello") @@ -1364,7 +1364,7 @@ async def test_error_handling( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") # Simple run that should succeed await agent.run("Hello") @@ -1375,7 +1375,7 @@ async def test_error_handling( assert spans[1]["is_segment"] is True assert spans[1]["status"] != "error" # Could be None or some other status elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") # Simple run that should succeed await agent.run("Hello") @@ -1426,7 +1426,7 @@ async def test_without_pii( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") test_agent = get_test_agent() await test_agent.run("Sensitive input") @@ -1491,7 +1491,7 @@ def sensitive_tool(data: str) -> str: return f"Processed: {data}" if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Use sensitive tool with private data") @@ -1553,7 +1553,7 @@ async def run_agent(input_text): return await test_agent.run(input_text) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") # Run 3 agents concurrently results = await asyncio.gather(*[run_agent(f"Input {i}") for i in range(3)]) @@ -1567,7 +1567,7 @@ async def run_agent(input_text): continue assert span["name"] == "invoke_agent test_agent" elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") # Run 3 agents concurrently results = await asyncio.gather(*[run_agent(f"Input {i}") for i in range(3)]) @@ -1636,7 +1636,7 @@ async def test_message_history( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") # First message await agent.run("Hello, I'm Alice") @@ -1703,7 +1703,7 @@ async def test_gen_ai_system( test_agent = get_test_agent() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Test input") @@ -1763,7 +1763,7 @@ async def test_include_prompts_false( test_agent = get_test_agent() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Sensitive prompt") @@ -1821,7 +1821,7 @@ async def test_include_prompts_true( test_agent = get_test_agent() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Test prompt") @@ -1884,7 +1884,7 @@ def test_tool(value: int) -> int: return value * 2 if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Use the test tool with value 5") @@ -1944,7 +1944,7 @@ async def test_include_prompts_requires_pii( test_agent = get_test_agent() if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Test prompt") @@ -2162,7 +2162,7 @@ async def test_invoke_agent_with_list_user_prompt( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") # Use a list as user prompt await agent.run(["First part", "Second part"]) @@ -2175,7 +2175,7 @@ async def test_invoke_agent_with_list_user_prompt( assert "First part" in messages_str assert "Second part" in messages_str elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") # Use a list as user prompt await agent.run(["First part", "Second part"]) @@ -2253,7 +2253,7 @@ async def test_invoke_agent_with_instructions( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run("Test input") @@ -2419,7 +2419,7 @@ async def test_usage_data_partial( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run("Test input") @@ -2474,7 +2474,7 @@ async def test_agent_data_from_scope( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") # The integration automatically sets agent in scope during execution await agent.run("Test input") @@ -2484,7 +2484,7 @@ async def test_agent_data_from_scope( assert spans[1]["name"] == "invoke_agent test_scope_agent" elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") # The integration automatically sets agent in scope during execution await agent.run("Test input") @@ -2536,7 +2536,7 @@ def tool_without_desc(x: int) -> int: return x * 2 if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Use the tool with 5") @@ -2597,7 +2597,7 @@ def calc_tool(value: int) -> int: return value + 10 if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await test_agent.run("Use calc_tool with 5") @@ -2676,7 +2676,7 @@ async def test_message_formatting_with_different_parts( ] if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run("What did I say?", message_history=history) @@ -2795,7 +2795,7 @@ async def test_agent_without_name( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") await agent.run("Test input") @@ -2804,7 +2804,7 @@ async def test_agent_without_name( assert "invoke_agent" in spans[1]["name"] elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") await agent.run("Test input") @@ -3011,7 +3011,7 @@ def test_tool(x: int) -> int: ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") # Run with history containing tool return await agent.run("Use test_tool with 5") @@ -3958,7 +3958,7 @@ async def test_binary_content_encoding_image( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"} @@ -3984,7 +3984,7 @@ async def test_binary_content_encoding_image( messages_data = _get_messages_from_span(span_data) assert _find_binary_content(messages_data, "image", "image/png") elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") with sentry_sdk.start_transaction(op="test", name="test"): span = sentry_sdk.start_span(op="test_span") @@ -4045,7 +4045,7 @@ async def test_binary_content_encoding_mixed_content( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"} @@ -4082,7 +4082,7 @@ async def test_binary_content_encoding_mixed_content( assert found_text, "Text content should be found" assert _find_binary_content(messages_data, "image", "image/jpeg") elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") with sentry_sdk.start_transaction(op="test", name="test"): span = sentry_sdk.start_span(op="test_span") @@ -4171,7 +4171,7 @@ async def test_binary_content_in_agent_run( ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run(["Analyze this image:", binary_content]) @@ -4225,7 +4225,7 @@ async def test_set_usage_data_with_cache_tokens( ) if span_streaming: - items = capture_items("span") + items = capture_items("transaction") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"} @@ -4250,7 +4250,7 @@ async def test_set_usage_data_with_cache_tokens( spans[0]["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE] == 20 ) elif stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("transaction") with sentry_sdk.start_transaction(op="test", name="test"): span = sentry_sdk.start_span(op="test_span") @@ -4352,7 +4352,7 @@ def test_image_url_base64_content_in_span( found_image = False if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") with sentry_sdk.start_transaction(op="test", name="test"): image_url = ImageUrl(url=url, **image_url_kwargs) @@ -4463,7 +4463,7 @@ async def test_invoke_agent_image_url( image_url = ImageUrl(url=url, **image_url_kwargs) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") await agent.run([image_url, "Describe this image"]) @@ -4539,7 +4539,7 @@ def multiply_numbers(a: int, b: int) -> int: ) if span_streaming or stream_gen_ai_spans: - items = capture_items("transaction", "span") + items = capture_items("span") result = await agent.run("What is 5 times 3?") assert result is not None diff --git a/tests/integrations/rq/test_rq.py b/tests/integrations/rq/test_rq.py index 9b82a31110..b32a60fd63 100644 --- a/tests/integrations/rq/test_rq.py +++ b/tests/integrations/rq/test_rq.py @@ -291,7 +291,7 @@ def test_tracing_enabled( worker = rq.SimpleWorker([queue], connection=queue.connection) if span_streaming: - items = capture_items("event", "span") + items = capture_items("span") with sentry_sdk.traces.start_span( name="custom parent", diff --git a/tests/integrations/rust_tracing/test_rust_tracing.py b/tests/integrations/rust_tracing/test_rust_tracing.py index 743ad1729d..dcd79dcc1a 100644 --- a/tests/integrations/rust_tracing/test_rust_tracing.py +++ b/tests/integrations/rust_tracing/test_rust_tracing.py @@ -83,7 +83,7 @@ def test_on_new_span_on_close( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("span") with sentry_sdk.traces.start_span(name="custom parent"): rust_tracing.new_span(RustTracingLevel.Info, 3) @@ -169,7 +169,7 @@ def test_nested_on_new_span_on_close( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("span") with sentry_sdk.traces.start_span(name="custom parent"): original_sentry_span = sentry_sdk.traces.get_current_span() @@ -343,7 +343,7 @@ def test_on_event_exception( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("event") sentry_sdk.get_isolation_scope().clear_breadcrumbs() with sentry_sdk.traces.start_span(name="custom parent"): @@ -403,7 +403,7 @@ def test_on_event_breadcrumb( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("event") sentry_sdk.get_isolation_scope().clear_breadcrumbs() with sentry_sdk.traces.start_span(name="custom parent"): @@ -458,7 +458,7 @@ def test_on_event_event( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("event") sentry_sdk.get_isolation_scope().clear_breadcrumbs() with sentry_sdk.traces.start_span(name="custom parent"): @@ -518,7 +518,7 @@ def test_on_event_ignored( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("span") sentry_sdk.get_isolation_scope().clear_breadcrumbs() with sentry_sdk.traces.start_span(name="custom parent"): @@ -578,7 +578,7 @@ def span_filter(metadata: Dict[str, object]) -> bool: _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("event", "transaction", "span") + items = capture_items("span") with sentry_sdk.traces.start_span(name="custom parent"): original_sentry_span = sentry_sdk.traces.get_current_span() From 0f8aca3830917c89194819d4fcf10305a14b93c5 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 10 Jun 2026 09:02:09 +0200 Subject: [PATCH 2/3] . --- tests/integrations/rq/test_rq.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integrations/rq/test_rq.py b/tests/integrations/rq/test_rq.py index b32a60fd63..0df5759a1e 100644 --- a/tests/integrations/rq/test_rq.py +++ b/tests/integrations/rq/test_rq.py @@ -291,7 +291,7 @@ def test_tracing_enabled( worker = rq.SimpleWorker([queue], connection=queue.connection) if span_streaming: - items = capture_items("span") + items = capture_items("event", "span") with sentry_sdk.traces.start_span( name="custom parent", @@ -302,7 +302,7 @@ def test_tracing_enabled( queue.enqueue(crashing_job, foo=None) worker.work(burst=True) - (error_event,) = (item.payload for item in items) + (error_event,) = (item.payload for item in items if item.type == "event") assert error_event["contexts"]["trace"]["trace_id"] == span.trace_id From 9bdffec88448250d9622ce294fc2d85ae5ac9b3a Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 10 Jun 2026 09:13:30 +0200 Subject: [PATCH 3/3] . --- tests/integrations/django/test_basic.py | 2 +- .../integrations/langchain/test_langchain.py | 2 +- tests/integrations/litellm/test_litellm.py | 4 ++-- .../pydantic_ai/test_pydantic_ai.py | 24 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index a05cf0095a..4ffad98ad1 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1629,7 +1629,7 @@ def test_does_not_capture_403( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("span") + items = capture_items("event", "transaction", "span") _, status, _ = unpack_werkzeug_response(client.get(reverse(endpoint))) assert status.lower() == "403 forbidden" diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index 14f57f0c0a..6617f51103 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -4149,7 +4149,7 @@ def test_langchain_embeddings_span_hierarchy( _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, ) if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") # Mock the actual API call with mock.patch.object( diff --git a/tests/integrations/litellm/test_litellm.py b/tests/integrations/litellm/test_litellm.py index b859dd1222..75735db616 100644 --- a/tests/integrations/litellm/test_litellm.py +++ b/tests/integrations/litellm/test_litellm.py @@ -1538,7 +1538,7 @@ def test_span_origin( request_headers={"X-Stainless-Raw-Response": "true"}, ) if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") with mock.patch.object( client.completions._client._client, @@ -1645,7 +1645,7 @@ def test_multiple_providers( ) if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") with mock.patch.object( openai_client.completions._client._client, diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 5a834f633a..6afeb6cc18 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -94,7 +94,7 @@ async def test_agent_run_async( test_agent = get_test_agent() if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") result = await test_agent.run( ["Message demonstrating the absence of truncation.", "Test input"] @@ -314,7 +314,7 @@ def test_agent_run_sync( test_agent = get_test_agent() if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") result = test_agent.run_sync( ["Message demonstrating the absence of truncation.", "Test input"] @@ -480,7 +480,7 @@ async def test_agent_run_stream( test_agent = get_test_agent() if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") async with test_agent.run_stream( ["Message demonstrating the absence of truncation.", "Test input"] @@ -633,7 +633,7 @@ async def test_agent_run_stream_events( test_agent = get_test_agent() if span_streaming: - items = capture_items("span", "transaction") + items = capture_items("span") if PYDANTIC_AI_VERSION > (2,): async with test_agent.run_stream_events( @@ -1364,7 +1364,7 @@ async def test_error_handling( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") # Simple run that should succeed await agent.run("Hello") @@ -1553,7 +1553,7 @@ async def run_agent(input_text): return await test_agent.run(input_text) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") # Run 3 agents concurrently results = await asyncio.gather(*[run_agent(f"Input {i}") for i in range(3)]) @@ -2162,7 +2162,7 @@ async def test_invoke_agent_with_list_user_prompt( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") # Use a list as user prompt await agent.run(["First part", "Second part"]) @@ -2474,7 +2474,7 @@ async def test_agent_data_from_scope( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") # The integration automatically sets agent in scope during execution await agent.run("Test input") @@ -2795,7 +2795,7 @@ async def test_agent_without_name( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") await agent.run("Test input") @@ -3958,7 +3958,7 @@ async def test_binary_content_encoding_image( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"} @@ -4045,7 +4045,7 @@ async def test_binary_content_encoding_mixed_content( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"} @@ -4225,7 +4225,7 @@ async def test_set_usage_data_with_cache_tokens( ) if span_streaming: - items = capture_items("transaction") + items = capture_items("span") with sentry_sdk.traces.start_span( name="test", attributes={"sentry.op": "test"}