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
This commit is contained in:
Madeline MacDonald
2018-06-19 11:23:01 -07:00
committed by GitHub
parent e686fed209
commit 520cfb780a
11 changed files with 62 additions and 3 deletions

View File

@@ -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 = {};

View File

@@ -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

View File

@@ -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<boolean> {
return this._runAction(id, provider => provider.connectSession(this._idMap.get(id)));
}

View File

@@ -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++];

10
src/sql/sqlops.d.ts vendored
View File

@@ -1409,6 +1409,7 @@ declare module 'sqlops' {
disconnectSession(sessionId: string): Thenable<boolean>;
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 -----------------------------------------------------------------------

View File

@@ -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

View File

@@ -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<any> {
let capabilitiesRegistration = this._capabilitiesRegistrations[handle];
if (capabilitiesRegistration) {

View File

@@ -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);
};

View File

@@ -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