update whoisactive extension (#10164)

* update whoisactive extension

* update readme
This commit is contained in:
Alan Ren
2020-04-27 10:51:54 -07:00
committed by GitHub
parent 1d3568a2aa
commit 53c726459e
10 changed files with 4468 additions and 8122 deletions

View File

@@ -40,4 +40,10 @@ Special thank to Adam Machanic for partnering with us and make this sp_whoisacti
## What's new in Server Reports v1.1?
* Changed CPU usage, CPU delta, memory usage, memory delta to show only top 10 data
* Added details option on each chart to display details of data entries
* Improved "Get plans" and "Find leader of block" tasks. The tasks will open new editor, configure current dashboard connection, and run the query.
* Improved "Get plans" and "Find leader of block" tasks. The tasks will open new editor, configure current dashboard connection, and run the query.
## How to produce an extension installation package
Run the following commands sequentially in the context of this directory:
- `yarn install` - to install the dependencies
- `yarn build` - to build the code
- `vsce package` - to produce an extension installation package

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 18 18"><defs><style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:#50e6ff;}.cls-4{fill:#fff;}</style><linearGradient id="linear-gradient" x1="12.282" y1="11.436" x2="12.282" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#005ba1"/><stop offset="0.525" stop-color="#0074cd"/><stop offset="1" stop-color="#0078d4"/></linearGradient><linearGradient id="linear-gradient-2" x1="7.923" y1="18" x2="7.923" y2="3.129" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0078d4"/><stop offset="0.16" stop-color="#1380da"/><stop offset="0.53" stop-color="#3c91e5"/><stop offset="0.82" stop-color="#559cec"/><stop offset="1" stop-color="#5ea0ef"/></linearGradient></defs><rect class="cls-1" x="6.564" width="11.436" height="11.436" rx="1"/><rect class="cls-2" y="3.129" width="15.846" height="14.871" rx="1"/><path class="cls-3" d="M14.731,11.8a.455.455,0,0,0-.431-.48H12.849a.2.2,0,0,0-.185.111l-.95,1.7L10.16,9.981l-1.444,4.5L7.482,11.277l-1.628,3.01a.223.223,0,0,1-.186.124h-.74a.455.455,0,0,0-.456.407h0a.459.459,0,0,0,.456.506H6.162a.221.221,0,0,0,.2-.124l.963-1.813,1.493,3.7,1.517-4.762,1.333,2.7,1.493-2.678a.2.2,0,0,1,.185-.111h.932A.457.457,0,0,0,14.731,11.8Z"/><path class="cls-4" d="M9.341,7.449V4.311h-.83V8.123h2.27V7.449ZM2.751,5.908a1.722,1.722,0,0,1-.471-.286.405.405,0,0,1-.11-.3.313.313,0,0,1,.138-.277.63.63,0,0,1,.388-.11,1.5,1.5,0,0,1,.923.267V4.413A2.382,2.382,0,0,0,2.7,4.265a1.514,1.514,0,0,0-1.006.314A1,1,0,0,0,1.3,5.4c0,.471.295.84.923,1.117a2.634,2.634,0,0,1,.572.332.39.39,0,0,1,.139.3.351.351,0,0,1-.148.286.747.747,0,0,1-.415.1,1.533,1.533,0,0,1-1.006-.387V8a2.01,2.01,0,0,0,.987.222,1.737,1.737,0,0,0,1.089-.3.994.994,0,0,0,.305-.84.972.972,0,0,0-.231-.646A2.246,2.246,0,0,0,2.751,5.908ZM7.588,7.375a2.16,2.16,0,0,0,.3-1.163,2.145,2.145,0,0,0-.3-.978,1.671,1.671,0,0,0-.646-.692,1.846,1.846,0,0,0-.923-.24,1.942,1.942,0,0,0-1,.249,1.717,1.717,0,0,0-.674.683,2.258,2.258,0,0,0-.24,1.052,2.094,2.094,0,0,0,.221.923,1.627,1.627,0,0,0,.637.683,1.9,1.9,0,0,0,.923.277l.794.923H7.8L6.665,8.077A1.654,1.654,0,0,0,7.588,7.375Zm-.923-.23a.871.871,0,0,1-.7.323.846.846,0,0,1-.7-.333,1.4,1.4,0,0,1-.268-.923,1.412,1.412,0,0,1,.268-.923.921.921,0,0,1,.72-.341.8.8,0,0,1,.692.341,1.5,1.5,0,0,1,.249.923A1.353,1.353,0,0,1,6.665,7.145Z"/></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -1,269 +1,272 @@
{
"name": "whoisactive",
"displayName": "whoisactive",
"description": "sp_whoisactive for Azure Data Studio",
"version": "0.2.0",
"publisher": "Microsoft",
"preview": true,
"engines": {
"vscode": "^1.26.0",
"azdata": "^1.11.0"
},
"icon": "images/extension.png",
"license": "SEE LICENSE IN LICENSE.txt",
"repository": "https://github.com/Microsoft/azuredatastudio",
"categories": [
"Other"
"name": "whoisactive",
"displayName": "whoisactive",
"description": "sp_whoisactive for Azure Data Studio",
"version": "0.3.0",
"publisher": "Microsoft",
"preview": true,
"engines": {
"vscode": "^1.26.0",
"azdata": "^1.11.0"
},
"icon": "images/extension.png",
"license": "SEE LICENSE IN LICENSE.txt",
"repository": "https://github.com/Microsoft/azuredatastudio",
"categories": [
"Other"
],
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"contributes": {
"configuration": [],
"commands": [
{
"command": "sp_whoisactive.install",
"title": "Whoisactive: Install sp_whoisactive",
"icon": {
"light": "./out/src/media/download.svg",
"dark": "./out/src/media/download_inverse.svg"
}
},
{
"command": "sp_whoisactive.findBlockLeaders",
"title": "Whoisactive: Find leader of block",
"icon": {
"light": "./out/src/media/blocker.svg",
"dark": "./out/src/media/blocker_inverse.svg"
}
},
{
"command": "sp_whoisactive.getPlans",
"title": "Whoisactive: Get plans",
"icon": {
"light": "./out/src/media/monitor.svg",
"dark": "./out/src/media/monitor_inverse.svg"
}
},
{
"command": "sp_whoisactive.documentation",
"title": "Whoisactive: Documentation",
"icon": {
"light": "./out/src/media/documentation.svg",
"dark": "./out/src/media/documentation_inverse.svg"
}
}
],
"activationEvents": [
"*"
"views": {},
"menus": {},
"dashboard.tabs": [
{
"id": "sp_whoisactive",
"title": "sp_whoisactive",
"icon": "images/whoisactive.svg",
"group": "monitoring",
"description": "Extension for checking who is active.",
"container": {
"sp_whoisactive-insights": {}
}
}
],
"main": "./out/src/extension",
"contributes": {
"configuration": [],
"commands": [
{
"command": "sp_whoisactive.install",
"title": "Whoisactive: Install sp_whoisactive",
"icon": {
"light": "./out/src/media/download.svg",
"dark": "./out/src/media/download_inverse.svg"
}
},
{
"command": "sp_whoisactive.findBlockLeaders",
"title": "Whoisactive: Find leader of block",
"icon": {
"light": "./out/src/media/blocker.svg",
"dark": "./out/src/media/blocker_inverse.svg"
}
},
{
"command": "sp_whoisactive.getPlans",
"title": "Whoisactive: Get plans",
"icon": {
"light": "./out/src/media/monitor.svg",
"dark": "./out/src/media/monitor_inverse.svg"
}
},
{
"command": "sp_whoisactive.documentation",
"title": "Whoisactive: Documentation",
"icon": {
"light": "./out/src/media/documentation.svg",
"dark": "./out/src/media/documentation_inverse.svg"
}
"dashboard.insights": [
{
"id": "sp_whoisactive-CPU-usage",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
],
"views": {},
"menus": {},
"dashboard.tabs": [
{
"id": "sp_whoisactive",
"title": "sp_whoisactive",
"description": "Extension for checking who is active.",
"container": {
"sp_whoisactive-insights": {}
}
},
"queryFile": "./out/src/sql/cpuUsage.sql",
"details": {
"queryFile": "./out/src/sql/cpuUsage_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "CPU"
}
}
},
{
"id": "sp_whoisactive-CPU-delta",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
],
"dashboard.insights": [
{
"id": "sp_whoisactive-CPU-usage",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
},
"queryFile": "./out/src/sql/cpuUsage.sql",
"details": {
"queryFile": "./out/src/sql/cpuUsage_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "CPU"
}
}
},
"queryFile": "./out/src/sql/cpuDelta.sql",
"details": {
"queryFile": "./out/src/sql/cpuDelta_details.sql",
"label": {
"column": "session_id",
"state": []
},
{
"id": "sp_whoisactive-CPU-delta",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
},
"queryFile": "./out/src/sql/cpuDelta.sql",
"details": {
"queryFile": "./out/src/sql/cpuDelta_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "CPU_delta"
}
}
},
{
"id": "sp_whoisactive-memory-usage",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
},
"queryFile": "./out/src/sql/memoryUsage.sql",
"details": {
"queryFile": "./out/src/sql/memoryUsage_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "used_memory"
}
}
},
{
"id": "sp_whoisactive-memory-delta",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
},
"queryFile": "./out/src/sql/memoryDelta.sql",
"details": {
"queryFile": "./out/src/sql/memoryDelta_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "used_memory_delta"
}
}
},
{
"id": "sp_whoisactive-blocking_sessions",
"contrib": {
"type": {
"table": null
},
"queryFile": "./out/src/sql/blockingSessions.sql"
}
"value": "CPU_delta"
}
}
},
{
"id": "sp_whoisactive-memory-usage",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
],
"dashboard.containers": [
{
"id": "sp_whoisactive-insights",
"container": {
"widgets-container": [
{
"name": "Tasks",
"widget": {
"tasks-widget": [
"sp_whoisactive.getPlans",
"sp_whoisactive.findBlockLeaders",
"sp_whoisactive.documentation",
"sp_whoisactive.install"
]
}
},
{
"name": "Top 10 CPU Usage",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-CPU-usage": {}
}
},
{
"name": "Top 10 CPU Delta",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-CPU-delta": {}
}
},
{
"name": "Top 10 Memory Usage",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-memory-usage": {}
}
},
{
"name": "Top 10 Memory Delta",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-memory-delta": {}
}
}
]
}
},
"queryFile": "./out/src/sql/memoryUsage.sql",
"details": {
"queryFile": "./out/src/sql/memoryUsage_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "used_memory"
}
}
},
{
"id": "sp_whoisactive-memory-delta",
"contrib": {
"type": {
"bar": {
"dataDirection": "vertical",
"dataType": "number",
"legendPosition": "none",
"labelFirstColumn": false,
"columnsAsLabels": true,
"showTopNData": 10
}
],
"snippets": []
},
"scripts": {
"build": "gulp build",
"compile": "gulp compile",
"watch": "gulp watch",
"typings": "gulp copytypings",
"postinstall": "node ./node_modules/vscode/bin/install && gulp copytypings"
},
"dependencies": {
"fs-extra": "^5.0.0",
"handlebars": "^4.5.3",
"openurl": "^1.1.1"
},
"devDependencies": {
"@types/mocha": "^2.2.42",
"@types/node": "^7.0.43",
"child-process-promise": "^2.2.1",
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-color": "0.0.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-tslint": "^6.0.2",
"gulp-typescript": "^3.2.4",
"should": "^13.2.1",
"temp-write": "^3.4.0",
"tslint": "^3.14.0",
"typemoq": "^2.1.0",
"typescript": "^2.6.1",
"vsce": "1.36.2",
"vscode": "^1.1.6"
}
},
"queryFile": "./out/src/sql/memoryDelta.sql",
"details": {
"queryFile": "./out/src/sql/memoryDelta_details.sql",
"label": {
"column": "session_id",
"state": []
},
"value": "used_memory_delta"
}
}
},
{
"id": "sp_whoisactive-blocking_sessions",
"contrib": {
"type": {
"table": null
},
"queryFile": "./out/src/sql/blockingSessions.sql"
}
}
],
"dashboard.containers": [
{
"id": "sp_whoisactive-insights",
"container": {
"widgets-container": [
{
"name": "Tasks",
"widget": {
"tasks-widget": [
"sp_whoisactive.getPlans",
"sp_whoisactive.findBlockLeaders",
"sp_whoisactive.documentation",
"sp_whoisactive.install"
]
}
},
{
"name": "Top 10 CPU Usage",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-CPU-usage": {}
}
},
{
"name": "Top 10 CPU Delta",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-CPU-delta": {}
}
},
{
"name": "Top 10 Memory Usage",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-memory-usage": {}
}
},
{
"name": "Top 10 Memory Delta",
"gridItemConfig": {
"sizex": 2,
"sizey": 1
},
"widget": {
"sp_whoisactive-memory-delta": {}
}
}
]
}
}
],
"snippets": []
},
"scripts": {
"build": "gulp build",
"compile": "gulp compile",
"watch": "gulp watch",
"typings": "gulp copytypings",
"postinstall": "node ./node_modules/vscode/bin/install && node ./node_modules/azdata/bin/install"
},
"dependencies": {
"fs-extra": "^5.0.0",
"handlebars": "^4.5.3",
"openurl": "^1.1.1"
},
"devDependencies": {
"azdata": "^1.0.0",
"@types/mocha": "^2.2.42",
"@types/node": "^7.0.43",
"child-process-promise": "^2.2.1",
"del": "^3.0.0",
"gulp": "^4.0.0",
"gulp-color": "0.0.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-tslint": "^6.0.2",
"gulp-typescript": "^3.2.4",
"should": "^13.2.1",
"temp-write": "^3.4.0",
"tslint": "^3.14.0",
"typemoq": "^2.1.0",
"typescript": "^2.6.1",
"vsce": "1.36.2",
"vscode": "^1.1.6"
}
}

