Skip to content

Commit

Permalink
Update node prometheus library to 13.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf authored and roboquat committed Sep 17, 2021
1 parent b338a87 commit a1dc90b
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 41 deletions.
4 changes: 3 additions & 1 deletion components/gitpod-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
readonly sentCounter: prometheusClient.Counter<string>;
readonly receivedCounter: prometheusClient.Counter<string>;
readonly handledCounter: prometheusClient.Counter<string>;

constructor() {
this.startedCounter = new prometheusClient.Counter({
Expand Down
2 changes: 1 addition & 1 deletion components/server/ee/src/monitoring-endpoint-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/prometheus-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string>;
protected readonly prebuildQueueSizeGauge: prom.Gauge<string>;

constructor() {
this.roundTripTimeGauge = new prom.Gauge({
Expand All @@ -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);
}

}
2 changes: 1 addition & 1 deletion components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export class GitpodServerImpl<Client extends GitpodClient, Server extends Gitpod
await client.markActive({ span }, req);

if (options && options.roundTripTime && Number.isFinite(options.roundTripTime)) {
this.clientDataPrometheusAdapter.storeWorkspaceRoundTripTimeSample(new Date(), user, instanceId, options.roundTripTime);
this.clientDataPrometheusAdapter.storeWorkspaceRoundTripTimeSample(user, instanceId, options.roundTripTime);
}
} catch (e) {
TraceContext.logError({ span }, e);
Expand Down
2 changes: 1 addition & 1 deletion components/ws-manager-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"amqplib": "^0.5.2",
"express": "^4.16.1",
"inversify": "^5.0.1",
"prom-client": "^10.2.0",
"prom-client": "^13.2.0",
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions components/ws-manager-bridge/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ export const start = async (container: Container) => {
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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
protected readonly timeToFirstUserActivityHistogram: prom.Histogram<string>;
protected readonly clusterScore: prom.Gauge<string>;
protected readonly clusterCordoned: prom.Gauge<string>;

constructor() {
this.workspaceStartupTimeHistogram = new prom.Histogram({
Expand Down
22 changes: 8 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit a1dc90b

Please sign in to comment.