Add isContainer property to telemetry
This commit is contained in:
parent
b8cdab2184
commit
4563517d90
@ -30,7 +30,7 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
|||||||
import { ProtocolConstants } from 'vs/base/parts/ipc/common/ipc.net';
|
import { ProtocolConstants } from 'vs/base/parts/ipc/common/ipc.net';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
|
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
|
||||||
@@ -228,6 +228,9 @@ export async function setupServerService
|
@@ -239,6 +239,9 @@ export async function setupServerService
|
||||||
const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority));
|
const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority));
|
||||||
socketServer.registerChannel('extensions', channel);
|
socketServer.registerChannel('extensions', channel);
|
||||||
|
|
||||||
|
@ -20,14 +20,29 @@ Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
|||||||
import { NullPolicyService } from 'vs/platform/policy/common/policy';
|
import { NullPolicyService } from 'vs/platform/policy/common/policy';
|
||||||
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
|
import { OneDataSystemAppender } from 'vs/platform/telemetry/node/1dsAppender';
|
||||||
import { LoggerService } from 'vs/platform/log/node/loggerService';
|
import { LoggerService } from 'vs/platform/log/node/loggerService';
|
||||||
@@ -149,7 +150,10 @@ export async function setupServerService
|
@@ -146,10 +147,25 @@ export async function setupServerService
|
||||||
|
const requestService = new RequestService(configurationService, environmentService, logService, loggerService);
|
||||||
|
services.set(IRequestService, requestService);
|
||||||
|
|
||||||
|
+ let isContainer = undefined;
|
||||||
|
+ try {
|
||||||
|
+ await Promises.stat('/run/.containerenv');
|
||||||
|
+ isContainer = true;
|
||||||
|
+ } catch (error) { /* Does not exist, probably. */ }
|
||||||
|
+ if (!isContainer) {
|
||||||
|
+ try {
|
||||||
|
+ const content = await Promises.readFile('/proc/self/cgroup', 'utf8')
|
||||||
|
+ isContainer = content.includes('docker');
|
||||||
|
+ } catch (error) { /* Permission denied, probably. */ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
let oneDsAppender: ITelemetryAppender = NullAppender;
|
let oneDsAppender: ITelemetryAppender = NullAppender;
|
||||||
const isInternal = isInternalTelemetry(productService, configurationService);
|
const isInternal = isInternalTelemetry(productService, configurationService);
|
||||||
if (supportsTelemetry(productService, environmentService)) {
|
if (supportsTelemetry(productService, environmentService)) {
|
||||||
- if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
|
- if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
|
||||||
+ const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track";
|
+ const telemetryEndpoint = process.env.CS_TELEMETRY_URL || "https://v1.telemetry.coder.com/track";
|
||||||
+ if (telemetryEndpoint) {
|
+ if (telemetryEndpoint) {
|
||||||
+ oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint));
|
+ oneDsAppender = new OneDataSystemAppender(requestService, false, eventPrefix, null, () => new TelemetryClient(telemetryEndpoint, isContainer));
|
||||||
+ } else if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
|
+ } else if (!isLoggingOnly(productService, environmentService) && productService.aiConfig?.ariaKey) {
|
||||||
oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
|
oneDsAppender = new OneDataSystemAppender(requestService, isInternal, eventPrefix, null, productService.aiConfig.ariaKey);
|
||||||
disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
disposables.add(toDisposable(() => oneDsAppender?.flush())); // Ensure the AI appender is disposed so that it flushes remaining data
|
||||||
@ -36,14 +51,16 @@ Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
+++ code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
||||||
@@ -0,0 +1,49 @@
|
@@ -0,0 +1,53 @@
|
||||||
+import { AppInsightsCore, IExtendedTelemetryItem, ITelemetryItem } from '@microsoft/1ds-core-js';
|
+import { AppInsightsCore, IExtendedTelemetryItem, ITelemetryItem } from '@microsoft/1ds-core-js';
|
||||||
+import * as https from 'https';
|
+import * as https from 'https';
|
||||||
+import * as http from 'http';
|
+import * as http from 'http';
|
||||||
+import * as os from 'os';
|
+import * as os from 'os';
|
||||||
+
|
+
|
||||||
+export class TelemetryClient extends AppInsightsCore {
|
+export class TelemetryClient extends AppInsightsCore {
|
||||||
+ public constructor(private readonly endpoint: string) {
|
+ public constructor(
|
||||||
|
+ private readonly endpoint: string,
|
||||||
|
+ private readonly isContainer: Boolean | undefined) {
|
||||||
+ super();
|
+ super();
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -73,6 +90,8 @@ Index: code-server/lib/vscode/src/vs/server/node/telemetryClient.ts
|
|||||||
+ options.properties['common.arch'] = os.arch();
|
+ options.properties['common.arch'] = os.arch();
|
||||||
+ } catch (error) {}
|
+ } catch (error) {}
|
||||||
+
|
+
|
||||||
|
+ options.properties['common.isContainer'] = this.isContainer;
|
||||||
|
+
|
||||||
+ try {
|
+ try {
|
||||||
+ const request = (/^http:/.test(this.endpoint) ? http : https).request(this.endpoint, {
|
+ const request = (/^http:/.test(this.endpoint) ? http : https).request(this.endpoint, {
|
||||||
+ method: 'POST',
|
+ method: 'POST',
|
||||||
|
Reference in New Issue
Block a user