Skip to content

Commit 43bb0ca

Browse files
test: Only capture relevant telemetry (#6547)
1 parent 50c4223 commit 43bb0ca

8 files changed

Lines changed: 99 additions & 99 deletions

File tree

tests/integrations/anthropic/test_anthropic.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,7 +3300,7 @@ def test_exception_message_create(
33003300
)
33013301

33023302
if span_streaming:
3303-
items = capture_items("event", "transaction")
3303+
items = capture_items("event")
33043304

33053305
with pytest.raises(AnthropicError):
33063306
client.messages.create(
@@ -3495,7 +3495,7 @@ async def test_exception_message_create_async(
34953495
)
34963496

34973497
if span_streaming:
3498-
items = capture_items("event", "transaction")
3498+
items = capture_items("event")
34993499

35003500
with pytest.raises(AnthropicError):
35013501
await client.messages.create(
@@ -3768,7 +3768,7 @@ def mock_messages_create(*args, **kwargs):
37683768
test_messages = [test_message]
37693769

37703770
if span_streaming or stream_gen_ai_spans:
3771-
items = capture_items("transaction", "span")
3771+
items = capture_items("span")
37723772

37733773
with start_transaction(name="anthropic tx"):
37743774
client.messages.create(
@@ -5064,7 +5064,7 @@ def test_system_prompt_with_complex_structure(
50645064
]
50655065

50665066
if span_streaming or stream_gen_ai_spans:
5067-
items = capture_items("transaction", "span")
5067+
items = capture_items("span")
50685068

50695069
with start_transaction(name="anthropic"):
50705070
response = client.messages.create(
@@ -5420,7 +5420,7 @@ def test_message_with_url_image(
54205420
]
54215421

54225422
if span_streaming or stream_gen_ai_spans:
5423-
items = capture_items("transaction", "span")
5423+
items = capture_items("span")
54245424

54255425
with start_transaction(name="anthropic"):
54265426
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -5492,7 +5492,7 @@ def test_message_with_file_image(
54925492
]
54935493

54945494
if span_streaming or stream_gen_ai_spans:
5495-
items = capture_items("transaction", "span")
5495+
items = capture_items("span")
54965496

54975497
with start_transaction(name="anthropic"):
54985498
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -5608,7 +5608,7 @@ def test_message_with_url_pdf(
56085608
]
56095609

56105610
if span_streaming or stream_gen_ai_spans:
5611-
items = capture_items("transaction", "span")
5611+
items = capture_items("span")
56125612

56135613
with start_transaction(name="anthropic"):
56145614
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -5680,7 +5680,7 @@ def test_message_with_file_document(
56805680
]
56815681

56825682
if span_streaming or stream_gen_ai_spans:
5683-
items = capture_items("transaction", "span")
5683+
items = capture_items("span")
56845684

56855685
with start_transaction(name="anthropic"):
56865686
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -5910,7 +5910,7 @@ def test_binary_content_not_stored_when_pii_disabled(
59105910
]
59115911

59125912
if span_streaming or stream_gen_ai_spans:
5913-
items = capture_items("transaction", "span")
5913+
items = capture_items("span")
59145914

59155915
with start_transaction(name="anthropic"):
59165916
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -5974,7 +5974,7 @@ def test_binary_content_not_stored_when_prompts_disabled(
59745974
]
59755975

59765976
if span_streaming or stream_gen_ai_spans:
5977-
items = capture_items("transaction", "span")
5977+
items = capture_items("span")
59785978

59795979
with start_transaction(name="anthropic"):
59805980
client.messages.create(max_tokens=1024, messages=messages, model="model")
@@ -6035,7 +6035,7 @@ def test_cache_tokens_nonstreaming(
60356035
)
60366036

60376037
if span_streaming or stream_gen_ai_spans:
6038-
items = capture_items("transaction", "span")
6038+
items = capture_items("span")
60396039

60406040
with start_transaction(name="anthropic"):
60416041
client.messages.create(
@@ -6117,7 +6117,7 @@ def test_input_tokens_include_cache_write_nonstreaming(
61176117
)
61186118

61196119
if span_streaming or stream_gen_ai_spans:
6120-
items = capture_items("transaction", "span")
6120+
items = capture_items("span")
61216121

61226122
with start_transaction(name="anthropic"):
61236123
client.messages.create(
@@ -6203,7 +6203,7 @@ def test_input_tokens_include_cache_read_nonstreaming(
62036203
)
62046204

62056205
if span_streaming or stream_gen_ai_spans:
6206-
items = capture_items("transaction", "span")
6206+
items = capture_items("span")
62076207

62086208
with start_transaction(name="anthropic"):
62096209
client.messages.create(
@@ -6295,7 +6295,7 @@ def test_input_tokens_include_cache_read_streaming(
62956295
)
62966296

62976297
if span_streaming or stream_gen_ai_spans:
6298-
items = capture_items("transaction", "span")
6298+
items = capture_items("span")
62996299

63006300
with mock.patch.object(
63016301
client._client,
@@ -6398,7 +6398,7 @@ def test_stream_messages_input_tokens_include_cache_read_streaming(
63986398
)
63996399

64006400
if span_streaming or stream_gen_ai_spans:
6401-
items = capture_items("transaction", "span")
6401+
items = capture_items("span")
64026402

64036403
with mock.patch.object(
64046404
client._client,
@@ -6485,7 +6485,7 @@ def test_input_tokens_unchanged_without_caching(
64856485
)
64866486

64876487
if span_streaming or stream_gen_ai_spans:
6488-
items = capture_items("transaction", "span")
6488+
items = capture_items("span")
64896489

64906490
with start_transaction(name="anthropic"):
64916491
client.messages.create(
@@ -6565,7 +6565,7 @@ def test_cache_tokens_streaming(
65656565
)
65666566

65676567
if span_streaming or stream_gen_ai_spans:
6568-
items = capture_items("transaction", "span")
6568+
items = capture_items("span")
65696569

65706570
with mock.patch.object(
65716571
client._client,
@@ -6663,7 +6663,7 @@ def test_stream_messages_cache_tokens(
66636663
)
66646664

66656665
if span_streaming or stream_gen_ai_spans:
6666-
items = capture_items("transaction", "span")
6666+
items = capture_items("span")
66676667

66686668
with mock.patch.object(
66696669
client._client,

tests/integrations/google_genai/test_google_genai.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def test_error_handling(
594594
_experiments={"trace_lifecycle": "stream" if span_streaming else "static"},
595595
)
596596
if span_streaming or stream_gen_ai_spans:
597-
items = capture_items("event", "transaction")
597+
items = capture_items("event")
598598

599599
# Mock an error at the HTTP level
600600
with mock.patch.object(
@@ -1800,7 +1800,7 @@ def test_embed_content_error_handling(
18001800
_experiments={"trace_lifecycle": "stream" if span_streaming else "static"},
18011801
)
18021802
if span_streaming or stream_gen_ai_spans:
1803-
items = capture_items("transaction", "event")
1803+
items = capture_items("event")
18041804

18051805
# Mock an error at the HTTP level
18061806
with mock.patch.object(
@@ -2210,7 +2210,7 @@ async def test_async_embed_content_error_handling(
22102210
)
22112211

22122212
if span_streaming or stream_gen_ai_spans:
2213-
items = capture_items("transaction", "event")
2213+
items = capture_items("event")
22142214

22152215
# Mock an error at the HTTP level
22162216
with mock.patch.object(

tests/integrations/langgraph/test_langgraph.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def original_compile(self, *args, **kwargs):
170170
return MockCompiledGraph(self.name)
171171

172172
if stream_gen_ai_spans:
173-
items = capture_items("transaction", "span")
173+
items = capture_items("span")
174174

175175
with patch("sentry_sdk.integrations.langgraph.StateGraph"), start_transaction():
176176
wrapped_compile = _wrap_state_graph_compile(original_compile)
@@ -299,7 +299,7 @@ def original_invoke(self, *args, **kwargs):
299299
return {"messages": new_messages}
300300

301301
if span_streaming or stream_gen_ai_spans:
302-
items = capture_items("transaction", "span")
302+
items = capture_items("span")
303303

304304
with start_transaction():
305305
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -485,7 +485,7 @@ async def run_test():
485485
return result
486486

487487
if span_streaming or stream_gen_ai_spans:
488-
items = capture_items("transaction", "span")
488+
items = capture_items("span")
489489

490490
result = asyncio.run(run_test())
491491
assert result is not None
@@ -610,7 +610,7 @@ def original_invoke(self, *args, **kwargs):
610610
raise Exception("Graph execution failed")
611611

612612
if span_streaming or stream_gen_ai_spans:
613-
items = capture_items("transaction", "span")
613+
items = capture_items("span")
614614

615615
with start_transaction(), pytest.raises(
616616
Exception, match="Graph execution failed"
@@ -681,7 +681,7 @@ async def run_error_test():
681681
await wrapped_ainvoke(pregel, test_state)
682682

683683
if span_streaming or stream_gen_ai_spans:
684-
items = capture_items("transaction", "span")
684+
items = capture_items("span")
685685

686686
asyncio.run(run_error_test())
687687

@@ -792,7 +792,7 @@ def original_invoke(self, *args, **kwargs):
792792
return {"result": "test"}
793793

794794
if span_streaming or stream_gen_ai_spans:
795-
items = capture_items("transaction", "span")
795+
items = capture_items("span")
796796

797797
with start_transaction():
798798
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -904,7 +904,7 @@ def original_invoke(self, *args, **kwargs):
904904
return {"messages": new_messages}
905905

906906
if span_streaming or stream_gen_ai_spans:
907-
items = capture_items("transaction", "span")
907+
items = capture_items("span")
908908

909909
with start_transaction():
910910
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -1028,7 +1028,7 @@ async def run_test():
10281028
return result
10291029

10301030
if span_streaming or stream_gen_ai_spans:
1031-
items = capture_items("transaction", "span")
1031+
items = capture_items("span")
10321032

10331033
result = asyncio.run(run_test())
10341034
assert result is not None
@@ -1151,7 +1151,7 @@ def original_invoke(self, *args, **kwargs):
11511151
return {"messages": new_messages}
11521152

11531153
if span_streaming or stream_gen_ai_spans:
1154-
items = capture_items("transaction", "span")
1154+
items = capture_items("span")
11551155

11561156
with start_transaction():
11571157
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -1274,7 +1274,7 @@ async def run_test():
12741274
return result
12751275

12761276
if span_streaming or stream_gen_ai_spans:
1277-
items = capture_items("transaction", "span")
1277+
items = capture_items("span")
12781278

12791279
result = asyncio.run(run_test())
12801280
assert result is not None
@@ -1374,7 +1374,7 @@ def original_invoke(self, *args, **kwargs):
13741374
return {"messages": new_messages}
13751375

13761376
if span_streaming or stream_gen_ai_spans:
1377-
items = capture_items("transaction", "span")
1377+
items = capture_items("span")
13781378

13791379
with start_transaction():
13801380
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -1491,7 +1491,7 @@ async def run_test():
14911491
return result
14921492

14931493
if span_streaming or stream_gen_ai_spans:
1494-
items = capture_items("transaction", "span")
1494+
items = capture_items("span")
14951495

14961496
result = asyncio.run(run_test())
14971497
assert result is not None
@@ -1609,7 +1609,7 @@ def original_invoke(self, *args, **kwargs):
16091609
return {"messages": new_messages}
16101610

16111611
if span_streaming or stream_gen_ai_spans:
1612-
items = capture_items("transaction", "span")
1612+
items = capture_items("span")
16131613

16141614
with start_transaction():
16151615
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -1737,7 +1737,7 @@ async def run_test():
17371737
return result
17381738

17391739
if span_streaming or stream_gen_ai_spans:
1740-
items = capture_items("transaction", "span")
1740+
items = capture_items("span")
17411741

17421742
result = asyncio.run(run_test())
17431743
assert result is not None
@@ -1881,7 +1881,7 @@ def original_invoke(self, *args, **kwargs):
18811881
return {"messages": new_messages}
18821882

18831883
if span_streaming or stream_gen_ai_spans:
1884-
items = capture_items("transaction", "span")
1884+
items = capture_items("span")
18851885

18861886
with start_transaction():
18871887
wrapped_invoke = _wrap_pregel_invoke(original_invoke)
@@ -1980,7 +1980,7 @@ def __init__(self, content, message_type="human"):
19801980
pregel = MockPregelInstance(compiled_graph)
19811981

19821982
if span_streaming or stream_gen_ai_spans:
1983-
items = capture_items("transaction", "span")
1983+
items = capture_items("span")
19841984

19851985
with start_transaction(name="langgraph tx"):
19861986
# Use the wrapped invoke function directly

0 commit comments

Comments
 (0)