Skip to content

Commit eb9c8ac

Browse files
committed
telemetry: Enable data fields that were disabled
#8617 disabled the telemetry fields as those database queries were causing heavy CPU performance. #8858 fixed that issue by adding indexes for those queries. This PR also adds tracing for the telemetry data provider so that we can also count how long they take usually, and how frequently these are called. Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent 37916d4 commit eb9c8ac

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

components/server/src/installation-admin/installation-admin-controller.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { injectable, inject } from "inversify";
88
import * as express from "express";
9+
import * as opentracing from "opentracing";
910
import { InstallationAdminTelemetryDataProvider } from "./telemetry-data-provider";
1011

1112
@injectable()
@@ -17,7 +18,14 @@ export class InstallationAdminController {
1718
const app = express();
1819

1920
app.get("/data", async (req: express.Request, res: express.Response) => {
20-
res.status(200).json(await this.telemetryDataProvider.getTelemetryData());
21+
const spanCtx =
22+
opentracing.globalTracer().extract(opentracing.FORMAT_HTTP_HEADERS, req.headers) || undefined;
23+
const span = opentracing.globalTracer().startSpan("telemetryDataEndpoint", { childOf: spanCtx });
24+
try {
25+
res.status(200).json(await this.telemetryDataProvider.getTelemetryData());
26+
} finally {
27+
span.finish();
28+
}
2129
});
2230

2331
return app;

components/server/src/installation-admin/telemetry-data-provider.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { injectable, inject } from "inversify";
88

99
import { TelemetryData } from "@gitpod/gitpod-protocol";
10+
import * as opentracing from "opentracing";
1011
import { InstallationAdminDB, UserDB, WorkspaceDB } from "@gitpod/gitpod-db/lib";
1112

1213
@injectable()
@@ -16,13 +17,17 @@ export class InstallationAdminTelemetryDataProvider {
1617
@inject(WorkspaceDB) protected readonly workspaceDb: WorkspaceDB;
1718

1819
async getTelemetryData(): Promise<TelemetryData> {
19-
const data: TelemetryData = {
20-
installationAdmin: await this.installationAdminDb.getData(),
21-
totalUsers: 0, //await this.userDb.getUserCount(true),
22-
totalWorkspaces: 0, //await this.workspaceDb.getWorkspaceCount(),
23-
totalInstances: 0, //await this.workspaceDb.getInstanceCount(),
24-
} as TelemetryData;
25-
26-
return data;
20+
const span = opentracing.globalTracer().startSpan("getTelemetryData");
21+
try {
22+
const data: TelemetryData = {
23+
installationAdmin: await this.installationAdminDb.getData(),
24+
totalUsers: await this.userDb.getUserCount(true),
25+
totalWorkspaces: await this.workspaceDb.getWorkspaceCount(),
26+
totalInstances: await this.workspaceDb.getInstanceCount(),
27+
} as TelemetryData;
28+
return data;
29+
} finally {
30+
span.finish();
31+
}
2732
}
2833
}

0 commit comments

Comments
 (0)