Skip to content

Commit 700e8a1

Browse files
retry adding experimental option to tests
1 parent 6bf4006 commit 700e8a1

8 files changed

Lines changed: 377 additions & 20 deletions

File tree

tests/integrations/anthropic/test_anthropic.py

Lines changed: 101 additions & 12 deletions
Large diffs are not rendered by default.

tests/integrations/google_genai/test_google_genai.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def test_nonstreaming_generate_content(
130130
integrations=[GoogleGenAIIntegration(include_prompts=include_prompts)],
131131
traces_sample_rate=1.0,
132132
send_default_pii=send_default_pii,
133+
_experiments={"gen_ai_as_v2_spans": True},
133134
)
134135
items = capture_items("transaction", "span")
135136

@@ -219,6 +220,7 @@ def test_generate_content_with_system_instruction(
219220
integrations=[GoogleGenAIIntegration(include_prompts=True)],
220221
traces_sample_rate=1.0,
221222
send_default_pii=True,
223+
_experiments={"gen_ai_as_v2_spans": True},
222224
)
223225
items = capture_items("span")
224226

@@ -262,6 +264,7 @@ def test_generate_content_with_tools(sentry_init, capture_items, mock_genai_clie
262264
sentry_init(
263265
integrations=[GoogleGenAIIntegration()],
264266
traces_sample_rate=1.0,
267+
_experiments={"gen_ai_as_v2_spans": True},
265268
)
266269
items = capture_items("span")
267270

@@ -344,6 +347,7 @@ def test_tool_execution(sentry_init, capture_items):
344347
integrations=[GoogleGenAIIntegration(include_prompts=True)],
345348
traces_sample_rate=1.0,
346349
send_default_pii=True,
350+
_experiments={"gen_ai_as_v2_spans": True},
347351
)
348352
items = capture_items("span")
349353

@@ -380,6 +384,7 @@ def test_error_handling(sentry_init, capture_items, mock_genai_client):
380384
sentry_init(
381385
integrations=[GoogleGenAIIntegration()],
382386
traces_sample_rate=1.0,
387+
_experiments={"gen_ai_as_v2_spans": True},
383388
)
384389
items = capture_items("event", "transaction")
385390

@@ -411,6 +416,7 @@ def test_streaming_generate_content(sentry_init, capture_items, mock_genai_clien
411416
integrations=[GoogleGenAIIntegration(include_prompts=True)],
412417
traces_sample_rate=1.0,
413418
send_default_pii=True,
419+
_experiments={"gen_ai_as_v2_spans": True},
414420
)
415421
items = capture_items("span")
416422

@@ -527,6 +533,7 @@ def test_span_origin(sentry_init, capture_items, mock_genai_client):
527533
sentry_init(
528534
integrations=[GoogleGenAIIntegration()],
529535
traces_sample_rate=1.0,
536+
_experiments={"gen_ai_as_v2_spans": True},
530537
)
531538
items = capture_items("span", "transaction")
532539

@@ -554,6 +561,7 @@ def test_response_without_usage_metadata(sentry_init, capture_items, mock_genai_
554561
sentry_init(
555562
integrations=[GoogleGenAIIntegration()],
556563
traces_sample_rate=1.0,
564+
_experiments={"gen_ai_as_v2_spans": True},
557565
)
558566
items = capture_items("span")
559567

@@ -595,6 +603,7 @@ def test_multiple_candidates(sentry_init, capture_items, mock_genai_client):
595603
integrations=[GoogleGenAIIntegration(include_prompts=True)],
596604
traces_sample_rate=1.0,
597605
send_default_pii=True,
606+
_experiments={"gen_ai_as_v2_spans": True},
598607
)
599608
items = capture_items("span")
600609

