Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
arafatkatze committed Nov 13, 2024
1 parent be28a99 commit 157f74a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions vscode/src/chat/chat-view/ChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv
message.fileName
)
break

case 'trace-exporter':
console.log("This is my span", message.myspan)
await this.sendTraceData(message.myspan)
break
case 'smartApplyAccept':
Expand Down Expand Up @@ -1818,16 +1816,22 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv

private async sendTraceData(spanData: any): Promise<void> {
try {
const endpoint = 'https://sourcegraph.test:3443/-/debug/otlp/v1/traces'
const token = 'sgp_local_4c4e7013cd91463d8a80cae0f8dc408a864a4076'
const { auth } = await currentResolvedConfig()
if (!auth.accessToken) {
logError('ChatController', 'Cannot send trace data: not authenticated')
return
}

const response = await fetch(endpoint, {
// Build trace URL the same way OpenTelemetryService does
const traceUrl = new URL('/-/debug/otlp/v1/traces', auth.serverEndpoint).toString()

const response = await fetch(traceUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `token ${token}`
...(auth.accessToken ? { 'Authorization': `token ${auth.accessToken}` } : {})
},
body: (spanData)
body: spanData
})

if (!response.ok) {
Expand Down

0 comments on commit 157f74a

Please sign in to comment.