mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
prom: add connection count
This commit is contained in:
1 parent
4c81d96660
commit
810b4cd25e
4 files changed
+17
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.15.14",
|
"version": "3.15.15",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -391,6 +391,7 @@ export function Connection(
|
|||||||
args, request, response, user, domain, UiContext,
|
args, request, response, user, domain, UiContext,
|
||||||
} = ctx.HydroContext;
|
} = ctx.HydroContext;
|
||||||
const h = new RouteConnHandler(ctx, args, request, response, user, domain, UiContext);
|
const h = new RouteConnHandler(ctx, args, request, response, user, domain, UiContext);
|
||||||
|
await bus.emit('connection/create', h);
|
||||||
ctx.handler = h;
|
ctx.handler = h;
|
||||||
h.conn = conn;
|
h.conn = conn;
|
||||||
try {
|
try {
|
||||||
@@ -402,7 +403,10 @@ export function Connection(
|
|||||||
h.message(JSON.parse(e.data.toString()));
|
h.message(JSON.parse(e.data.toString()));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
conn.onclose = () => h.cleanup?.(args);
|
conn.onclose = () => {
|
||||||
|
h.cleanup?.(args);
|
||||||
|
bus.emit('connection/close', h);
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await h.onerror(e);
|
await h.onerror(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,16 @@ bus.on('handler/after/ProblemSubmit', (that) => {
|
|||||||
submissionCounter.inc({ lang: that.args.lang, domainId: that.args.domainId });
|
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');
|
const taskColl = db.collection('task');
|
||||||
createMetric(Gauge, 'hydro_task', 'taskcount', {
|
createMetric(Gauge, 'hydro_task', 'taskcount', {
|
||||||
async collect() {
|
async collect() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/prom-client",
|
"name": "@hydrooj/prom-client",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"prom-client": "^14.0.1"
|
"prom-client": "^14.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user