Skip to content

Commit bdf3019

Browse files
authored
fix: metric to show tool distribution (#1090)
1 parent 9919654 commit bdf3019

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,10 @@ export class AgenticChatController implements ChatHandlers {
659659
})
660660
break
661661
}
662+
663+
if (toolUse.name) {
664+
this.#telemetryController.emitToolUseSuggested(toolUse, session.conversationId || '')
665+
}
662666
} catch (err) {
663667
if (loadingMessageId) {
664668
await chatResultStream.removeResultBlock(loadingMessageId)

server/aws-lsp-codewhisperer/src/language-server/chat/telemetry/chatTelemetryController.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
RelevancyVoteType,
1515
isClientTelemetryEvent,
1616
} from './clientTelemetry'
17-
import { UserIntent } from '@amzn/codewhisperer-streaming'
17+
import { ToolUse, UserIntent } from '@amzn/codewhisperer-streaming'
1818
import { TriggerContext } from '../contexts/triggerContext'
1919

2020
import { CredentialsProvider, Logging } from '@aws/language-server-runtimes/server-interface'
@@ -168,6 +168,19 @@ export class ChatTelemetryController {
168168
}
169169
}
170170

171+
public emitToolUseSuggested(toolUse: ToolUse, conversationId: string) {
172+
this.#telemetry.emitMetric({
173+
name: ChatTelemetryEventName.ToolUseSuggested,
174+
data: {
175+
[CONVERSATION_ID_METRIC_KEY]: conversationId,
176+
cwsprChatConversationType: 'AgenticChatWithToolUse',
177+
credentialStartUrl: this.#credentialsProvider.getConnectionMetadata()?.sso?.startUrl,
178+
cwsprToolName: toolUse.name ?? '',
179+
cwsprToolUseId: toolUse.toolUseId ?? '',
180+
},
181+
})
182+
}
183+
171184
public emitAddMessageMetric(tabId: string, metric: Partial<CombinedConversationEvent>) {
172185
const conversationId = this.getConversationId(tabId)
173186
// Store the customization value associated with the message

server/aws-lsp-codewhisperer/src/shared/telemetry/types.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export enum ChatTelemetryEventName {
165165
RunCommand = 'amazonq_runCommand',
166166
MessageResponseError = 'amazonq_messageResponseError',
167167
ModifyCode = 'amazonq_modifyCode',
168+
ToolUseSuggested = 'amazonq_toolUseSuggested',
168169
}
169170

170171
export interface ChatTelemetryEventMap {
@@ -178,6 +179,15 @@ export interface ChatTelemetryEventMap {
178179
[ChatTelemetryEventName.RunCommand]: RunCommandEvent
179180
[ChatTelemetryEventName.MessageResponseError]: MessageResponseErrorEvent
180181
[ChatTelemetryEventName.ModifyCode]: ModifyCodeEvent
182+
[ChatTelemetryEventName.ToolUseSuggested]: ToolUseSuggestedEvent
183+
}
184+
185+
export type ToolUseSuggestedEvent = {
186+
credentialStartUrl?: string
187+
cwsprChatConversationId: string
188+
cwsprChatConversationType: ChatConversationType
189+
cwsprToolName: string
190+
cwsprToolUseId: string
181191
}
182192

183193
export type ModifyCodeEvent = {
@@ -242,7 +252,7 @@ export enum ChatInteractionType {
242252
ClickBodyLink = 'clickBodyLink',
243253
}
244254

245-
export type ChatConversationType = 'Chat' | 'Assign' | 'Transform' | 'AgenticChat'
255+
export type ChatConversationType = 'Chat' | 'Assign' | 'Transform' | 'AgenticChat' | 'AgenticChatWithToolUse'
246256

247257
export type InteractWithMessageEvent = {
248258
credentialStartUrl?: string

0 commit comments

Comments
 (0)