mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
writing telemetry into a file when running the app for perf tests (#802)
This commit is contained in:
43
src/sql/platform/telemetry/fileTelemetryService.ts
Normal file
43
src/sql/platform/telemetry/fileTelemetryService.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* Write telemetry into a file for test purposes
|
||||
*/
|
||||
export class FileTelemetryService implements ITelemetryService {
|
||||
_serviceBrand: undefined;
|
||||
private _isFirst = true;
|
||||
|
||||
constructor(private _outputFile: string) {
|
||||
}
|
||||
|
||||
publicLog(eventName: string, data?: ITelemetryData) {
|
||||
let telemetryData = JSON.stringify(Object.assign({eventName: eventName, data: data}));
|
||||
if (this._outputFile) {
|
||||
if (this._isFirst) {
|
||||
fs.open(this._outputFile, fs.O_WRONLY | fs.O_CREAT, (err, fr) => {
|
||||
fs.writeFileSync(this._outputFile, telemetryData + '\n');
|
||||
this._isFirst = false;
|
||||
});
|
||||
} else {
|
||||
fs.appendFileSync(this._outputFile, telemetryData + '\n');
|
||||
}
|
||||
}
|
||||
return TPromise.wrap<void>(null);
|
||||
}
|
||||
isOptedIn: true;
|
||||
getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
return TPromise.wrap({
|
||||
instanceId: 'someValue.instanceId',
|
||||
sessionId: 'someValue.sessionId',
|
||||
machineId: 'someValue.machineId'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -89,6 +89,9 @@ import { HashService } from 'vs/workbench/services/hash/node/hashService';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { FileTelemetryService } from 'sql/platform/telemetry/fileTelemetryService';
|
||||
|
||||
/**
|
||||
* Services that we require for the Shell
|
||||
*/
|
||||
@@ -315,9 +318,12 @@ export class WorkbenchShell {
|
||||
// Experiments
|
||||
this.experimentService = instantiationService.createInstance(ExperimentService);
|
||||
serviceCollection.set(IExperimentService, this.experimentService);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (this.environmentService.args['perf-test']) {
|
||||
let telemetryOutput = this.environmentService.args['telemetry-output'];
|
||||
this.telemetryService = new FileTelemetryService(telemetryOutput);
|
||||
// Telemetry
|
||||
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
|
||||
} else if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
|
||||
const channel = getDelayedChannel<ITelemetryAppenderChannel>(sharedProcess.then(c => c.getChannel('telemetryAppender')));
|
||||
const commit = product.commit;
|
||||
const version = pkg.version;
|
||||
|
||||
Reference in New Issue
Block a user