Skip to content

Commit 105dcd5

Browse files
committed
simplify promise handle
1 parent 0eacc29 commit 105dcd5

File tree

1 file changed

+3
-4
lines changed
  • packages/core/src/utils/google-genai

1 file changed

+3
-4
lines changed

packages/core/src/utils/google-genai/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ function instrumentMethod<T extends unknown[], R>(
236236
if (finalOptions.recordInputs && args[0] && typeof args[0] === 'object') {
237237
addPrivateRequestAttributes(span, args[0] as Record<string, unknown>);
238238
}
239-
const result = (originalMethod as (...args: T) => R).apply(context, args);
240-
239+
const result = originalMethod.apply(context, args);
241240
// No response attributes for create (returns object of chat instance, not generated content)
242241
return result;
243242
} catch (error) {
@@ -263,8 +262,8 @@ function instrumentMethod<T extends unknown[], R>(
263262
addPrivateRequestAttributes(span, args[0] as Record<string, unknown>);
264263
}
265264

266-
const result = await Promise.resolve((originalMethod as (...args: T) => Promise<R>).apply(context, args));
267-
addResponseAttributes(span, result as GoogleGenAIResponse, finalOptions.recordOutputs);
265+
const result = await originalMethod.apply(context, args);
266+
addResponseAttributes(span, result, finalOptions.recordOutputs);
268267
return result;
269268
} catch (error) {
270269
captureException(error, {

0 commit comments

Comments
 (0)