mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
prom-client: add active connection gauge
This commit is contained in:
2 files changed
+28
No files matched your search
@@ -66,6 +66,20 @@ export function createRegistry(ctx: Context) {
|
||||
labelNames: ['type'],
|
||||
});
|
||||
|
||||
ctx.inject(['server'], () => {
|
||||
const gauge = createMetric(Gauge, 'hydro_active_handler', 'active handler count', {
|
||||
async collect() {
|
||||
const stats = ctx.server.statistics();
|
||||
this.reset();
|
||||
for (const key in stats) this.set({ type: key }, stats[key]);
|
||||
},
|
||||
labelNames: ['type'],
|
||||
});
|
||||
return () => {
|
||||
gauge.remove();
|
||||
};
|
||||
});
|
||||
|
||||
const eventCounter = createMetric(Counter, 'hydro_eventcount', 'eventcount', {
|
||||
labelNames: ['name'],
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user