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.
*/
/* 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 { Appservice,
IMetricContext,
......@@ -69,15 +69,16 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics {
private httpServer: http.Server;
public init(as: Appservice, config: DiscordBridgeConfigMetrics) {
promClient.collectDefaultMetrics();
collectDefaultMetrics();
// TODO: Bind this for every user.
this.httpServer = http.createServer((req, res) => {
if (req.method !== "GET" || req.url !== "/metrics") {
res.writeHead(404, "Not found");
res.end();
return;
}
res.writeHead(200, "OK", {"Content-Type": promClient.register.contentType});
res.write(promClient.register.metrics());
res.writeHead(200, "OK", {"Content-Type": register.contentType});
res.write(register.metrics());
res.end();
});
this.matrixCallCounter = new Counter({
......@@ -85,41 +86,41 @@ export class PrometheusBridgeMetrics implements IBridgeMetrics {
labelNames: ["method", "result"],
name: "matrix_api_calls",
});
promClient.register.registerMetric(this.matrixCallCounter);
register.registerMetric(this.matrixCallCounter);
this.remoteCallCounter = new Counter({
help: "Count of remote API calls made",
labelNames: ["method"],
name: "remote_api_calls",
});
promClient.register.registerMetric(this.remoteCallCounter);
register.registerMetric(this.remoteCallCounter);
this.storeCallCounter = new Counter({
help: "Count of store function calls made",
labelNames: ["method", "cached"],
name: "store_calls",
});
promClient.register.registerMetric(this.storeCallCounter);
register.registerMetric(this.storeCallCounter);
this.presenceGauge = new Gauge({
help: "Count of users in the presence queue",
name: "active_presence_users",
});
promClient.register.registerMetric(this.presenceGauge);
register.registerMetric(this.presenceGauge);
this.matrixRequest = new Histogram({
help: "Histogram of processing durations of received Matrix messages",
labelNames: ["outcome"],
name: "matrix_request_seconds",
});
promClient.register.registerMetric(this.matrixRequest);
register.registerMetric(this.matrixRequest);
this.remoteRequest = new Histogram({
help: "Histogram of processing durations of received remote messages",
labelNames: ["outcome"],
name: "remote_request_seconds",
});
promClient.register.registerMetric(this.remoteRequest);
register.registerMetric(this.remoteRequest);
this.requestsInFlight = new Map();
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