Skip to content

Commit 3741a50

Browse files
committed
[lssh] add telemetry logging
1 parent af5b12e commit 3741a50

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/commands/logs.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export class ExportLogsCommand implements Command {
3131
private readonly telemetryService: ITelemetryService,
3232
private readonly logService: ILogService,
3333
private readonly hostService: IHostService,
34-
) { }
34+
) {
35+
const lsshLog = this.getLSSHLog();
36+
if (lsshLog) {
37+
this.logService.info('LSSH Log:', lsshLog);
38+
}
39+
}
3540

3641
async execute() {
3742
const gitpodHost = this.hostService.gitpodHost;
@@ -57,12 +62,20 @@ export class ExportLogsCommand implements Command {
5762

5863
private getAdditionalLocalLogs() {
5964
const additionalLocalLogs = [];
65+
const lsshLog = this.getLSSHLog();
66+
if (lsshLog) {
67+
additionalLocalLogs.push(lsshLog);
68+
}
69+
return additionalLocalLogs;
70+
}
71+
72+
private getLSSHLog(): string | undefined {
6073
const sshDestStr = getGitpodRemoteWindowConnectionInfo(this.context)?.sshDestStr;
6174
if (sshDestStr) {
6275
const sshDest = SSHDestination.fromRemoteSSHString(sshDestStr);
63-
additionalLocalLogs.push(path.join(os.tmpdir(), `lssh-${sshDest.hostname}.log`));
76+
return path.join(os.tmpdir(), `lssh-${sshDest.hostname}.log`);
6477
}
65-
return additionalLocalLogs;
78+
return undefined;
6679
}
6780

6881
async exportLogs() {

src/common/telemetry.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ export function getErrorMetricsEndpoint(gitpodHost: string): string {
6969
return `https://ide.${serviceUrl.hostname}/metrics-api/reportError`;
7070
}
7171

72-
export async function commonSendEventData(logService: ILogService, segmentClient: Analytics, machineId: string, eventName: string, data?: any): Promise<void> {
72+
export async function commonSendEventData(logService: ILogService, segmentClient: Analytics | undefined, machineId: string, eventName: string, data?: any): Promise<void> {
7373
const properties = data ?? {};
7474

7575
delete properties['gitpodHost'];
7676

77-
if (!isBuiltFromGHA) {
78-
logService.trace('Local event report', eventName, properties);
77+
logService.trace('[TELEMETRY]', eventName, properties);
78+
79+
if (!segmentClient) {
7980
return;
8081
}
8182
return new Promise((resolve) =>

src/local-ssh/telemetryService.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ export class TelemetryService implements ITelemetryService {
3434

3535
async sendEventData(eventName: string, data?: Record<string, any>): Promise<void> {
3636
const properties = mixin(cleanData(data ?? {}, this.cleanupPatterns, isTrustedValue), this.commonProperties);
37-
38-
if (!this.segmentClient) {
39-
return;
40-
}
41-
4237
return commonSendEventData(this.logService, this.segmentClient, this.machineId, eventName, properties);
4338
}
4439

0 commit comments

Comments
 (0)