File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed
packages/instrumentation-openai/src Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -537,21 +537,23 @@ export class OpenAIInstrumentation extends InstrumentationBase {
537537 ) : APIPromise < T > {
538538 return new APIPromise < T > (
539539 new Promise ( ( resolve , reject ) => {
540- promise . _thenUnwrap ( ( result ) => {
541- const data = version === "v3" ? ( result as any ) . data : result ;
542-
543- this . _endSpan ( { type, span, result : data as any } ) ;
544- return result ;
545- } ) . catch ( ( error : Error ) => {
546- span . setStatus ( {
547- code : SpanStatusCode . ERROR ,
548- message : error . message ,
540+ promise
541+ . _thenUnwrap ( ( result ) => {
542+ const data = version === "v3" ? ( result as any ) . data : result ;
543+
544+ this . _endSpan ( { type, span, result : data as any } ) ;
545+ return result ;
546+ } )
547+ . catch ( ( error : Error ) => {
548+ span . setStatus ( {
549+ code : SpanStatusCode . ERROR ,
550+ message : error . message ,
551+ } ) ;
552+ span . recordException ( error ) ;
553+ span . end ( ) ;
554+ throw error ;
549555 } ) ;
550- span . recordException ( error ) ;
551- span . end ( ) ;
552- throw error ;
553- } )
554- } )
556+ } ) ,
555557 ) ;
556558 }
557559
You can’t perform that action at this time.
0 commit comments