Skip to content

Commit

Permalink
telemetry: Enable data fields that were disabled
Browse files Browse the repository at this point in the history
#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 <tarun@gitpod.io>
  • Loading branch information
Pothulapati committed Mar 30, 2022
1 parent 543bcac commit 8bd705c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { injectable, inject } from "inversify";
import * as express from "express";
import * as opentracing from "opentracing";
import { InstallationAdminTelemetryDataProvider } from "./telemetry-data-provider";

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

app.get("/data", async (req: express.Request, res: express.Response) => {
res.status(200).json(await this.telemetryDataProvider.getTelemetryData());
const spanCtx =
opentracing.globalTracer().extract(opentracing.FORMAT_HTTP_HEADERS, req.headers) || undefined;
const span = opentracing.globalTracer().startSpan("telemetryDataEndpoint", { childOf: spanCtx });
try {
res.status(200).json(await this.telemetryDataProvider.getTelemetryData());
} finally {
span.finish();
}
});

return app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { injectable, inject } from "inversify";

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

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

async getTelemetryData(): Promise<TelemetryData> {
const data: TelemetryData = {
installationAdmin: await this.installationAdminDb.getData(),
totalUsers: 0, //await this.userDb.getUserCount(true),
totalWorkspaces: 0, //await this.workspaceDb.getWorkspaceCount(),
totalInstances: 0, //await this.workspaceDb.getInstanceCount(),
} as TelemetryData;

return data;
const span = opentracing.globalTracer().startSpan("getTelemetryData");
try {
const data: TelemetryData = {
installationAdmin: await this.installationAdminDb.getData(),
totalUsers: await this.userDb.getUserCount(true),
totalWorkspaces: await this.workspaceDb.getWorkspaceCount(),
totalInstances: await this.workspaceDb.getInstanceCount(),
} as TelemetryData;
return data;
} finally {
span.finish();
}
}
}

0 comments on commit 8bd705c

Please sign in to comment.