mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix broken XEvent Profiler (#504)
* Fix broken profilergrid and choose columns dialog * Additional profiler changes * Additonal profiler bugs fixes
This commit is contained in:
@@ -17,6 +17,9 @@ import * as nls from 'vs/nls';
|
|||||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import { ObjectExplorerActionsContext } from 'sql/parts/registeredServer/viewlet/objectExplorerActions';
|
||||||
|
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||||
|
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType } from 'sql/parts/connection/common/connectionManagement';
|
||||||
|
|
||||||
export class ProfilerConnect extends Action {
|
export class ProfilerConnect extends Action {
|
||||||
public static ID = 'profiler.connect';
|
public static ID = 'profiler.connect';
|
||||||
@@ -228,17 +231,35 @@ export class NewProfilerAction extends TaskAction {
|
|||||||
public static LABEL = nls.localize('newProfiler', 'New Profiler');
|
public static LABEL = nls.localize('newProfiler', 'New Profiler');
|
||||||
public static ICON = 'profile';
|
public static ICON = 'profile';
|
||||||
|
|
||||||
|
private _connectionProfile: ConnectionProfile;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
id: string, label: string, icon: string,
|
id: string, label: string, icon: string,
|
||||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||||
|
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||||
@IInstantiationService private _instantiationService: IInstantiationService
|
@IInstantiationService private _instantiationService: IInstantiationService
|
||||||
) {
|
) {
|
||||||
super(id, label, icon);
|
super(id, label, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
run(actionContext: BaseActionContext): TPromise<boolean> {
|
run(actionContext: BaseActionContext): TPromise<boolean> {
|
||||||
|
if (actionContext instanceof ObjectExplorerActionsContext) {
|
||||||
|
this._connectionProfile = actionContext.connectionProfile;
|
||||||
|
}
|
||||||
|
|
||||||
let profilerInput = this._instantiationService.createInstance(ProfilerInput, actionContext.profile);
|
let profilerInput = this._instantiationService.createInstance(ProfilerInput, actionContext.profile);
|
||||||
return this._editorService.openEditor(profilerInput, { pinned: true }, false).then(() => {
|
return this._editorService.openEditor(profilerInput, { pinned: true }, false).then(() => {
|
||||||
|
let options: IConnectionCompletionOptions = {
|
||||||
|
params: undefined,
|
||||||
|
saveTheConnection: false,
|
||||||
|
showConnectionDialogOnError: true,
|
||||||
|
showDashboard: false,
|
||||||
|
showFirewallRuleOnError: true
|
||||||
|
};
|
||||||
|
this._connectionService.connect(this._connectionProfile, profilerInput.id, options).then(() => {
|
||||||
|
TPromise.as(true);
|
||||||
|
});
|
||||||
|
|
||||||
return TPromise.as(true);
|
return TPromise.as(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ import { CommonFindController, FindStartFocusAction } from 'vs/editor/contrib/fi
|
|||||||
import * as types from 'vs/base/common/types';
|
import * as types from 'vs/base/common/types';
|
||||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||||
|
|
||||||
import { ProfilerTestBackend } from 'sql/parts/profiler/service/profilerTestBackend';
|
|
||||||
|
|
||||||
class BasicView extends View {
|
class BasicView extends View {
|
||||||
private _previousSize: number;
|
private _previousSize: number;
|
||||||
private _collapsed: boolean;
|
private _collapsed: boolean;
|
||||||
@@ -157,7 +155,7 @@ export class ProfilerEditor extends BaseEditor {
|
|||||||
let tableContainer = this._createProfilerTable();
|
let tableContainer = this._createProfilerTable();
|
||||||
let paneContainer = this._createProfilerPane();
|
let paneContainer = this._createProfilerPane();
|
||||||
this._splitView.addView(new BasicView(
|
this._splitView.addView(new BasicView(
|
||||||
undefined,
|
300,
|
||||||
tableContainer,
|
tableContainer,
|
||||||
() => this._profilerTableEditor.focus(),
|
() => this._profilerTableEditor.focus(),
|
||||||
size => this._profilerTableEditor.layout(new Dimension(parseFloat(DOM.getComputedStyle(this._body).width), size)),
|
size => this._profilerTableEditor.layout(new Dimension(parseFloat(DOM.getComputedStyle(this._body).width), size)),
|
||||||
@@ -165,7 +163,7 @@ export class ProfilerEditor extends BaseEditor {
|
|||||||
));
|
));
|
||||||
|
|
||||||
this._panelView = new BasicView(
|
this._panelView = new BasicView(
|
||||||
undefined,
|
300,
|
||||||
paneContainer,
|
paneContainer,
|
||||||
() => this._tabbedPanel.focus(),
|
() => this._tabbedPanel.focus(),
|
||||||
size => this._tabbedPanel.layout(new Dimension(DOM.getTotalWidth(this._body), size)),
|
size => this._tabbedPanel.layout(new Dimension(DOM.getTotalWidth(this._body), size)),
|
||||||
|
|||||||
@@ -62,19 +62,17 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public set sessionTemplate(template: IProfilerSessionTemplate) {
|
public set sessionTemplate(template: IProfilerSessionTemplate) {
|
||||||
if (!this.state.isConnected || this.state.isStopped) {
|
this._sessionTemplate = template;
|
||||||
this._sessionTemplate = template;
|
let newColumns = this.sessionTemplate.view.events.reduce<Array<string>>((p, e) => {
|
||||||
let newColumns = this.sessionTemplate.view.events.reduce<Array<string>>((p, e) => {
|
e.columns.forEach(c => {
|
||||||
e.columns.forEach(c => {
|
if (!p.includes(c)) {
|
||||||
if (!p.includes(c)) {
|
p.push(c);
|
||||||
p.push(c);
|
}
|
||||||
}
|
});
|
||||||
});
|
return p;
|
||||||
return p;
|
}, []);
|
||||||
}, []);
|
newColumns.unshift('EventClass');
|
||||||
newColumns.unshift('EventClass');
|
this.setColumns(newColumns);
|
||||||
this.setColumns(newColumns);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get sessionTemplate(): IProfilerSessionTemplate {
|
public get sessionTemplate(): IProfilerSessionTemplate {
|
||||||
@@ -125,16 +123,54 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
|||||||
return this._state;
|
return this._state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onMoreRows(events: data.ProfilerSessionEvents) {
|
public onMoreRows(eventMessage: data.ProfilerSessionEvents) {
|
||||||
|
for (let i: number = 0; i < eventMessage.events.length && i < 500; ++i) {
|
||||||
|
let e: data.ProfilerEvent = eventMessage.events[i];
|
||||||
|
let data = {};
|
||||||
|
data['EventClass'] = e.name;
|
||||||
|
data['StartTime'] = e.timestamp;
|
||||||
|
data['EndTime'] = e.timestamp;
|
||||||
|
const columns = [
|
||||||
|
'TextData',
|
||||||
|
'ApplicationName',
|
||||||
|
'NTUserName',
|
||||||
|
'LoginName',
|
||||||
|
'CPU',
|
||||||
|
'Reads',
|
||||||
|
'Writes',
|
||||||
|
'Duration',
|
||||||
|
'ClientProcessID',
|
||||||
|
'SPID',
|
||||||
|
'StartTime',
|
||||||
|
'EndTime',
|
||||||
|
'BinaryData'
|
||||||
|
];
|
||||||
|
|
||||||
events = undefined;
|
let columnNameMap: Map<string, string> = new Map<string, string>();
|
||||||
|
columnNameMap['client_app_name'] = 'ApplicationName';
|
||||||
|
columnNameMap['nt_username'] = 'NTUserName';
|
||||||
|
columnNameMap['options_text'] = 'TextData';
|
||||||
|
columnNameMap['server_principal_name'] = 'LoginName';
|
||||||
|
columnNameMap['session_id'] = 'SPID';
|
||||||
|
columnNameMap['batch_text'] = 'TextData';
|
||||||
|
columnNameMap['cpu_time'] = 'CPU';
|
||||||
|
columnNameMap['duration'] = 'Duration';
|
||||||
|
columnNameMap['logical_reads'] = 'Reads';
|
||||||
|
|
||||||
|
for (let idx = 0; idx < columns.length; ++idx) {
|
||||||
|
let columnName = columns[idx];
|
||||||
|
data[columnName] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let key in e.values) {
|
||||||
|
let columnName = columnNameMap[key];
|
||||||
|
if (columnName) {
|
||||||
|
let value = e.values[key];
|
||||||
|
data[columnName] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._data.push(data);
|
||||||
|
}
|
||||||
|
|
||||||
// let validColumns = this.sessionTemplate.view.events.find(i => i.name === data.EventClass).columns;
|
|
||||||
// Object.keys(rowCount).forEach(k => {
|
|
||||||
// if (!validColumns.includes(k)) {
|
|
||||||
// delete rowCount[k];
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// this._data.push(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionPr
|
|||||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||||
import { NewProfilerAction } from 'sql/parts/profiler/contrib/profilerActions';
|
import { NewProfilerAction } from 'sql/parts/profiler/contrib/profilerActions';
|
||||||
import { TreeUpdateUtils } from 'sql/parts/registeredServer/viewlet/treeUpdateUtils';
|
import { TreeUpdateUtils } from 'sql/parts/registeredServer/viewlet/treeUpdateUtils';
|
||||||
import { IConnectionManagementService, IErrorMessageService } from 'sql/parts/connection/common/connectionManagement';
|
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides actions for the server tree elements
|
* Provides actions for the server tree elements
|
||||||
|
|||||||
@@ -349,10 +349,7 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
|||||||
|
|
||||||
// Profiler handlers
|
// Profiler handlers
|
||||||
public $onSessionEventsAvailable(handle: number, response: data.ProfilerSessionEvents): void {
|
public $onSessionEventsAvailable(handle: number, response: data.ProfilerSessionEvents): void {
|
||||||
|
|
||||||
this._profilerService.onMoreRows(response);
|
this._profilerService.onMoreRows(response);
|
||||||
//this._profilerService.onMoreRows
|
|
||||||
//this._taskService.onNewTaskCreated(handle, taskInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public $unregisterProvider(handle: number): TPromise<any> {
|
public $unregisterProvider(handle: number): TPromise<any> {
|
||||||
@@ -364,6 +361,4 @@ export class MainThreadDataProtocol extends MainThreadDataProtocolShape {
|
|||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user