@@ -659,6 +668,7 @@ def test_all_configuration_parameters(sentry_init, capture_items, mock_genai_cli
659668
sentry_init(
660669
integrations=[GoogleGenAIIntegration()],
661670
traces_sample_rate=1.0,
671+
_experiments={"gen_ai_as_v2_spans": True},
662672
)
663673
items = capture_items("span")
664674

@@ -698,6 +708,7 @@ def test_empty_response(sentry_init, capture_items, mock_genai_client):
698708
sentry_init(
699709
integrations=[GoogleGenAIIntegration()],
700710
traces_sample_rate=1.0,
711+
_experiments={"gen_ai_as_v2_spans": True},
701712
)
702713
items = capture_items("span")
703714

@@ -729,6 +740,7 @@ def test_response_with_different_id_fields(
729740
sentry_init(
730741
integrations=[GoogleGenAIIntegration()],
731742
traces_sample_rate=1.0,
743+
_experiments={"gen_ai_as_v2_spans": True},
732744
)
733745
items = capture_items("span")
734746

@@ -771,6 +783,7 @@ def test_tool_with_async_function(sentry_init):
771783
sentry_init(
772784
integrations=[GoogleGenAIIntegration()],
773785
traces_sample_rate=1.0,
786+
_experiments={"gen_ai_as_v2_spans": True},
774787
)
775788

776789
# Create an async tool function
@@ -793,6 +806,7 @@ def test_contents_as_none(sentry_init, capture_items, mock_genai_client):
793806
integrations=[GoogleGenAIIntegration(include_prompts=True)],
794807
traces_sample_rate=1.0,
795808
send_default_pii=True,
809+
_experiments={"gen_ai_as_v2_spans": True},
796810
)
797811
items = capture_items("span")
798812

@@ -819,6 +833,7 @@ def test_tool_calls_extraction(sentry_init, capture_items, mock_genai_client):
819833
sentry_init(
820834
integrations=[GoogleGenAIIntegration()],
821835
traces_sample_rate=1.0,
836+
_experiments={"gen_ai_as_v2_spans": True},
822837
)
823838
items = capture_items("span")
824839

@@ -905,6 +920,7 @@ def test_google_genai_message_truncation(sentry_init, capture_items, mock_genai_
905920
integrations=[GoogleGenAIIntegration(include_prompts=True)],
906921
traces_sample_rate=1.0,
907922
send_default_pii=True,
923+
_experiments={"gen_ai_as_v2_spans": True},
908924
)
909925
items = capture_items("span")
910926

@@ -980,6 +996,7 @@ def test_embed_content(
980996
integrations=[GoogleGenAIIntegration(include_prompts=include_prompts)],
981997
traces_sample_rate=1.0,
982998
send_default_pii=send_default_pii,
999+
_experiments={"gen_ai_as_v2_spans": True},
9831000
)
9841001
items = capture_items("transaction", "span")
9851002

@@ -1041,6 +1058,7 @@ def test_embed_content_string_input(sentry_init, capture_items, mock_genai_clien
10411058
integrations=[GoogleGenAIIntegration(include_prompts=True)],
10421059
traces_sample_rate=1.0,
10431060
send_default_pii=True,
1061+
_experiments={"gen_ai_as_v2_spans": True},
10441062
)
10451063
items = capture_items("span")
10461064

@@ -1087,6 +1105,7 @@ def test_embed_content_error_handling(sentry_init, capture_items, mock_genai_cli
10871105
sentry_init(
10881106
integrations=[GoogleGenAIIntegration()],
10891107
traces_sample_rate=1.0,
1108+
_experiments={"gen_ai_as_v2_spans": True},
10901109
)
10911110
items = capture_items("transaction", "event")
10921111

@@ -1120,6 +1139,7 @@ def test_embed_content_without_statistics(
11201139
sentry_init(
11211140
integrations=[GoogleGenAIIntegration()],
11221141
traces_sample_rate=1.0,
1142+
_experiments={"gen_ai_as_v2_spans": True},
11231143
)
11241144
items = capture_items("span")
11251145

@@ -1159,6 +1179,7 @@ def test_embed_content_span_origin(sentry_init, capture_items, mock_genai_client
11591179
sentry_init(
11601180
integrations=[GoogleGenAIIntegration()],
11611181
traces_sample_rate=1.0,
1182+
_experiments={"gen_ai_as_v2_spans": True},
11621183
)
11631184
items = capture_items("transaction", "span")
11641185

@@ -1199,6 +1220,7 @@ async def test_async_embed_content(
11991220
integrations=[GoogleGenAIIntegration(include_prompts=include_prompts)],
12001221
traces_sample_rate=1.0,
12011222
send_default_pii=send_default_pii,
1223+
_experiments={"gen_ai_as_v2_spans": True},
12021224
)
12031225
items = capture_items("transaction", "span")
12041226

@@ -1263,6 +1285,7 @@ async def test_async_embed_content_string_input(
12631285
integrations=[GoogleGenAIIntegration(include_prompts=True)],
12641286
traces_sample_rate=1.0,
12651287
send_default_pii=True,
1288+
_experiments={"gen_ai_as_v2_spans": True},
12661289
)
12671290
items = capture_items("span")
12681291

@@ -1312,6 +1335,7 @@ async def test_async_embed_content_error_handling(
13121335
sentry_init(
13131336
integrations=[GoogleGenAIIntegration()],
13141337
traces_sample_rate=1.0,
1338+
_experiments={"gen_ai_as_v2_spans": True},
13151339
)
13161340
items = capture_items("transaction", "event")
13171341

@@ -1346,6 +1370,7 @@ async def test_async_embed_content_without_statistics(
13461370
sentry_init(
13471371
integrations=[GoogleGenAIIntegration()],
13481372
traces_sample_rate=1.0,
1373+
_experiments={"gen_ai_as_v2_spans": True},
13491374
)
13501375
items = capture_items("span")
13511376

@@ -1388,6 +1413,7 @@ async def test_async_embed_content_span_origin(
13881413
sentry_init(
13891414
integrations=[GoogleGenAIIntegration()],
13901415
traces_sample_rate=1.0,
1416+
_experiments={"gen_ai_as_v2_spans": True},
13911417
)
13921418
items = capture_items("transaction", "span")
13931419

@@ -1419,6 +1445,7 @@ def test_generate_content_with_content_object(
14191445
integrations=[GoogleGenAIIntegration(include_prompts=True)],
14201446
traces_sample_rate=1.0,
14211447
send_default_pii=True,
1448+
_experiments={"gen_ai_as_v2_spans": True},
14221449
)
14231450
items = capture_items("span")
14241451

@@ -1455,6 +1482,7 @@ def test_generate_content_with_dict_format(
14551482
integrations=[GoogleGenAIIntegration(include_prompts=True)],
14561483
traces_sample_rate=1.0,
14571484
send_default_pii=True,
1485+
_experiments={"gen_ai_as_v2_spans": True},
14581486
)
14591487
items = capture_items("span")
14601488

@@ -1487,6 +1515,7 @@ def test_generate_content_with_file_data(sentry_init, capture_items, mock_genai_
14871515
integrations=[GoogleGenAIIntegration(include_prompts=True)],
14881516
traces_sample_rate=1.0,
14891517
send_default_pii=True,
1518+
_experiments={"gen_ai_as_v2_spans": True},
14901519
)
14911520
items = capture_items("span")
14921521

@@ -1536,6 +1565,7 @@ def test_generate_content_with_inline_data(
15361565
integrations=[GoogleGenAIIntegration(include_prompts=True)],
15371566
traces_sample_rate=1.0,
15381567
send_default_pii=True,
1568+
_experiments={"gen_ai_as_v2_spans": True},
15391569
)
15401570
items = capture_items("span")
15411571

@@ -1581,6 +1611,7 @@ def test_generate_content_with_function_response(
15811611
integrations=[GoogleGenAIIntegration(include_prompts=True)],
15821612
traces_sample_rate=1.0,
15831613
send_default_pii=True,
1614+
_experiments={"gen_ai_as_v2_spans": True},
15841615
)
15851616
items = capture_items("span")
15861617

@@ -1635,6 +1666,7 @@ def test_generate_content_with_mixed_string_and_content(
16351666
integrations=[GoogleGenAIIntegration(include_prompts=True)],
16361667
traces_sample_rate=1.0,
16371668
send_default_pii=True,
1669+
_experiments={"gen_ai_as_v2_spans": True},
16381670
)
16391671
items = capture_items("span")
16401672

@@ -1678,6 +1710,7 @@ def test_generate_content_with_part_object_directly(
16781710
integrations=[GoogleGenAIIntegration(include_prompts=True)],
16791711
traces_sample_rate=1.0,
16801712
send_default_pii=True,
1713+
_experiments={"gen_ai_as_v2_spans": True},
16811714
)
16821715
items = capture_items("span")
16831716

@@ -1716,6 +1749,7 @@ def test_generate_content_with_list_of_dicts(
17161749
integrations=[GoogleGenAIIntegration(include_prompts=True)],
17171750
traces_sample_rate=1.0,
17181751
send_default_pii=True,
1752+
_experiments={"gen_ai_as_v2_spans": True},
17191753
)
17201754
items = capture_items("span")
17211755

@@ -1752,6 +1786,7 @@ def test_generate_content_with_dict_inline_data(
17521786
integrations=[GoogleGenAIIntegration(include_prompts=True)],
17531787
traces_sample_rate=1.0,
17541788
send_default_pii=True,
1789+
_experiments={"gen_ai_as_v2_spans": True},
17551790
)
17561791
items = capture_items("span")
17571792

@@ -1796,6 +1831,7 @@ def test_generate_content_without_parts_property_inline_data(
17961831
integrations=[GoogleGenAIIntegration(include_prompts=True)],
17971832
traces_sample_rate=1.0,
17981833
send_default_pii=True,
1834+
_experiments={"gen_ai_as_v2_spans": True},
17991835
)
18001836
items = capture_items("span")
18011837

@@ -1839,6 +1875,7 @@ def test_generate_content_without_parts_property_inline_data_and_binary_data_wit
18391875
integrations=[GoogleGenAIIntegration(include_prompts=True)],
18401876
traces_sample_rate=1.0,
18411877
send_default_pii=True,
1878+
_experiments={"gen_ai_as_v2_spans": True},
18421879
)
18431880
items = capture_items("span")
18441881

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ def test_text_generation(
480480
traces_sample_rate=1.0,
481481
send_default_pii=send_default_pii,
482482
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
483+
_experiments={"gen_ai_as_v2_spans": True},
483484
)
484485
items = capture_items("transaction", "span")
485486

@@ -555,6 +556,7 @@ def test_text_generation_streaming(
555556
traces_sample_rate=1.0,
556557
send_default_pii=send_default_pii,
557558
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
559+
_experiments={"gen_ai_as_v2_spans": True},
558560
)
559561
items = capture_items("transaction", "span")
560562

@@ -631,6 +633,7 @@ def test_chat_completion(
631633
traces_sample_rate=1.0,
632634
send_default_pii=send_default_pii,
633635
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
636+
_experiments={"gen_ai_as_v2_spans": True},
634637
)
635638
items = capture_items("transaction", "span")
636639

@@ -709,6 +712,7 @@ def test_chat_completion_streaming(
709712
traces_sample_rate=1.0,
710713
send_default_pii=send_default_pii,
711714
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
715+
_experiments={"gen_ai_as_v2_spans": True},
712716
)
713717
items = capture_items("transaction", "span")
714718

@@ -779,7 +783,7 @@ def test_chat_completion_streaming(
779783
def test_chat_completion_api_error(
780784
sentry_init: "Any", capture_items: "Any", mock_hf_api_with_errors: "Any"
781785
) -> None:
782-
sentry_init(traces_sample_rate=1.0)
786+
sentry_init(traces_sample_rate=1.0, _experiments={"gen_ai_as_v2_spans": True})
783787
items = capture_items("event", "transaction", "span")
784788

785789
client = get_hf_provider_inference_client()
@@ -838,7 +842,7 @@ def test_chat_completion_api_error(
838842
def test_span_status_error(
839843
sentry_init: "Any", capture_items: "Any", mock_hf_api_with_errors: "Any"
840844
) -> None:
841-
sentry_init(traces_sample_rate=1.0)
845+
sentry_init(traces_sample_rate=1.0, _experiments={"gen_ai_as_v2_spans": True})
842846
items = capture_items("event", "transaction", "span")
843847

844848
client = get_hf_provider_inference_client()
@@ -881,6 +885,7 @@ def test_chat_completion_with_tools(
881885
traces_sample_rate=1.0,
882886
send_default_pii=send_default_pii,
883887
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
888+
_experiments={"gen_ai_as_v2_spans": True},
884889
)
885890
items = capture_items("transaction", "span")
886891

@@ -976,6 +981,7 @@ def test_chat_completion_streaming_with_tools(
976981
traces_sample_rate=1.0,
977982
send_default_pii=send_default_pii,
978983
integrations=[HuggingfaceHubIntegration(include_prompts=include_prompts)],
984+
_experiments={"gen_ai_as_v2_spans": True},
979985
)
980986
items = capture_items("transaction", "span")
981987

0 commit comments

Comments
 (0)