prom: add connection count

This commit is contained in:
undefined committed 2022-08-18 20:15:23 +08:00
1 parent 4c81d96660
commit 810b4cd25e
4 files changed
+17 -3

No files matched your search

+10
View File
@@ -35,6 +35,16 @@ bus.on('handler/after/ProblemSubmit', (that) => {
submissionCounter.inc({ lang: that.args.lang, domainId: that.args.domainId });
});
const connectionGauge = createMetric(Gauge, 'hydro_connection', 'connectioncount', {
labelNames: ['domainId'],
});
bus.on('connection/create', (h) => {
connectionGauge.inc({ domainId: h.args.domainId });
});
bus.on('connection/close', (h) => {
connectionGauge.inc({ domainId: h.args.domainId }, -1);
});
const taskColl = db.collection('task');
createMetric(Gauge, 'hydro_task', 'taskcount', {
async collect() {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/prom-client",
"version": "0.0.1",
"version": "0.0.2",
"dependencies": {
"prom-client": "^14.0.1"
}