Skip to content

Commit 690135f

Browse files
keeganirbykaranA-aws
authored andcommitted
refactor(cwl): remove LiveTail setting, re-use existing CWL setting aws#5831
* Remove CWL LiveTail limit setting. Instead pulls from existing limit preference. Updated description of limit preference to describe LiveTail line trimming behavior * Rename CWL Scheme variable to fit linting rules * Bubble up exception instead of rethrowing it.
1 parent e05b4c7 commit 690135f

File tree

10 files changed

+17
-33
lines changed

10 files changed

+17
-33
lines changed

packages/core/package.nls.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@
255255
"AWS.appcomposer.explorerTitle": "Infrastructure Composer",
256256
"AWS.cdk.explorerTitle": "CDK",
257257
"AWS.codecatalyst.explorerTitle": "CodeCatalyst",
258-
"AWS.cwl.limit.desc": "Maximum amount of log entries pulled per request from CloudWatch Logs (max 10000)",
259-
"AWS.cwl.liveTailMaxEvents.desc": "Maximum amount of log entries that can be kept in a single live tail session. When the limit is reached, the oldest events will be removed to accomodate new events (min 1000; max 10000)",
258+
"AWS.cwl.limit.desc": "Maximum amount of log entries pulled per request from CloudWatch Logs. For LiveTail, when the limit is reached, the oldest events will be removed to accomodate new events. (max 10000)",
260259
"AWS.samcli.deploy.bucket.recentlyUsed": "Buckets recently used for SAM deployments",
261260
"AWS.submenu.amazonqEditorContextSubmenu.title": "Amazon Q",
262261
"AWS.submenu.auth.title": "Authentication",

packages/core/src/awsService/cloudWatchLogs/activation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import * as vscode from 'vscode'
7-
import { CLOUDWATCH_LOGS_LIVETAIL_SCHEME, CLOUDWATCH_LOGS_SCHEME } from '../../shared/constants'
7+
import { cloudwatchLogsLiveTailScheme, CLOUDWATCH_LOGS_SCHEME } from '../../shared/constants'
88
import { Settings } from '../../shared/settings'
99
import { addLogEvents } from './commands/addLogEvents'
1010
import { copyLogResource } from './commands/copyLogResource'
@@ -51,7 +51,7 @@ export async function activate(context: vscode.ExtensionContext, configuration:
5151
)
5252

5353
context.subscriptions.push(
54-
vscode.workspace.registerTextDocumentContentProvider(CLOUDWATCH_LOGS_LIVETAIL_SCHEME, liveTailDocumentProvider)
54+
vscode.workspace.registerTextDocumentContentProvider(cloudwatchLogsLiveTailScheme, liveTailDocumentProvider)
5555
)
5656

