@@ -5166,45 +5166,6 @@ def test_langchain_embeddings_multiple_providers(
51665166 assert SPANDATA .GEN_AI_EMBEDDINGS_INPUT in span ["data" ]
51675167
51685168
5169- def test_langchain_embeddings_error_handling (sentry_init , capture_events ):
5170- """Test that errors in embeddings are properly captured."""
5171- try :
5172- from langchain_openai import OpenAIEmbeddings
5173- except ImportError :
5174- pytest .skip ("langchain_openai not installed" )
5175-
5176- sentry_init (
5177- integrations = [LangchainIntegration (include_prompts = True )],
5178- disabled_integrations = [StdlibIntegration ],
5179- traces_sample_rate = 1.0 ,
5180- send_default_pii = True ,
5181- )
5182- events = capture_events ()
5183-
5184- # Mock the API call to raise an error
5185- with mock .patch .object (
5186- OpenAIEmbeddings ,
5187- "embed_documents" ,
5188- side_effect = ValueError ("API error" ),
5189- ):
5190- embeddings = OpenAIEmbeddings (
5191- model = "text-embedding-ada-002" , openai_api_key = "test-key"
5192- )
5193-
5194- # Force setup to re-run
5195- LangchainIntegration .setup_once ()
5196-
5197- with start_transaction (name = "test_embeddings_error" ), pytest .raises (ValueError ):
5198- embeddings .embed_documents (["Test" ])
5199-
5200- # The error should be captured
5201- assert len (events ) >= 1
5202- # We should have both the transaction and potentially an error event
5203- [e for e in events if e .get ("level" ) == "error" ]
5204- # Note: errors might not be auto-captured depending on SDK settings,
5205- # but the span should still be created
5206-
5207-
52085169@pytest .mark .parametrize ("span_streaming" , [True , False ])
52095170@pytest .mark .parametrize ("stream_gen_ai_spans" , [True , False ])
52105171def test_langchain_embeddings_multiple_calls (
0 commit comments