From 520cfb780a7356ffa8983de6ebbdf508c12302f8 Mon Sep 17 00:00:00 2001 From: Madeline MacDonald Date: Tue, 19 Jun 2018 11:23:01 -0700 Subject: [PATCH] Profiler notifications (#1648) * adding lost events flag to events available notification * Initial changes to support notifications for stopped session and lost events * Updated localized strings & send stop notification box * reordering imports * vbump sqltools & dataprotocolclient, fix notification wording --- extensions/mssql/package.json | 2 +- extensions/mssql/src/config.json | 2 +- src/sql/parts/profiler/editor/profilerInput.ts | 18 +++++++++++++++++- src/sql/parts/profiler/service/interfaces.ts | 8 ++++++++ .../parts/profiler/service/profilerService.ts | 5 +++++ .../profiler/service/profilerTestBackend.ts | 4 ++++ src/sql/sqlops.d.ts | 10 ++++++++++ .../workbench/api/node/extHostDataProtocol.ts | 7 +++++++ .../api/node/mainThreadDataProtocol.ts | 4 ++++ .../workbench/api/node/sqlExtHost.api.impl.ts | 4 ++++ .../workbench/api/node/sqlExtHost.protocol.ts | 1 + 11 files changed, 62 insertions(+), 3 deletions(-) diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index faeba3d57c..7bab9fc6f0 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -658,7 +658,7 @@ } }, "dependencies": { - "dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.1.8.2", + "dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#0.1.9", "opener": "^1.4.3", "service-downloader": "github:anthonydresser/service-downloader#0.1.2", "vscode-extension-telemetry": "^0.0.15" diff --git a/extensions/mssql/src/config.json b/extensions/mssql/src/config.json index 5e7ac50ddc..4eecf95b90 100644 --- a/extensions/mssql/src/config.json +++ b/extensions/mssql/src/config.json @@ -1,6 +1,6 @@ { "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", - "version": "1.4.0-alpha.45", + "version": "1.4.0-alpha.46", "downloadFileNames": { "Windows_86": "win-x86-netcoreapp2.1.zip", "Windows_64": "win-x64-netcoreapp2.1.zip", diff --git a/src/sql/parts/profiler/editor/profilerInput.ts b/src/sql/parts/profiler/editor/profilerInput.ts index 2e42de003d..5257604ca1 100644 --- a/src/sql/parts/profiler/editor/profilerInput.ts +++ b/src/sql/parts/profiler/editor/profilerInput.ts @@ -14,6 +14,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { EditorInput } from 'vs/workbench/common/editor'; import { IEditorModel } from 'vs/platform/editor/common/editor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { INotificationService } from 'vs/platform/notification/common/notification'; import { Event, Emitter } from 'vs/base/common/event'; import { generateUuid } from 'vs/base/common/uuid'; @@ -35,7 +36,8 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { constructor( private _connection: IConnectionProfile, @IInstantiationService private _instantiationService: IInstantiationService, - @IProfilerService private _profilerService: IProfilerService + @IProfilerService private _profilerService: IProfilerService, + @INotificationService private _notificationService: INotificationService ) { super(); this._state = new ProfilerState(); @@ -123,7 +125,21 @@ export class ProfilerInput extends EditorInput implements IProfilerSession { return this._state; } + public onSessionStopped(notification: sqlops.ProfilerSessionStoppedParams) { + this._notificationService.error(nls.localize("profiler.sessionStopped", "XEvent Profiler Session stopped unexpectedly on the server {0}.", this._connection.serverName)); + + this.state.change({ + isStopped: true, + isPaused: false, + isRunning: false + }); + } + public onMoreRows(eventMessage: sqlops.ProfilerSessionEvents) { + if (eventMessage.eventsLost){ + this._notificationService.warn(nls.localize("profiler.eventsLost", "The XEvent Profiler session for {0} has lost events.", this._connection.serverName)); + } + for (let i: number = 0; i < eventMessage.events.length && i < 500; ++i) { let e: sqlops.ProfilerEvent = eventMessage.events[i]; let data = {}; diff --git a/src/sql/parts/profiler/service/interfaces.ts b/src/sql/parts/profiler/service/interfaces.ts index 159fe1f3f9..3a3480d9e3 100644 --- a/src/sql/parts/profiler/service/interfaces.ts +++ b/src/sql/parts/profiler/service/interfaces.ts @@ -25,6 +25,10 @@ export interface IProfilerSession { * Called by the service when more rows are available to render */ onMoreRows(events: sqlops.ProfilerSessionEvents); + /** + * Called by the service when the session is closed unexpectedly + */ + onSessionStopped(events: sqlops.ProfilerSessionStoppedParams); } /** @@ -65,6 +69,10 @@ export interface IProfilerService { * The method called by the service provider for when more rows are available to render */ onMoreRows(params: sqlops.ProfilerSessionEvents): void; + /** + * The method called by the service provider for when more rows are available to render + */ + onSessionStopped(params: sqlops.ProfilerSessionStoppedParams): void; /** * Gets a list of the session templates that are specified in the settings * @param provider An optional string to limit the session template to a specific diff --git a/src/sql/parts/profiler/service/profilerService.ts b/src/sql/parts/profiler/service/profilerService.ts index 6f5ffd6368..01b9a99f70 100644 --- a/src/sql/parts/profiler/service/profilerService.ts +++ b/src/sql/parts/profiler/service/profilerService.ts @@ -82,6 +82,11 @@ export class ProfilerService implements IProfilerService { this._sessionMap.get(this._idMap.reverseGet(params.sessionId)).onMoreRows(params); } + public onSessionStopped(params: sqlops.ProfilerSessionStoppedParams): void { + + this._sessionMap.get(this._idMap.reverseGet(params.ownerUri)).onSessionStopped(params); + } + public connectSession(id: ProfilerSessionID): Thenable { return this._runAction(id, provider => provider.connectSession(this._idMap.get(id))); } diff --git a/src/sql/parts/profiler/service/profilerTestBackend.ts b/src/sql/parts/profiler/service/profilerTestBackend.ts index b0ce154a9b..6a28c9ea8c 100644 --- a/src/sql/parts/profiler/service/profilerTestBackend.ts +++ b/src/sql/parts/profiler/service/profilerTestBackend.ts @@ -48,6 +48,10 @@ export class ProfilerTestBackend implements sqlops.ProfilerProvider { return; } + registerOnSessionStopped(handler: (response: sqlops.ProfilerSessionStoppedParams) => any) { + return; + } + private intervalFn(guid: string): number { return setTimeout(() => { let data = this.testData[this.index++]; diff --git a/src/sql/sqlops.d.ts b/src/sql/sqlops.d.ts index 0619e3ebee..98998881ce 100644 --- a/src/sql/sqlops.d.ts +++ b/src/sql/sqlops.d.ts @@ -1409,6 +1409,7 @@ declare module 'sqlops' { disconnectSession(sessionId: string): Thenable; registerOnSessionEventsAvailable(handler: (response: ProfilerSessionEvents) => any): void; + registerOnSessionStopped(handler: (response: ProfilerSessionStoppedParams) => any): void; } export interface IProfilerTableRow { @@ -1449,6 +1450,15 @@ declare module 'sqlops' { sessionId: string; events: ProfilerEvent[]; + + eventsLost: boolean; + } + + export interface ProfilerSessionStoppedParams { + + ownerUri: string; + + sessionId: number; } // File browser interfaces ----------------------------------------------------------------------- diff --git a/src/sql/workbench/api/node/extHostDataProtocol.ts b/src/sql/workbench/api/node/extHostDataProtocol.ts index ae7d85132c..af77e67771 100644 --- a/src/sql/workbench/api/node/extHostDataProtocol.ts +++ b/src/sql/workbench/api/node/extHostDataProtocol.ts @@ -518,6 +518,13 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape { this._proxy.$onSessionEventsAvailable(handle, response); } + /** + * Profiler session stopped unexpectedly notification + */ + public $onSessionStopped(handle: number, response: sqlops.ProfilerSessionStoppedParams): void { + this._proxy.$onSessionStopped(handle, response); + } + /** * Agent Job Provider methods diff --git a/src/sql/workbench/api/node/mainThreadDataProtocol.ts b/src/sql/workbench/api/node/mainThreadDataProtocol.ts index 8de3337a90..89d8a30f19 100644 --- a/src/sql/workbench/api/node/mainThreadDataProtocol.ts +++ b/src/sql/workbench/api/node/mainThreadDataProtocol.ts @@ -432,6 +432,10 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape { this._profilerService.onMoreRows(response); } + public $onSessionStopped(handle: number, response: sqlops.ProfilerSessionStoppedParams): void { + this._profilerService.onSessionStopped(response); + } + public $unregisterProvider(handle: number): TPromise { let capabilitiesRegistration = this._capabilitiesRegistrations[handle]; if (capabilitiesRegistration) { diff --git a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts index fc7b4c4bf1..444c15807c 100644 --- a/src/sql/workbench/api/node/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/node/sqlExtHost.api.impl.ts @@ -237,6 +237,10 @@ export function createApiFactory( extHostDataProvider.$onSessionEventsAvailable(provider.handle, response); }); + provider.registerOnSessionStopped((response: sqlops.ProfilerSessionStoppedParams) => { + extHostDataProvider.$onSessionStopped(provider.handle, response); + }); + return extHostDataProvider.$registerProfilerProvider(provider); }; diff --git a/src/sql/workbench/api/node/sqlExtHost.protocol.ts b/src/sql/workbench/api/node/sqlExtHost.protocol.ts index dbacbd14f2..7aa7e90383 100644 --- a/src/sql/workbench/api/node/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/node/sqlExtHost.protocol.ts @@ -416,6 +416,7 @@ export interface MainThreadDataProtocolShape extends IDisposable { $onFilePathsValidated(handle: number, response: sqlops.FileBrowserValidatedParams): void; $onScriptingComplete(handle: number, message: sqlops.ScriptingCompleteResult): void; $onSessionEventsAvailable(handle: number, response: sqlops.ProfilerSessionEvents): void; + $onSessionStopped(handle: number, response: sqlops.ProfilerSessionStoppedParams): void; /** * Callback when a session has completed initialization