5757
context.subscriptions.push(

packages/core/src/awsService/cloudWatchLogs/cloudWatchLogsUtils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,4 @@ function createURIFromArgs(args: CloudWatchLogsArgs): vscode.Uri {
111111
}
112112
export const cwlUriSchema = new UriSchema<CloudWatchLogsArgs>(parseCloudWatchLogsUri, createURIFromArgs)
113113

114-
export class CloudWatchLogsSettings extends fromExtensionManifest('aws.cwl', {
115-
limit: Number,
116-
liveTailMaxEvents: Number,
117-
}) {}
114+
export class CloudWatchLogsSettings extends fromExtensionManifest('aws.cwl', { limit: Number }) {}

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,15 @@ async function handleSessionStream(
7171
document: vscode.TextDocument,
7272
session: LiveTailSession
7373
) {
74-
try {
75-
for await (const event of stream) {
76-
if (event.sessionUpdate !== undefined && event.sessionUpdate.sessionResults !== undefined) {
77-
const formattedLogEvents = event.sessionUpdate.sessionResults.map<string>((logEvent) =>
78-
formatLogEvent(logEvent)
79-
)
80-
if (formattedLogEvents.length !== 0) {
81-
await updateTextDocumentWithNewLogEvents(formattedLogEvents, document, session.maxLines)
82-
}
74+
for await (const event of stream) {
75+
if (event.sessionUpdate !== undefined && event.sessionUpdate.sessionResults !== undefined) {
76+
const formattedLogEvents = event.sessionUpdate.sessionResults.map<string>((logEvent) =>
77+
formatLogEvent(logEvent)
78+
)
79+
if (formattedLogEvents.length !== 0) {
80+
await updateTextDocumentWithNewLogEvents(formattedLogEvents, document, session.maxLines)
8381
}
8482
}
85-
} catch (err) {
86-
throw new ToolkitError('Caught on-stream exception')
8783
}
8884
}
8985

packages/core/src/awsService/cloudWatchLogs/registry/liveTailSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class LiveTailSession {
4646
}),
4747
abortController: new AbortController(),
4848
}
49-
this._maxLines = LiveTailSession.settings.get('liveTailMaxEvents', 10000)
49+
this._maxLines = LiveTailSession.settings.get('limit', 10000)
5050
this._uri = createLiveTailURIFromArgs(configuration)
5151
}
5252

packages/core/src/awsService/cloudWatchLogs/registry/liveTailSessionRegistry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
import * as vscode from 'vscode'
6-
import { CLOUDWATCH_LOGS_LIVETAIL_SCHEME } from '../../../shared/constants'
6+
import { cloudwatchLogsLiveTailScheme } from '../../../shared/constants'
77
import { LiveTailSession, LiveTailSessionConfiguration } from './liveTailSession'
88

99
export class LiveTailSessionRegistry extends Map<vscode.Uri, LiveTailSession> {
@@ -19,7 +19,7 @@ export class LiveTailSessionRegistry extends Map<vscode.Uri, LiveTailSession> {
1919
}
2020

2121
export function createLiveTailURIFromArgs(sessionData: LiveTailSessionConfiguration): vscode.Uri {
22-
let uriStr = `${CLOUDWATCH_LOGS_LIVETAIL_SCHEME}:${sessionData.region}:${sessionData.logGroupName}`
22+
let uriStr = `${cloudwatchLogsLiveTailScheme}:${sessionData.region}:${sessionData.logGroupName}`
2323

2424
if (sessionData.logStreamFilter) {
2525
if (sessionData.logStreamFilter.type !== 'all') {

packages/core/src/shared/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const ecsIamPermissionsUrl = vscode.Uri.parse(
146146
* URI scheme for CloudWatch Logs Virtual Documents
147147
*/
148148
export const CLOUDWATCH_LOGS_SCHEME = 'aws-cwl' // eslint-disable-line @typescript-eslint/naming-convention
149-
export const CLOUDWATCH_LOGS_LIVETAIL_SCHEME = 'aws-cwl-lt' // eslint-disable-line @typescript-eslint/naming-convention
149+
export const cloudwatchLogsLiveTailScheme = 'aws-cwl-lt'
150150

151151
export const AWS_SCHEME = 'aws' // eslint-disable-line @typescript-eslint/naming-convention
152152
export const ec2LogsScheme = 'aws-ec2'

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const toolkitSettings = {
2222
"aws.stepfunctions.asl.maxItemsComputed": {},
2323
"aws.ssmDocument.ssm.maxItemsComputed": {},
2424
"aws.cwl.limit": {},
25-
"aws.cwl.liveTailMaxEvents": {},
2625
"aws.samcli.manuallySelectedBuckets": {},
2726
"aws.samcli.enableCodeLenses": {},
2827
"aws.suppressPrompts": {

packages/core/src/test/awsService/cloudWatchLogs/registry/liveTailRegistry.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import * as vscode from 'vscode'
66
import assert from 'assert'
77
import { LiveTailSessionConfiguration } from '../../../../awsService/cloudWatchLogs/registry/liveTailSession'
88
import { createLiveTailURIFromArgs } from '../../../../awsService/cloudWatchLogs/registry/liveTailSessionRegistry'
9-
import { CLOUDWATCH_LOGS_LIVETAIL_SCHEME } from '../../../../shared/constants'
9+
import { cloudwatchLogsLiveTailScheme } from '../../../../shared/constants'
1010

1111
describe('LiveTailSession URI', async function () {
1212
const testLogGroupName = 'test-log-group'
1313
const testRegion = 'test-region'
14-
const expectedUriBase = `${CLOUDWATCH_LOGS_LIVETAIL_SCHEME}:${testRegion}:${testLogGroupName}`
14+
const expectedUriBase = `${cloudwatchLogsLiveTailScheme}:${testRegion}:${testLogGroupName}`
1515

1616
it('is correct with no logStream filter, no filter pattern', function () {
1717
const config: LiveTailSessionConfiguration = {

packages/toolkit/package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@
162162
"description": "%AWS.cwl.limit.desc%",
163163
"maximum": 10000
164164
},
165-
"aws.cwl.liveTailMaxEvents": {
166-
"type": "number",
167-
"default": 10000,
168-
"description": "%AWS.cwl.liveTailMaxEvents.desc%",
169-
"minimum": 1000,
170-
"maximum": 10000
171-
},
172165
"aws.samcli.manuallySelectedBuckets": {
173166
"type": "object",
174167
"description": "%AWS.samcli.deploy.bucket.recentlyUsed%",

0 commit comments

Comments
 (0)