28
28
)
29
29
from testing_support .validators .validate_custom_event import validate_custom_event_count
30
30
from 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
37
33
38
34
from newrelic .api .background_task import background_task
39
35
from newrelic .api .llm_custom_attributes import WithLlmCustomAttributes
@@ -81,9 +77,13 @@ def vectorstore_events_sans_content(event):
81
77
"id" : None , # UUID that changes with each run
82
78
"vendor" : "langchain" ,
83
79
"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" ,
86
82
"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 ,
87
87
},
88
88
),
89
89
]
@@ -133,9 +133,7 @@ def test_vectorstore_modules_instrumented():
133
133
name = "test_vectorstore:test_pdf_pagesplitter_vectorstore_in_txn" ,
134
134
scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
135
135
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 )],
139
137
background_task = True ,
140
138
)
141
139
@validate_attributes ("agent" , ["llm" ])
@@ -165,9 +163,7 @@ def test_pdf_pagesplitter_vectorstore_in_txn(set_trace_info, embedding_openai_cl
165
163
name = "test_vectorstore:test_pdf_pagesplitter_vectorstore_in_txn_no_content" ,
166
164
scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
167
165
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 )],
171
167
background_task = True ,
172
168
)
173
169
@validate_attributes ("agent" , ["llm" ])
@@ -225,9 +221,7 @@ def test_pdf_pagesplitter_vectorstore_ai_monitoring_disabled(set_trace_info, emb
225
221
name = "test_vectorstore:test_async_pdf_pagesplitter_vectorstore_in_txn" ,
226
222
scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
227
223
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 )],
231
225
background_task = True ,
232
226
)
233
227
@validate_attributes ("agent" , ["llm" ])
@@ -261,9 +255,7 @@ async def _test():
261
255
name = "test_vectorstore:test_async_pdf_pagesplitter_vectorstore_in_txn_no_content" ,
262
256
scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
263
257
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 )],
267
259
background_task = True ,
268
260
)
269
261
@validate_attributes ("agent" , ["llm" ])
@@ -337,23 +329,20 @@ async def _test():
337
329
"ingest_source" : "Python" ,
338
330
"error" : True ,
339
331
},
340
- ),
332
+ )
341
333
]
342
334
343
335
344
336
@reset_core_stats_engine ()
345
337
@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" : []}
348
339
)
349
340
@validate_custom_events (events_with_context_attrs (vectorstore_error_events ))
350
341
@validate_transaction_metrics (
351
342
name = "test_vectorstore:test_vectorstore_error" ,
352
343
scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
353
344
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 )],
357
346
background_task = True ,
358
347
)
359
348
@background_task ()
@@ -372,17 +361,14 @@ def test_vectorstore_error(set_trace_info, embedding_openai_client, loop):
372
361
@reset_core_stats_engine ()
373
362
@disabled_ai_monitoring_record_content_settings
374
363
@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" : []}
377
365
)
378
366
@validate_custom_events (vectorstore_events_sans_content (vectorstore_error_events ))
379
367
@validate_transaction_metrics (
380
368
name = "test_vectorstore:test_vectorstore_error_no_content" ,
381
369
scoped_metrics = [("Llm/vectorstore/LangChain/similarity_search" , 1 )],
382
370
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 )],
386
372
background_task = True ,
387
373
)
388
374
@background_task ()
@@ -399,17 +385,14 @@ def test_vectorstore_error_no_content(set_trace_info, embedding_openai_client):
399
385
400
386
@reset_core_stats_engine ()
401
387
@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" : []}
404
389
)
405
390
@validate_custom_events (events_with_context_attrs (vectorstore_error_events ))
406
391
@validate_transaction_metrics (
407
392
name = "test_vectorstore:test_async_vectorstore_error" ,
408
393
scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
409
394
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 )],
413
396
background_task = True ,
414
397
)
415
398
@background_task ()
@@ -433,17 +416,14 @@ async def _test():
433
416
@reset_core_stats_engine ()
434
417
@disabled_ai_monitoring_record_content_settings
435
418
@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" : []}
438
420
)
439
421
@validate_custom_events (vectorstore_events_sans_content (vectorstore_error_events ))
440
422
@validate_transaction_metrics (
441
423
name = "test_vectorstore:test_async_vectorstore_error_no_content" ,
442
424
scoped_metrics = [("Llm/vectorstore/LangChain/asimilarity_search" , 1 )],
443
425
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 )],
447
427
background_task = True ,
448
428
)
449
429
@background_task ()
0 commit comments