2828)
2929from testing_support .validators .validate_custom_event import validate_custom_event_count
3030from testing_support .validators .validate_custom_events import validate_custom_events
31- from testing_support .validators .validate_error_trace_attributes import (
32- validate_error_trace_attributes ,
33- )
34- from testing_support .validators .validate_transaction_metrics import (
35- validate_transaction_metrics ,
36- )
31+ from testing_support .validators .validate_error_trace_attributes import validate_error_trace_attributes
32+ from testing_support .validators .validate_transaction_metrics import validate_transaction_metrics
3733
3834from newrelic .api .background_task import background_task
3935from newrelic .api .llm_custom_attributes import WithLlmCustomAttributes
@@ -81,9 +77,13 @@ def vectorstore_events_sans_content(event):
8177 "id" : None , # UUID that changes with each run
8278 "vendor" : "langchain" ,
8379 "ingest_source" : "Python" ,
84- "metadata.source " : os . path . join ( os . path . dirname ( __file__ ), "hello.pdf" ) ,
85- "metadata.page " : 0 ,
80+ "metadata.creationdate " : "2023-02-10T00:49:47+00:00" ,
81+ "metadata.creator " : "XeTeX output 2023.02.10:0049" ,
8682 "metadata.page_label" : "1" ,
83+ "metadata.page" : 0 ,
84+ "metadata.producer" : "xdvipdfmx (20210318)" ,
85+ "metadata.source" : os .path .join (os .path .dirname (__file__ ), "hello.pdf" ),
86+ "metadata.total_pages" : 1 ,
8787 },
8888 ),
8989]
@@ -133,9 +133,7 @@ def test_vectorstore_modules_instrumented():
133133 name = "test_vectorstore:test_pdf_pagesplitter_vectorstore_in_txn" ,
134134 scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
135135 rollup_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
136- custom_metrics = [
137- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
138- ],
136+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
139137 background_task = True ,
140138)
141139@validate_attributes ("agent" , ["llm" ])
@@ -165,9 +163,7 @@ def test_pdf_pagesplitter_vectorstore_in_txn(set_trace_info, embedding_openai_cl
165163 name = "test_vectorstore:test_pdf_pagesplitter_vectorstore_in_txn_no_content" ,
166164 scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
167165 rollup_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
168- custom_metrics = [
169- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
170- ],
166+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
171167 background_task = True ,
172168)
173169@validate_attributes ("agent" , ["llm" ])
@@ -225,9 +221,7 @@ def test_pdf_pagesplitter_vectorstore_ai_monitoring_disabled(set_trace_info, emb
225221 name = "test_vectorstore:test_async_pdf_pagesplitter_vectorstore_in_txn" ,
226222 scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
227223 rollup_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
228- custom_metrics = [
229- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
230- ],
224+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
231225 background_task = True ,
232226)
233227@validate_attributes ("agent" , ["llm" ])
@@ -261,9 +255,7 @@ async def _test():
261255 name = "test_vectorstore:test_async_pdf_pagesplitter_vectorstore_in_txn_no_content" ,
262256 scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
263257 rollup_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
264- custom_metrics = [
265- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
266- ],
258+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
267259 background_task = True ,
268260)
269261@validate_attributes ("agent" , ["llm" ])
@@ -337,23 +329,20 @@ async def _test():
337329 "ingest_source" : "Python" ,
338330 "error" : True ,
339331 },
340- ),
332+ )
341333]
342334
343335
344336@reset_core_stats_engine ()
345337@validate_error_trace_attributes (
346- callable_name (AssertionError ),
347- required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []},
338+ callable_name (AssertionError ), required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []}
348339)
349340@validate_custom_events (events_with_context_attrs (vectorstore_error_events ))
350341@validate_transaction_metrics (
351342 name = "test_vectorstore:test_vectorstore_error" ,
352343 scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
353344 rollup_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
354- custom_metrics = [
355- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
356- ],
345+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
357346 background_task = True ,
358347)
359348@background_task ()
@@ -372,17 +361,14 @@ def test_vectorstore_error(set_trace_info, embedding_openai_client, loop):
372361@reset_core_stats_engine ()
373362@disabled_ai_monitoring_record_content_settings
374363@validate_error_trace_attributes (
375- callable_name (AssertionError ),
376- required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []},
364+ callable_name (AssertionError ), required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []}
377365)
378366@validate_custom_events (vectorstore_events_sans_content (vectorstore_error_events ))
379367@validate_transaction_metrics (
380368 name = "test_vectorstore:test_vectorstore_error_no_content" ,
381369 scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
382370 rollup_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
383- custom_metrics = [
384- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
385- ],
371+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
386372 background_task = True ,
387373)
388374@background_task ()
@@ -399,17 +385,14 @@ def test_vectorstore_error_no_content(set_trace_info, embedding_openai_client):
399385
400386@reset_core_stats_engine ()
401387@validate_error_trace_attributes (
402- callable_name (AssertionError ),
403- required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []},
388+ callable_name (AssertionError ), required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []}
404389)
405390@validate_custom_events (events_with_context_attrs (vectorstore_error_events ))
406391@validate_transaction_metrics (
407392 name = "test_vectorstore:test_async_vectorstore_error" ,
408393 scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
409394 rollup_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
410- custom_metrics = [
411- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
412- ],
395+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
413396 background_task = True ,
414397)
415398@background_task ()
@@ -433,17 +416,14 @@ async def _test():
433416@reset_core_stats_engine ()
434417@disabled_ai_monitoring_record_content_settings
435418@validate_error_trace_attributes (
436- callable_name (AssertionError ),
437- required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []},
419+ callable_name (AssertionError ), required_params = {"user" : ["vector_store_id" ], "intrinsic" : [], "agent" : []}
438420)
439421@validate_custom_events (vectorstore_events_sans_content (vectorstore_error_events ))
440422@validate_transaction_metrics (
441423 name = "test_vectorstore:test_async_vectorstore_error_no_content" ,
442424 scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
443425 rollup_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
444- custom_metrics = [
445- (f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 ),
446- ],
426+ custom_metrics = [(f"Supportability/Python/ML/LangChain/{ langchain .__version__ } " , 1 )],
447427 background_task = True ,
448428)
449429@background_task ()
0 commit comments