@@ -10,16 +10,10 @@ import {
1010} from '@aws-sdk/client-cloudwatch-logs'
1111import { LogStreamFilterResponse } from '../wizard/liveTailLogStreamSubmenu'
1212import { CloudWatchLogsSettings } from '../cloudWatchLogsUtils'
13- import { Settings , ToolkitError } from '../../../shared'
13+ import { convertToTimeString , Settings , ToolkitError } from '../../../shared'
1414import { createLiveTailURIFromArgs } from './liveTailSessionRegistry'
1515import { getUserAgent } from '../../../shared/telemetry/util'
1616
17- export type LiveTailSessionStatusBarItems = {
18- isSampled : vscode . StatusBarItem
19- eventRate : vscode . StatusBarItem
20- sessionTimer : vscode . StatusBarItem
21- }
22-
2317export type LiveTailSessionConfiguration = {
2418 logGroupName : string
2519 logStreamFilter ?: LogStreamFilterResponse
@@ -39,9 +33,11 @@ export class LiveTailSession {
3933 private logEventFilterPattern ?: string
4034 private _maxLines : number
4135 private _uri : vscode . Uri
42- private _statusBarItems : LiveTailSessionStatusBarItems
36+ private statusBarItem : vscode . StatusBarItem
4337 private startTime : number | undefined
4438 private endTime : number | undefined
39+ private _eventRate : number
40+ private _isSampled : boolean
4541
4642 static settings = new CloudWatchLogsSettings ( Settings . instance )
4743
@@ -57,7 +53,9 @@ export class LiveTailSession {
5753 }
5854 this . _maxLines = LiveTailSession . settings . get ( 'limit' , 10000 )
5955 this . _uri = createLiveTailURIFromArgs ( configuration )
60- this . _statusBarItems = this . createStatusBarItems ( )
56+ this . statusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 0 )
57+ this . _eventRate = 0
58+ this . _isSampled = false
6159 }
6260
6361 public get maxLines ( ) {
@@ -72,8 +70,12 @@ export class LiveTailSession {
7270 return this . _logGroupName
7371 }
7472
75- public get statusBarItems ( ) : LiveTailSessionStatusBarItems {
76- return this . _statusBarItems
73+ public set eventRate ( rate : number ) {
74+ this . _eventRate = rate
75+ }
76+
77+ public set isSampled ( isSampled : boolean ) {
78+ this . _isSampled = isSampled
7779 }
7880
7981 public async startLiveTailSession ( ) : Promise < AsyncIterable < StartLiveTailResponseStream > > {
@@ -95,7 +97,7 @@ export class LiveTailSession {
9597
9698 public stopLiveTailSession ( ) {
9799 this . endTime = Date . now ( )
98- this . disposeStatusBarItems ( )
100+ this . statusBarItem . dispose ( )
99101 this . liveTailClient . abortController . abort ( )
100102 this . liveTailClient . cwlClient . destroy ( )
101103 }
@@ -133,29 +135,18 @@ export class LiveTailSession {
133135 } )
134136 }
135137
136- private createStatusBarItems ( ) : LiveTailSessionStatusBarItems {
137- return {
138- sessionTimer : vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 0 ) ,
139- eventRate : vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 1 ) ,
140- isSampled : vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 2 ) ,
141- }
142- }
143-
144- public showStatusBarItems ( ) {
145- this . statusBarItems . eventRate . show ( )
146- this . statusBarItems . isSampled . show ( )
147- this . statusBarItems . sessionTimer . show ( )
138+ public showStatusBarItem ( ) {
139+ this . statusBarItem . show ( )
148140 }
149141
150- public hideStatusBarItems ( ) {
151- this . statusBarItems . eventRate . hide ( )
152- this . statusBarItems . isSampled . hide ( )
153- this . statusBarItems . sessionTimer . hide ( )
142+ public hideStatusBarItem ( ) {
143+ this . statusBarItem . hide ( )
154144 }
155145
156- private disposeStatusBarItems ( ) {
157- this . statusBarItems . eventRate . dispose ( )
158- this . statusBarItems . isSampled . dispose ( )
159- this . statusBarItems . sessionTimer . dispose ( )
146+ public updateStatusBarItemText ( ) {
147+ const elapsedTime = this . getLiveTailSessionDuration ( )
148+ const timeString = convertToTimeString ( elapsedTime )
149+ const sampledString = this . _isSampled ? 'Yes' : 'No'
150+ this . statusBarItem . text = `Tailing Session: ${ timeString } , ${ this . _eventRate } events/sec, Sampled: ${ sampledString } `
160151 }
161152}
0 commit comments