Skip to content

Commit 91f9fd2

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 656b666 commit 91f9fd2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

+5
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,11 @@ export class InstallationAdminController {
1718
const app = express();
1819

1920
app.get("/data", async (req: express.Request, res: express.Response) => {
21+
const spanCtx =
22+
opentracing.globalTracer().extract(opentracing.FORMAT_HTTP_HEADERS, req.headers) || undefined;
23+
const span = opentracing.globalTracer().startSpan("telemetryDataEndpoint", { childOf: spanCtx });
2024
res.status(200).json(await this.telemetryDataProvider.getTelemetryData());
25+
span.finish();
2126
});
2227

2328
return app;

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

+6-3
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,15 @@ export class InstallationAdminTelemetryDataProvider {
1617
@inject(WorkspaceDB) protected readonly workspaceDb: WorkspaceDB;
1718

1819
async getTelemetryData(): Promise<TelemetryData> {
20+
const span = opentracing.globalTracer().startSpan("getTelemetryData");
1921
const data: TelemetryData = {
2022
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(),
23+
totalUsers: await this.userDb.getUserCount(true),
24+
totalWorkspaces: await this.workspaceDb.getWorkspaceCount(),
25+
totalInstances: await this.workspaceDb.getInstanceCount(),
2426
} as TelemetryData;
2527

28+
span.finish();
2629
return data;
2730
}
2831
}

0 commit comments

Comments
 (0)