mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add additional telemetry for basic admin operations (#24526)
This commit is contained in:
@@ -130,7 +130,13 @@ async function handleNewObjectDialogCommand(context: azdata.ObjectExplorerContex
|
|||||||
objectExplorerContext: context
|
objectExplorerContext: context
|
||||||
};
|
};
|
||||||
const dialog = getDialog(service, options);
|
const dialog = getDialog(service, options);
|
||||||
|
const startTime = Date.now();
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenNewObjectDialog, {
|
||||||
|
objectType: objectType
|
||||||
|
}, {
|
||||||
|
elapsedTimeMs: Date.now() - startTime
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenNewObjectDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenNewObjectDialog, err).withAdditionalProperties({
|
||||||
@@ -159,7 +165,13 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
|
|||||||
objectExplorerContext: context
|
objectExplorerContext: context
|
||||||
};
|
};
|
||||||
const dialog = getDialog(service, options);
|
const dialog = getDialog(service, options);
|
||||||
|
const startTime = Date.now();
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenPropertiesDialog, {
|
||||||
|
objectType: object.type
|
||||||
|
}, {
|
||||||
|
elapsedTimeMs: Date.now() - startTime
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenPropertiesDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenPropertiesDialog, err).withAdditionalProperties({
|
||||||
@@ -297,7 +309,13 @@ async function handleDetachDatabase(context: azdata.ObjectExplorerContext, servi
|
|||||||
objectExplorerContext: context
|
objectExplorerContext: context
|
||||||
};
|
};
|
||||||
const dialog = new DetachDatabaseDialog(service, options);
|
const dialog = new DetachDatabaseDialog(service, options);
|
||||||
|
const startTime = Date.now();
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenDetachDatabaseDialog, {
|
||||||
|
objectType: object.type
|
||||||
|
}, {
|
||||||
|
elapsedTimeMs: Date.now() - startTime
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDetachDatabaseDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDetachDatabaseDialog, err).withAdditionalProperties({
|
||||||
@@ -325,7 +343,13 @@ async function handleAttachDatabase(context: azdata.ObjectExplorerContext, servi
|
|||||||
objectExplorerContext: context
|
objectExplorerContext: context
|
||||||
};
|
};
|
||||||
const dialog = new AttachDatabaseDialog(service, options);
|
const dialog = new AttachDatabaseDialog(service, options);
|
||||||
|
const startTime = Date.now();
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenAttachDatabaseDialog, {
|
||||||
|
objectType: ObjectManagement.NodeType.Database
|
||||||
|
}, {
|
||||||
|
elapsedTimeMs: Date.now() - startTime
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenAttachDatabaseDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenAttachDatabaseDialog, err).withAdditionalProperties({
|
||||||
@@ -357,7 +381,13 @@ async function handleDropDatabase(context: azdata.ObjectExplorerContext, service
|
|||||||
objectExplorerContext: context
|
objectExplorerContext: context
|
||||||
};
|
};
|
||||||
const dialog = new DropDatabaseDialog(service, options);
|
const dialog = new DropDatabaseDialog(service, options);
|
||||||
|
const startTime = Date.now();
|
||||||
await dialog.open();
|
await dialog.open();
|
||||||
|
TelemetryReporter.sendTelemetryEvent(TelemetryActions.OpenDropDatabaseDialog, {
|
||||||
|
objectType: object.type
|
||||||
|
}, {
|
||||||
|
elapsedTimeMs: Date.now() - startTime
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDropDatabaseDialog, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, TelemetryActions.OpenDropDatabaseDialog, err).withAdditionalProperties({
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ export const enum TelemetryActions {
|
|||||||
UpdateObject = 'UpdateObject',
|
UpdateObject = 'UpdateObject',
|
||||||
OpenDetachDatabaseDialog = 'OpenDetachDatabaseDialog',
|
OpenDetachDatabaseDialog = 'OpenDetachDatabaseDialog',
|
||||||
OpenAttachDatabaseDialog = 'OpenAttachDatabaseDialog',
|
OpenAttachDatabaseDialog = 'OpenAttachDatabaseDialog',
|
||||||
OpenDropDatabaseDialog = 'OpenDropDatabaseDialog'
|
OpenDropDatabaseDialog = 'OpenDropDatabaseDialog',
|
||||||
|
AttachDatabase = 'AttachDatabase',
|
||||||
|
DetachDatabase = 'DetachDatabase'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ObjectManagementViewName = 'ObjectManagement';
|
export const ObjectManagementViewName = 'ObjectManagement';
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as azdata from 'azdata';
|
|||||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||||
import { DatabaseFileData, IObjectManagementService, ObjectManagement } from 'mssql';
|
import { DatabaseFileData, IObjectManagementService, ObjectManagement } from 'mssql';
|
||||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||||
import { AttachDatabaseDocUrl } from '../constants';
|
import { AttachDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
import { RemoveText } from '../../ui/localizedConstants';
|
import { RemoveText } from '../../ui/localizedConstants';
|
||||||
import { DefaultMinTableRowCount, DialogButton, getTableHeight } from '../../ui/dialogBase';
|
import { DefaultMinTableRowCount, DialogButton, getTableHeight } from '../../ui/dialogBase';
|
||||||
@@ -178,6 +178,10 @@ export class AttachDatabaseDialog extends ObjectManagementDialogBase<Database, D
|
|||||||
return AttachDatabaseDocUrl;
|
return AttachDatabaseDocUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override get actionName(): string {
|
||||||
|
return TelemetryActions.AttachDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async validateInput(): Promise<string[]> {
|
protected override async validateInput(): Promise<string[]> {
|
||||||
let errors = [];
|
let errors = [];
|
||||||
if (this._databasesToAttach.length === 0) {
|
if (this._databasesToAttach.length === 0) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||||
import { DetachDatabaseDocUrl } from '../constants';
|
import { DetachDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
||||||
@@ -48,6 +48,10 @@ export class DetachDatabaseDialog extends ObjectManagementDialogBase<Database, D
|
|||||||
return DetachDatabaseDocUrl;
|
return DetachDatabaseDocUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override get actionName(): string {
|
||||||
|
return TelemetryActions.DetachDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
||||||
await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._updateStatistics, false);
|
await this.objectManagementService.detachDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._updateStatistics, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||||
import { Database, DatabaseViewInfo } from '../interfaces';
|
import { Database, DatabaseViewInfo } from '../interfaces';
|
||||||
import { DropDatabaseDocUrl } from '../constants';
|
import { DropDatabaseDocUrl, TelemetryActions } from '../constants';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, DatabaseViewInfo> {
|
||||||
@@ -52,6 +52,10 @@ export class DropDatabaseDialog extends ObjectManagementDialogBase<Database, Dat
|
|||||||
return DropDatabaseDocUrl;
|
return DropDatabaseDocUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override get actionName(): string {
|
||||||
|
return TelemetryActions.DropObject;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
protected override async saveChanges(contextId: string, object: ObjectManagement.SqlObject): Promise<void> {
|
||||||
await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._deleteBackupHistory, false);
|
await this.objectManagementService.dropDatabase(this.options.connectionUri, this.options.database, this._dropConnections, this._deleteBackupHistory, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
: localizedConstants.UpdateObjectOperationDisplayName(typeDisplayName, this.options.objectName);
|
: localizedConstants.UpdateObjectOperationDisplayName(typeDisplayName, this.options.objectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected get actionName(): string {
|
||||||
|
return this.options.isNewObject ? TelemetryActions.CreateObject : TelemetryActions.UpdateObject;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async initialize(): Promise<void> {
|
protected override async initialize(): Promise<void> {
|
||||||
await super.initialize();
|
await super.initialize();
|
||||||
this.dialogObject.registerOperation({
|
this.dialogObject.registerOperation({
|
||||||
@@ -75,7 +79,6 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
description: '',
|
description: '',
|
||||||
isCancelable: false,
|
isCancelable: false,
|
||||||
operation: async (operation: azdata.BackgroundOperation): Promise<void> => {
|
operation: async (operation: azdata.BackgroundOperation): Promise<void> => {
|
||||||
const actionName = this.options.isNewObject ? TelemetryActions.CreateObject : TelemetryActions.UpdateObject;
|
|
||||||
try {
|
try {
|
||||||
if (this.isDirty) {
|
if (this.isDirty) {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
@@ -89,7 +92,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TelemetryReporter.sendTelemetryEvent(actionName, {
|
TelemetryReporter.sendTelemetryEvent(this.actionName, {
|
||||||
objectType: this.options.objectType
|
objectType: this.options.objectType
|
||||||
}, {
|
}, {
|
||||||
elapsedTimeMs: Date.now() - startTime
|
elapsedTimeMs: Date.now() - startTime
|
||||||
@@ -99,7 +102,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
|
|||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
operation.updateStatus(azdata.TaskStatus.Failed, getErrorMessage(err));
|
operation.updateStatus(azdata.TaskStatus.Failed, getErrorMessage(err));
|
||||||
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, actionName, err).withAdditionalProperties({
|
TelemetryReporter.createErrorEvent2(ObjectManagementViewName, this.actionName, err).withAdditionalProperties({
|
||||||
objectType: this.options.objectType
|
objectType: this.options.objectType
|
||||||
}).send();
|
}).send();
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user