Skip to content

Commit ed15bbc

Browse files
authored
telemetry(cwl): LiveTail metrics
## Problem Updating telemetry to accommodate changes in aws/aws-toolkit-common#932 ## Solution Update package version for telemetry. Add validation on the LogStreamFilter submenu's response for filter type. This is needed to allow the type returned from the LogStreamFilterSubmenu to be convertible to the type in the metric definition for filterPattern. In any case, this is a good validation to have since the 'menu' placeholder value isn't valid for starting a LiveTail session anyways.
1 parent 08eb59e commit ed15bbc

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"generateNonCodeFiles": "npm run generateNonCodeFiles -w packages/ --if-present"
4040
},
4141
"devDependencies": {
42-
"@aws-toolkits/telemetry": "^1.0.284",
42+
"@aws-toolkits/telemetry": "^1.0.287",
4343
"@playwright/browser-chromium": "^1.43.1",
4444
"@types/he": "^1.2.3",
4545
"@types/vscode": "^1.68.0",

packages/core/src/awsService/cloudWatchLogs/commands/tailLogGroup.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ export async function tailLogGroup(
2424
codeLensProvider: LiveTailCodeLensProvider,
2525
logData?: { regionName: string; groupName: string }
2626
): Promise<void> {
27-
await telemetry.cwlLiveTail_Start.run(async (span) => {
27+
await telemetry.cloudwatchlogs_startLiveTail.run(async (span) => {
2828
const wizard = new TailLogGroupWizard(logData)
2929
const wizardResponse = await wizard.run()
3030
if (!wizardResponse) {
3131
throw new CancellationError('user')
3232
}
33+
if (wizardResponse.logStreamFilter.type === 'menu' || wizardResponse.logStreamFilter.type === undefined) {
34+
//logstream filter wizard uses type to determine which submenu to show. 'menu' is set when no type is selected
35+
//and to show the 'menu' of selecting a type. This should not be reachable due to the picker logic, but validating in case.
36+
throw new ToolkitError(`Invalid Log Stream filter type: ${wizardResponse.logStreamFilter.type}`)
37+
}
3338
const awsCredentials = await globals.awsContext.getCredentials()
3439
if (awsCredentials === undefined) {
3540
throw new ToolkitError('Failed to start LiveTail session: credentials are undefined.')
@@ -67,8 +72,8 @@ export async function tailLogGroup(
6772
source: source,
6873
result: 'Succeeded',
6974
sessionAlreadyStarted: false,
70-
hasLogEventFilterPattern: Boolean(wizardResponse.filterPattern),
71-
logStreamFilterType: wizardResponse.logStreamFilter.type,
75+
hasTextFilter: Boolean(wizardResponse.filterPattern),
76+
filterType: wizardResponse.logStreamFilter.type,
7277
})
7378
await handleSessionStream(stream, document, session)
7479
} finally {
@@ -83,7 +88,7 @@ export function closeSession(
8388
source: string,
8489
codeLensProvider: LiveTailCodeLensProvider
8590
) {
86-
telemetry.cwlLiveTail_Stop.run((span) => {
91+
telemetry.cloudwatchlogs_stopLiveTail.run((span) => {
8792
const session = registry.get(uriToKey(sessionUri))
8893
if (session === undefined) {
8994
throw new ToolkitError(`No LiveTail session found for URI: ${uriToKey(sessionUri)}`)

0 commit comments

Comments
 (0)