Skip to content
Extraits de code Groupes Projets
Valider f0197836 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Do not use default

parent 8ff8860c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -15,7 +15,7 @@ limitations under the License. ...@@ -15,7 +15,7 @@ limitations under the License.
*/ */
/* eslint-disable max-classes-per-file, @typescript-eslint/no-empty-function */ /* eslint-disable max-classes-per-file, @typescript-eslint/no-empty-function */
import { Gauge, Counter, Histogram, default as promClient } from "prom-client"; import { Gauge, Counter, Histogram, collectDefaultMetrics, register } from "prom-client";
import { Log } from "./log"; import { Log } from "./log";
import { Appservice, import { Appservice,
IMetricContext, IMetricContext,
...@@ -69,15 +69,16 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics { ...@@ -69,15 +69,16 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics {
private httpServer: http.Server; private httpServer: http.Server;
public init(as: Appservice, config: DiscordBridgeConfigMetrics) { public init(as: Appservice, config: DiscordBridgeConfigMetrics) {
promClient.collectDefaultMetrics(); collectDefaultMetrics();
// TODO: Bind this for every user. // TODO: Bind this for every user.
this.httpServer = http.createServer((req, res) => { this.httpServer = http.createServer((req, res) => {
if (req.method !== "GET" || req.url !== "/metrics") { if (req.method !== "GET" || req.url !== "/metrics") {
res.writeHead(404, "Not found"); res.writeHead(404, "Not found");
res.end(); res.end();
return;
} }
res.writeHead(200, "OK", {"Content-Type": promClient.register.contentType}); res.writeHead(200, "OK", {"Content-Type": register.contentType});
res.write(promClient.register.metrics()); res.write(register.metrics());
res.end(); res.end();
}); });
this.matrixCallCounter = new Counter({ this.matrixCallCounter = new Counter({
...@@ -85,41 +86,41 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics { ...@@ -85,41 +86,41 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics {
labelNames: ["method", "result"], labelNames: ["method", "result"],
name: "matrix_api_calls", name: "matrix_api_calls",
}); });
promClient.register.registerMetric(this.matrixCallCounter); register.registerMetric(this.matrixCallCounter);
this.remoteCallCounter = new Counter({ this.remoteCallCounter = new Counter({
help: "Count of remote API calls made", help: "Count of remote API calls made",
labelNames: ["method"], labelNames: ["method"],
name: "remote_api_calls", name: "remote_api_calls",
}); });
promClient.register.registerMetric(this.remoteCallCounter); register.registerMetric(this.remoteCallCounter);
this.storeCallCounter = new Counter({ this.storeCallCounter = new Counter({
help: "Count of store function calls made", help: "Count of store function calls made",
labelNames: ["method", "cached"], labelNames: ["method", "cached"],
name: "store_calls", name: "store_calls",
}); });
promClient.register.registerMetric(this.storeCallCounter); register.registerMetric(this.storeCallCounter);
this.presenceGauge = new Gauge({ this.presenceGauge = new Gauge({
help: "Count of users in the presence queue", help: "Count of users in the presence queue",
name: "active_presence_users", name: "active_presence_users",
}); });
promClient.register.registerMetric(this.presenceGauge); register.registerMetric(this.presenceGauge);
this.matrixRequest = new Histogram({ this.matrixRequest = new Histogram({
help: "Histogram of processing durations of received Matrix messages", help: "Histogram of processing durations of received Matrix messages",
labelNames: ["outcome"], labelNames: ["outcome"],
name: "matrix_request_seconds", name: "matrix_request_seconds",
}); });
promClient.register.registerMetric(this.matrixRequest); register.registerMetric(this.matrixRequest);
this.remoteRequest = new Histogram({ this.remoteRequest = new Histogram({
help: "Histogram of processing durations of received remote messages", help: "Histogram of processing durations of received remote messages",
labelNames: ["outcome"], labelNames: ["outcome"],
name: "remote_request_seconds", name: "remote_request_seconds",
}); });
promClient.register.registerMetric(this.remoteRequest); register.registerMetric(this.remoteRequest);
this.requestsInFlight = new Map(); this.requestsInFlight = new Map();
setInterval(() => { setInterval(() => {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter