diff --git a/components/server/src/installation-admin/installation-admin-controller.ts b/components/server/src/installation-admin/installation-admin-controller.ts index b1b896390e5282..33eeb28ba6fde4 100644 --- a/components/server/src/installation-admin/installation-admin-controller.ts +++ b/components/server/src/installation-admin/installation-admin-controller.ts @@ -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() @@ -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; diff --git a/components/server/src/installation-admin/telemetry-data-provider.ts b/components/server/src/installation-admin/telemetry-data-provider.ts index 2538ff90ff1dd8..6bab1545f3fe46 100644 --- a/components/server/src/installation-admin/telemetry-data-provider.ts +++ b/components/server/src/installation-admin/telemetry-data-provider.ts @@ -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() @@ -16,13 +17,17 @@ export class InstallationAdminTelemetryDataProvider { @inject(WorkspaceDB) protected readonly workspaceDb: WorkspaceDB; async getTelemetryData(): Promise { - 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(); + } } }