View File

@@ -13,27 +13,27 @@ import MainController from './controllers/mainController';
let controllers: ControllerBase[] = [];
export function activate(context: vscode.ExtensionContext): Promise<boolean> {
let activations: Promise<boolean>[] = [];
let activations: Promise<boolean>[] = [];
// Start the main controller
let mainController = new MainController(context);
controllers.push(mainController);
context.subscriptions.push(mainController);
activations.push(mainController.activate());
// Start the main controller
let mainController = new MainController(context);
controllers.push(mainController);
context.subscriptions.push(mainController);
activations.push(mainController.activate());
return Promise.all(activations)
.then((results: boolean[]) => {
for (let result of results) {
if (!result) {
return false;
}
}
return true;
});
return Promise.all(activations)
.then((results: boolean[]) => {
for (let result of results) {
if (!result) {
return false;
}
}
return true;
});
}
export function deactivate(): void {
for (let controller of controllers) {
controller.deactivate();
}
for (let controller of controllers) {
controller.deactivate();
}
}

View File

@@ -18,33 +18,33 @@ import * as LocalizedConstants from './localizedConstants';
* @param msg Message to log to the console
*/
export function logDebug(msg: any): void {
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
let logDebugInfo = config[Constants.configLogDebugInfo];
if (logDebugInfo === true) {
let currentTime = new Date().toLocaleTimeString();
let outputMsg = '[' + currentTime + ']: ' + msg ? msg.toString() : '';
console.log(outputMsg);
}
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
let logDebugInfo = config[Constants.configLogDebugInfo];
if (logDebugInfo === true) {
let currentTime = new Date().toLocaleTimeString();
let outputMsg = '[' + currentTime + ']: ' + msg ? msg.toString() : '';
console.log(outputMsg);
}
}
export function renderTemplateHtml(extensionPath: string, templateName: string, templateValues: object): Thenable<string> {
let templatePath = path.join(extensionPath, 'resources', templateName);
let templatePath = path.join(extensionPath, 'resources', templateName);
// 1) Read the template from the disk
// 2) Compile it as a handlebars template and render the HTML
// 3) On failure, return a simple string as an error
return fs.readFile(templatePath, 'utf-8')
.then(templateText => {
let template = handlebars.compile(templateText);
return template(templateValues);
})
.then(
undefined,
error => {
logDebug(error);
return LocalizedConstants.msgErrorLoadingTab;
}
);
// 1) Read the template from the disk
// 2) Compile it as a handlebars template and render the HTML
// 3) On failure, return a simple string as an error
return fs.readFile(templatePath, 'utf-8')
.then(templateText => {
let template = handlebars.compile(templateText);
return template(templateValues);
})
.then(
undefined,
error => {
logDebug(error);
return LocalizedConstants.msgErrorLoadingTab;
}
);
}

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"use strict";
'use strict';
let del = require('del');
let gulp = require('gulp');
@@ -18,21 +18,21 @@ let tsProject = ts.createProject('tsconfig.json');
// GULP TASKS //////////////////////////////////////////////////////////////
gulp.task('clean', function(done) {
gulp.task('clean', function (done) {
return del('out', done);
});
gulp.task('lint', () => {
return gulp.src([
config.paths.project.root + '/src/**/*.ts'
config.paths.project.root + '/src/**/*.ts'
])
.pipe((tslint({
formatter: "verbose"
})))
.pipe(tslint.report());
.pipe((tslint({
formatter: 'verbose'
})))
.pipe(tslint.report());
});
gulp.task('compile:src', function(done) {
gulp.task('compile:src', function (done) {
gulp.src([
config.paths.project.root + '/src/**/*.sql',
config.paths.project.root + '/src/**/*.svg',
@@ -48,26 +48,27 @@ gulp.task('compile:src', function(done) {
return gulp.src(srcFiles)
.pipe(srcmap.init())
.pipe(tsProject())
.on('error', function() {
if(process.env.BUILDMACHINE) {
.on('error', function () {
if (process.env.BUILDMACHINE) {
done('Failed to compile extension source, see above.');
process.exit(1);
}
})
// TODO: Reinstate localization code
// .pipe(nls.rewriteLocalizeCalls())
// .pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false))
.pipe(srcmap.write('.', { sourceRoot: function(file) { return file.cwd + '/src'; }}))
.pipe(srcmap.write('.', {
sourceRoot: function (file) {
return file.cwd + '/src';
}
}))
.pipe(gulp.dest('out/src/'));
});
// COMPOSED GULP TASKS /////////////////////////////////////////////////////
gulp.task("compile", gulp.series("compile:src"));
gulp.task('compile', gulp.series('compile:src'));
gulp.task("build", gulp.series("clean", "lint", "compile"));
gulp.task('build', gulp.series('clean', 'lint', 'compile'));
gulp.task("watch", function() {
gulp.task('watch', function () {
gulp.watch([config.paths.project.root + '/src/**/*',
config.paths.project.root + '/test/**/*.ts'],
config.paths.project.root + '/test/**/*.ts'],
gulp.series('build'));
});

View File

@@ -1,7 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../src/sql/azdata.d.ts'/>
/// <reference types='@types/node'/>

File diff suppressed because it is too large Load Diff