diff --git a/components/gitpod-protocol/package.json b/components/gitpod-protocol/package.json index 5189ca4973fdf5..5078f9822e0058 100644 --- a/components/gitpod-protocol/package.json +++ b/components/gitpod-protocol/package.json @@ -41,11 +41,13 @@ "jaeger-client": "3.17.2", "js-yaml": "^3.10.0", "opentracing": "^0.14.4", - "prom-client": "^10.2.0", + "prom-client": "^13.2.0", "random-number-csprng": "^1.0.2", "reconnecting-websocket": "^4.4.0", "reflect-metadata": "^0.1.10", "uuid": "^3.3.3", + "vscode-jsonrpc": "^5.0.1", + "vscode-languageserver-protocol": "3.15.3", "vscode-uri": "^1.0.1", "vscode-ws-jsonrpc": "^0.2.0", "ws": "^7.4.6" diff --git a/components/gitpod-protocol/src/messaging/client-call-metrics.ts b/components/gitpod-protocol/src/messaging/client-call-metrics.ts index 47cd048d353e4c..9d2d90762e0775 100644 --- a/components/gitpod-protocol/src/messaging/client-call-metrics.ts +++ b/components/gitpod-protocol/src/messaging/client-call-metrics.ts @@ -30,10 +30,10 @@ export interface IClientCallMetrics { @injectable() export class PrometheusClientCallMetrics implements IClientCallMetrics { - readonly startedCounter: prometheusClient.Counter; - readonly sentCounter: prometheusClient.Counter; - readonly receivedCounter: prometheusClient.Counter; - readonly handledCounter: prometheusClient.Counter; + readonly startedCounter: prometheusClient.Counter; + readonly sentCounter: prometheusClient.Counter; + readonly receivedCounter: prometheusClient.Counter; + readonly handledCounter: prometheusClient.Counter; constructor() { this.startedCounter = new prometheusClient.Counter({ diff --git a/components/server/ee/src/monitoring-endpoint-ee.ts b/components/server/ee/src/monitoring-endpoint-ee.ts index 7938a9ac977b67..c5475f981e8d4e 100644 --- a/components/server/ee/src/monitoring-endpoint-ee.ts +++ b/components/server/ee/src/monitoring-endpoint-ee.ts @@ -20,7 +20,7 @@ export class MonitoringEndpointsAppEE extends WorkspaceHealthMonitoring { monApp.get('/metrics', async (req, res) => { try { res.set('Content-Type', register.contentType); - res.end(register.metrics()); + res.end(await register.metrics()); } catch (ex) { res.status(500).end(ex); } diff --git a/components/server/ee/src/prebuilds/prebuild-queue-maintainer.ts b/components/server/ee/src/prebuilds/prebuild-queue-maintainer.ts index a7e5f5c1fdaf7d..07721908e92574 100644 --- a/components/server/ee/src/prebuilds/prebuild-queue-maintainer.ts +++ b/components/server/ee/src/prebuilds/prebuild-queue-maintainer.ts @@ -132,8 +132,7 @@ export class PrebuildQueueMaintainer implements Disposable { await this.workspaceStarter.startWorkspace({span}, workspace, user); } - const t = new Date(); - Array.from(queueLengths.keys()).forEach(q => this.prometheusAdapter.storePrebuildQueueLength(t, q, queueLengths.get(q) || 0)); + Array.from(queueLengths.keys()).forEach(q => this.prometheusAdapter.storePrebuildQueueLength(q, queueLengths.get(q) || 0)); } catch (err) { TraceContext.logError({span}, err); throw err; diff --git a/components/server/package.json b/components/server/package.json index cb80a966ec6ed1..df4357171c409c 100644 --- a/components/server/package.json +++ b/components/server/package.json @@ -76,7 +76,7 @@ "passport-gitlab2": "5.0.0", "passport-http": "^0.3.0", "probot": "11.4.0", - "prom-client": "^10.2.0", + "prom-client": "^13.2.0", "rate-limiter-flexible": "^2.2.1", "reflect-metadata": "^0.1.10", "swot-js": "^1.0.3", diff --git a/components/server/src/prometheus-metrics.ts b/components/server/src/prometheus-metrics.ts index ddf410d17db390..032ffc57cd1b71 100644 --- a/components/server/src/prometheus-metrics.ts +++ b/components/server/src/prometheus-metrics.ts @@ -7,7 +7,7 @@ import * as prometheusClient from 'prom-client'; // Enable collection of default metrics. -prometheusClient.collectDefaultMetrics({ timeout: 5000 }); +prometheusClient.collectDefaultMetrics(); export const register = prometheusClient.register; const loginCounter = new prometheusClient.Counter({ diff --git a/components/server/src/workspace/client-data-prometheus-adapter.ts b/components/server/src/workspace/client-data-prometheus-adapter.ts index bac5c454c2df11..7666acc2c93cbf 100644 --- a/components/server/src/workspace/client-data-prometheus-adapter.ts +++ b/components/server/src/workspace/client-data-prometheus-adapter.ts @@ -8,8 +8,8 @@ import { User } from "@gitpod/gitpod-protocol"; export const IClientDataPrometheusAdapter = Symbol('IClientDataPrometheusAdapter'); export interface IClientDataPrometheusAdapter { - storeWorkspaceRoundTripTimeSample(time: Date, user: User, workspaceId: string, roundTripTimeInMilliseconds: number): void; - storePrebuildQueueLength(time: Date, cloneURL: string, queueLength: number): void; + storeWorkspaceRoundTripTimeSample(user: User, workspaceId: string, roundTripTimeInMilliseconds: number): void; + storePrebuildQueueLength(cloneURL: string, queueLength: number): void; } import * as prom from 'prom-client'; @@ -19,8 +19,8 @@ import { Config } from "../config"; @injectable() export class ClientDataPrometheusAdapterImpl implements IClientDataPrometheusAdapter { @inject(Config) protected readonly config: Config; - protected readonly roundTripTimeGauge: prom.Gauge; - protected readonly prebuildQueueSizeGauge: prom.Gauge; + protected readonly roundTripTimeGauge: prom.Gauge; + protected readonly prebuildQueueSizeGauge: prom.Gauge; constructor() { this.roundTripTimeGauge = new prom.Gauge({ @@ -35,12 +35,12 @@ export class ClientDataPrometheusAdapterImpl implements IClientDataPrometheusAda }) } - storeWorkspaceRoundTripTimeSample(time: Date, user: User, workspaceId: string, roundTripTimeInMilliseconds: number): void { - this.roundTripTimeGauge.set({ user: user.id, workspace: workspaceId, region: this.config.installationShortname }, roundTripTimeInMilliseconds, time); + storeWorkspaceRoundTripTimeSample(user: User, workspaceId: string, roundTripTimeInMilliseconds: number): void { + this.roundTripTimeGauge.set({ user: user.id, workspace: workspaceId, region: this.config.installationShortname }, roundTripTimeInMilliseconds); } - storePrebuildQueueLength(time: Date, cloneURL: string, queueLength: number): void { - this.prebuildQueueSizeGauge.set({ cloneURL, region: this.config.installationShortname }, queueLength, time); + storePrebuildQueueLength(cloneURL: string, queueLength: number): void { + this.prebuildQueueSizeGauge.set({ cloneURL, region: this.config.installationShortname }, queueLength); } } \ No newline at end of file diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index 1f76dd1dcd1047..2f9fc7ca89cc90 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -686,7 +686,7 @@ export class GitpodServerImpl { tracingManager.setup("ws-manager-bridge"); const metricsApp = express(); - prometheusClient.collectDefaultMetrics({ timeout: 5000 }); - metricsApp.get('/metrics', (req, res) => { - res.send(prometheusClient.register.metrics().toString()); + prometheusClient.collectDefaultMetrics(); + metricsApp.get('/metrics', async (req, res) => { + res.set('Content-Type', prometheusClient.register.contentType); + res.send(await prometheusClient.register.metrics()); }); const metricsPort = 9500; const metricsHttpServer = metricsApp.listen(metricsPort, 'localhost', () => { diff --git a/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts b/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts index 403facf750359a..56182c9ca4b5dc 100644 --- a/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts +++ b/components/ws-manager-bridge/src/prometheus-metrics-exporter.ts @@ -11,10 +11,10 @@ import { WorkspaceClusterWoTLS } from '@gitpod/gitpod-protocol/src/workspace-clu @injectable() export class PrometheusMetricsExporter { - protected readonly workspaceStartupTimeHistogram: prom.Histogram; - protected readonly timeToFirstUserActivityHistogram: prom.Histogram; - protected readonly clusterScore: prom.Gauge; - protected readonly clusterCordoned: prom.Gauge; + protected readonly workspaceStartupTimeHistogram: prom.Histogram; + protected readonly timeToFirstUserActivityHistogram: prom.Histogram; + protected readonly clusterScore: prom.Gauge; + protected readonly clusterCordoned: prom.Gauge; constructor() { this.workspaceStartupTimeHistogram = new prom.Histogram({ diff --git a/yarn.lock b/yarn.lock index b1b4d9065c77ae..2ac19904f70344 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4665,7 +4665,7 @@ "@types/history" "*" "@types/react" "*" -"@types/react@*", "@types/react@17.0.0", "@types/react@^17.0.0": +"@types/react@*", "@types/react@^17.0.0": version "17.0.0" resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.0.tgz#5af3eb7fad2807092f0046a1302b7823e27919b8" integrity sha512-aj/L7RIMsRlWML3YB6KZiXB3fV2t41+5RBGYF8z+tAKU43Px8C3cYUZsDvf1/+Bm4FK21QWBrDutu8ZJ/70qOw== @@ -14859,7 +14859,7 @@ mz@^2.4.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nan@2.14.1, nan@^2.12.1, nan@^2.13.2, nan@^2.14.0, nan@^2.9.2: +nan@^2.12.1, nan@^2.13.2, nan@^2.9.2: version "2.14.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== @@ -15406,13 +15406,6 @@ onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" -oniguruma@7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/oniguruma/-/oniguruma-7.2.1.tgz#51775834f7819b6e31aa878706aa7f65ad16b07f" - integrity sha512-WPS/e1uzhswPtJSe+Zls/kAj27+lEqZjCmRSjnYk/Z4L2Mu+lJC2JWtkZhPJe4kZeTQfz7ClcLyXlI4J68MG2w== - dependencies: - nan "^2.14.0" - open@^7.0.2: version "7.4.2" resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" @@ -17195,9 +17188,10 @@ progress@^2.0.0, progress@^2.0.1: resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== -prom-client@^10.2.0: - version "10.2.3" - resolved "http://registry.npmjs.org/prom-client/-/prom-client-10.2.3.tgz#a51bf21c239c954a6c5be4b1361fdd380218bb41" +prom-client@^13.2.0: + version "13.2.0" + resolved "https://registry.yarnpkg.com/prom-client/-/prom-client-13.2.0.tgz#99d13357912dd400f8911b77df19f7b328a93e92" + integrity sha512-wGr5mlNNdRNzEhRYXgboUU2LxHWIojxscJKmtG3R8f4/KiWqyYgXTLHs0+Ted7tG3zFT7pgHJbtomzZ1L0ARaQ== dependencies: tdigest "^0.1.1" @@ -17546,7 +17540,7 @@ react-dev-utils@^11.0.3: strip-ansi "6.0.0" text-table "0.2.0" -react-dom@17.0.1, react-dom@^17.0.1: +react-dom@^17.0.1: version "17.0.1" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.1.tgz#1de2560474ec9f0e334285662ede52dbc5426fc6" integrity sha512-6eV150oJZ9U2t9svnsspTMrWNyHc6chX0KzDeAOXftRa8bNeOKTTfCJ7KorIwenkHd2xqVTBTCZd79yk/lx/Ug== @@ -17675,7 +17669,7 @@ react-scripts@^4.0.3: optionalDependencies: fsevents "^2.1.3" -react@17.0.1, react@^17.0.1: +react@^17.0.1: version "17.0.1" resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127" integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==