Skip to content

Commit 3b85269

Browse files
authored
telemetry(amazonq): flare is now source of truth for metrics (#7768)
## Problem In VSC, we check that the metric name must be in [aws-toolkit-common](https://github.com/aws/aws-toolkit-common) before emitting the metric. Therefore when we want to add a new metric, the current process is: 1. Add new metric in aws-toolkit-common 2. Wait for version to increment (~1 hour) 3. Bump up toolkit-common version in VSC repo 4. Wait for next VSC release (up to 1 week) Only after steps 1-4, will we be actually emitting the new metric. JB, VS, and Eclipse do not have this dependency, and assume Flare is the source of truth for metrics ## Solution In VSC, Flare is now the source of truth for metrics instead of depending on aws-toolkit-common --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent f36023f commit 3b85269

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ import {
9797
ViewDiffMessage,
9898
referenceLogText,
9999
} from 'aws-core-vscode/amazonq'
100-
import { telemetry, TelemetryBase } from 'aws-core-vscode/telemetry'
100+
import { telemetry } from 'aws-core-vscode/telemetry'
101101
import { isValidResponseError } from './error'
102102
import { decryptResponse, encryptRequest } from '../encryption'
103103
import { getCursorState } from '../utils'
@@ -144,10 +144,13 @@ export function registerLanguageServerEventListener(languageClient: LanguageClie
144144
// This passes through metric data from LSP events to Toolkit telemetry with all fields from the LSP server
145145
languageClient.onTelemetry((e) => {
146146
const telemetryName: string = e.name
147-
148-
if (telemetryName in telemetry) {
149-
languageClient.info(`[VSCode Telemetry] Emitting ${telemetryName} telemetry: ${JSON.stringify(e.data)}`)
150-
telemetry[telemetryName as keyof TelemetryBase].emit(e.data)
147+
languageClient.info(`[VSCode Telemetry] Emitting ${telemetryName} telemetry: ${JSON.stringify(e.data)}`)
148+
try {
149+
// Flare is now the source of truth for metrics instead of depending on each IDE client and toolkit-common
150+
const metric = (telemetry as any).getMetric(telemetryName)
151+
metric?.emit(e.data)
152+
} catch (error) {
153+
languageClient.warn(`[VSCode Telemetry] Failed to emit ${telemetryName}: ${error}`)
151154
}
152155
})
153156
}

0 commit comments

Comments
 (0)