Skip to content

Commit bc61d38

Browse files
committed
.
1 parent 8963182 commit bc61d38

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

packages/core/src/tracing/langchain/embeddings.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { captureException } from '../../exports';
22
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
3-
import { SPAN_STATUS_ERROR } from '../../tracing';
43
import { startSpan } from '../../tracing/trace';
54
import type { SpanAttributeValue } from '../../types-hoist/span';
65
import {
@@ -81,21 +80,13 @@ export function instrumentEmbeddingMethod(
8180
op: GEN_AI_EMBEDDINGS_OPERATION_ATTRIBUTE,
8281
attributes: attributes as Record<string, SpanAttributeValue>,
8382
},
84-
async span => {
85-
try {
86-
return await Reflect.apply(target, thisArg, args);
87-
} catch (error) {
88-
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
89-
83+
() => {
84+
return (Reflect.apply(target, thisArg, args) as Promise<unknown>).then(undefined, error => {
9085
captureException(error, {
91-
mechanism: {
92-
handled: false,
93-
type: `${LANGCHAIN_ORIGIN}.embeddings_error`,
94-
},
86+
mechanism: { handled: false, type: 'auto.ai.langchain' },
9587
});
96-
9788
throw error;
98-
}
89+
});
9990
},
10091
);
10192
},

packages/core/test/lib/tracing/langchain-embeddings.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ describe('instrumentEmbeddingMethod', () => {
106106
const instance = { constructor: { name: 'OpenAIEmbeddings' }, model: 'error-model' };
107107
await expect(wrapped.call(instance, 'test')).rejects.toThrow('API error');
108108

109-
expect(capturedSpanSetStatus).toHaveBeenCalledWith({ code: 2, message: 'internal_error' });
110109
expect(captureException).toHaveBeenCalledWith(error, {
111-
mechanism: { handled: false, type: 'auto.ai.langchain.embeddings_error' },
110+
mechanism: { handled: false, type: 'auto.ai.langchain' },
112111
});
113112
});
114113

0 commit comments

Comments
 (0)