@@ -50,15 +50,15 @@ describe('wrapEmbeddingMethod', () => {
5050
5151 it ( 'creates a span with correct attributes for embedQuery' , async ( ) => {
5252 const original = vi . fn ( ) . mockResolvedValue ( [ 0.1 , 0.2 , 0.3 ] ) ;
53- const wrapped = wrapEmbeddingMethod ( original , 'embed' ) ;
53+ const wrapped = wrapEmbeddingMethod ( original ) ;
5454
5555 const instance = { constructor : { name : 'OpenAIEmbeddings' } , model : 'text-embedding-3-small' , dimensions : 1536 } ;
5656 await wrapped . call ( instance , 'Hello world' ) ;
5757
5858 expect ( capturedSpanConfig ) . toBeDefined ( ) ;
59- expect ( capturedSpanConfig ! . name ) . toBe ( 'embed text-embedding-3-small' ) ;
59+ expect ( capturedSpanConfig ! . name ) . toBe ( 'embeddings text-embedding-3-small' ) ;
6060 expect ( capturedSpanConfig ! . op ) . toBe ( GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE ) ;
61- expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embed ' ) ;
61+ expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embeddings ' ) ;
6262 expect ( capturedSpanConfig ! . attributes [ GEN_AI_REQUEST_MODEL_ATTRIBUTE ] ) . toBe ( 'text-embedding-3-small' ) ;
6363 expect ( capturedSpanConfig ! . attributes [ GEN_AI_SYSTEM_ATTRIBUTE ] ) . toBe ( 'openai' ) ;
6464 expect ( capturedSpanConfig ! . attributes [ GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE ] ) . toBe ( 1536 ) ;
@@ -67,20 +67,20 @@ describe('wrapEmbeddingMethod', () => {
6767
6868 it ( 'creates a span with correct attributes for embedDocuments' , async ( ) => {
6969 const original = vi . fn ( ) . mockResolvedValue ( [ [ 0.1 ] , [ 0.2 ] ] ) ;
70- const wrapped = wrapEmbeddingMethod ( original , 'embed_many' ) ;
70+ const wrapped = wrapEmbeddingMethod ( original ) ;
7171
7272 const instance = { constructor : { name : 'MistralAIEmbeddings' } , model : 'mistral-embed' , encodingFormat : 'float' } ;
7373 await wrapped . call ( instance , [ 'doc1' , 'doc2' ] ) ;
7474
75- expect ( capturedSpanConfig ! . name ) . toBe ( 'embed_many mistral-embed' ) ;
76- expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embed_many ' ) ;
75+ expect ( capturedSpanConfig ! . name ) . toBe ( 'embeddings mistral-embed' ) ;
76+ expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embeddings ' ) ;
7777 expect ( capturedSpanConfig ! . attributes [ GEN_AI_SYSTEM_ATTRIBUTE ] ) . toBe ( 'mistralai' ) ;
7878 expect ( capturedSpanConfig ! . attributes [ GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE ] ) . toBe ( 'float' ) ;
7979 } ) ;
8080
8181 it ( 'records input when recordInputs is true (string)' , async ( ) => {
8282 const original = vi . fn ( ) . mockResolvedValue ( [ 0.1 ] ) ;
83- const wrapped = wrapEmbeddingMethod ( original , 'embed' , { recordInputs : true } ) ;
83+ const wrapped = wrapEmbeddingMethod ( original , { recordInputs : true } ) ;
8484
8585 const instance = { constructor : { name : 'OpenAIEmbeddings' } , model : 'text-embedding-3-small' } ;
8686 await wrapped . call ( instance , 'Hello world' ) ;
@@ -90,7 +90,7 @@ describe('wrapEmbeddingMethod', () => {
9090
9191 it ( 'records input when recordInputs is true (array)' , async ( ) => {
9292 const original = vi . fn ( ) . mockResolvedValue ( [ [ 0.1 ] ] ) ;
93- const wrapped = wrapEmbeddingMethod ( original , 'embed_many' , { recordInputs : true } ) ;
93+ const wrapped = wrapEmbeddingMethod ( original , { recordInputs : true } ) ;
9494
9595 const instance = { constructor : { name : 'OpenAIEmbeddings' } , model : 'text-embedding-3-small' } ;
9696 await wrapped . call ( instance , [ 'doc1' , 'doc2' ] ) ;
@@ -101,7 +101,7 @@ describe('wrapEmbeddingMethod', () => {
101101 it ( 'sets error status on failure' , async ( ) => {
102102 const error = new Error ( 'API error' ) ;
103103 const original = vi . fn ( ) . mockRejectedValue ( error ) ;
104- const wrapped = wrapEmbeddingMethod ( original , 'embed' ) ;
104+ const wrapped = wrapEmbeddingMethod ( original ) ;
105105
106106 const instance = { constructor : { name : 'OpenAIEmbeddings' } , model : 'error-model' } ;
107107 await expect ( wrapped . call ( instance , 'test' ) ) . rejects . toThrow ( 'API error' ) ;
@@ -124,7 +124,7 @@ describe('wrapEmbeddingMethod', () => {
124124 ] ;
125125
126126 for ( const { className, expected } of testCases ) {
127- const wrapped = wrapEmbeddingMethod ( original , 'embed' ) ;
127+ const wrapped = wrapEmbeddingMethod ( original ) ;
128128 const instance = { constructor : { name : className } , model : 'test-model' } ;
129129 await wrapped . call ( instance , 'test' ) ;
130130
@@ -134,11 +134,11 @@ describe('wrapEmbeddingMethod', () => {
134134
135135 it ( 'handles missing instance properties gracefully' , async ( ) => {
136136 const original = vi . fn ( ) . mockResolvedValue ( [ 0.1 ] ) ;
137- const wrapped = wrapEmbeddingMethod ( original , 'embed' ) ;
137+ const wrapped = wrapEmbeddingMethod ( original ) ;
138138
139139 await wrapped . call ( { } , 'test' ) ;
140140
141- expect ( capturedSpanConfig ! . name ) . toBe ( 'embed unknown' ) ;
141+ expect ( capturedSpanConfig ! . name ) . toBe ( 'embeddings unknown' ) ;
142142 expect ( capturedSpanConfig ! . attributes [ GEN_AI_REQUEST_MODEL_ATTRIBUTE ] ) . toBe ( 'unknown' ) ;
143143 expect ( capturedSpanConfig ! . attributes [ GEN_AI_SYSTEM_ATTRIBUTE ] ) . toBeUndefined ( ) ;
144144 expect ( capturedSpanConfig ! . attributes [ GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE ] ) . toBeUndefined ( ) ;
@@ -165,13 +165,10 @@ describe('wrapLangChainEmbeddings', () => {
165165 const wrapped = wrapLangChainEmbeddings ( instance ) ;
166166 expect ( wrapped ) . toBe ( instance ) ; // Returns the same instance
167167
168- // embedQuery should be wrapped
169168 await wrapped . embedQuery ( 'test' ) ;
170- expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embed ' ) ;
169+ expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embeddings ' ) ;
171170
172- // embedDocuments should be wrapped
173171 await wrapped . embedDocuments ( [ 'doc1' ] ) ;
174- expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embed_many ' ) ;
172+ expect ( capturedSpanConfig ! . attributes [ GEN_AI_OPERATION_NAME_ATTRIBUTE ] ) . toBe ( 'embeddings ' ) ;
175173 } ) ;
176-
177174} ) ;
0 commit comments