Move appenders to be better controlled by services (#133465)

* Cleanup telemetry appenders to be owned by service

* Add telemetry level to services

* simplify

* Fix compile

* Rename supportsTelemetryLogging -> supportsTelemetry

Co-authored-by: SteVen Batten <sbatten@microsoft.com>
This commit is contained in:
Logan Ramos
2021-09-22 10:39:57 -04:00
committed by GitHub
parent 758daa73e3
commit 12ae331012
23 changed files with 144 additions and 171 deletions
+8 -5
View File
@@ -43,9 +43,9 @@ import { IProductService } from 'vs/platform/product/common/productService';
import { IRequestService } from 'vs/platform/request/common/request';
import { RequestService } from 'vs/platform/request/node/requestService';
import { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties';
import { ITelemetryService, machineIdKey, TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryService, machineIdKey } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { combinedAppender, getTelemetryLevel, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { supportsTelemetry, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { buildTelemetryMessage } from 'vs/platform/telemetry/node/telemetry';
@@ -89,7 +89,10 @@ class CliMain extends Disposable {
await this.doRun(environmentService, extensionManagementCLIService, fileService);
// Flush the remaining data in AI adapter (with 1s timeout)
return raceTimeout(combinedAppender(...appenders).flush(), 1000);
await Promise.all(appenders.map(a => {
raceTimeout(a.flush(), 1000);
}));
return;
});
}
@@ -148,7 +151,7 @@ class CliMain extends Disposable {
// Telemetry
const appenders: AppInsightsAppender[] = [];
if (getTelemetryLevel(productService, environmentService) >= TelemetryLevel.USER) {
if (supportsTelemetry(productService, environmentService)) {
if (productService.aiConfig && productService.aiConfig.asimovKey) {
appenders.push(new AppInsightsAppender('monacoworkbench', null, productService.aiConfig.asimovKey));
}
@@ -156,7 +159,7 @@ class CliMain extends Disposable {
const { appRoot, extensionsPath, installSourcePath } = environmentService;
const config: ITelemetryServiceConfig = {
appender: combinedAppender(...appenders),
appenders,
sendErrorTelemetry: false,
commonProperties: (async () => {
let machineId: string | undefined = undefined;