From f7d6cbf69230ec85a8972e017efd11c4846dc6ea Mon Sep 17 00:00:00 2001 From: Beyang Liu Date: Mon, 2 Sep 2024 16:28:23 -0700 Subject: [PATCH] on empty chat streaming response, log span and trace id (#5439) --- vscode/src/completions/nodeClient.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/vscode/src/completions/nodeClient.ts b/vscode/src/completions/nodeClient.ts index 067ca5cc1a16..884642081c27 100644 --- a/vscode/src/completions/nodeClient.ts +++ b/vscode/src/completions/nodeClient.ts @@ -239,17 +239,30 @@ export class SourcegraphNodeCompletionsClient extends SourcegraphCompletionsClie // // We still want to close the request. request.on('close', () => { + const traceSpan = getActiveTraceAndSpanId() + const traceInfo = traceSpan + ? { traceId: traceSpan.traceId, spanId: traceSpan.spanId } + : undefined if (!didReceiveAnyEvent) { logError( 'SourcegraphNodeCompletionsClient', "request.on('close')", - 'Connection closed without receiving any events', + 'Connection closed without receiving any events (this may be due to an outage with the upstream LLM provider)', + `trace-and-span: ${JSON.stringify(traceInfo)}`, { verbose: { bufferText } } ) - onErrorOnce(new Error('Connection closed without receiving any events')) + onErrorOnce( + new Error( + `Connection closed without receiving any events (this may be due to an outage with the upstream LLM provider) ${JSON.stringify( + traceInfo + )}` + ) + ) } if (!didSendMessage) { - onErrorOnce(new Error('Connection unexpectedly closed')) + onErrorOnce( + new Error(`Connection unexpectedly closed: ${JSON.stringify(traceInfo)}`) + ) } })