add summary too, just in case idk
This commit is contained in:
parent
dab53c6857
commit
92be3ebb5e
2 changed files with 9 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "mtproto_exporter",
|
"name": "mtproto_exporter",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"packageManager": "pnpm@10.6.5",
|
"packageManager": "pnpm@10.6.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Dialog, TelegramClient } from "@mtcute/node";
|
import type { Dialog, TelegramClient } from "@mtcute/node";
|
||||||
|
|
||||||
import type { Registry } from "prom-client";
|
import { Registry, Summary } from "prom-client";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
import timers from "node:timers/promises";
|
import timers from "node:timers/promises";
|
||||||
|
|
||||||
|
|
@ -53,6 +53,7 @@ class DialogsHolder {
|
||||||
private ttl: bigint;
|
private ttl: bigint;
|
||||||
|
|
||||||
private dialogsIterDurationHistogram: Histogram;
|
private dialogsIterDurationHistogram: Histogram;
|
||||||
|
private dialogsIterDurationSummary: Summary;
|
||||||
|
|
||||||
constructor(private tg: TelegramClient, ttl: number, private timeout: number, private pollInterval = 10) {
|
constructor(private tg: TelegramClient, ttl: number, private timeout: number, private pollInterval = 10) {
|
||||||
this.ttl = BigInt(ttl) * 1000000n;
|
this.ttl = BigInt(ttl) * 1000000n;
|
||||||
|
|
@ -60,10 +61,15 @@ class DialogsHolder {
|
||||||
name: "telegram_api_dialogs_iter_duration",
|
name: "telegram_api_dialogs_iter_duration",
|
||||||
help: "Duration of iteration over telegram dialogs",
|
help: "Duration of iteration over telegram dialogs",
|
||||||
});
|
});
|
||||||
|
this.dialogsIterDurationSummary = new Summary({
|
||||||
|
name: "telegram_api_dialogs_iter_duration_summary",
|
||||||
|
help: "Duration of iteration over telegram dialogs",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerMetrics(registry: Registry) {
|
public registerMetrics(registry: Registry) {
|
||||||
registry.registerMetric(this.dialogsIterDurationHistogram);
|
registry.registerMetric(this.dialogsIterDurationHistogram);
|
||||||
|
registry.registerMetric(this.dialogsIterDurationSummary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async get() {
|
public async get() {
|
||||||
|
|
@ -85,7 +91,7 @@ class DialogsHolder {
|
||||||
}
|
}
|
||||||
this.dialogs.push(d);
|
this.dialogs.push(d);
|
||||||
}
|
}
|
||||||
end();
|
this.dialogsIterDurationSummary.observe(end());
|
||||||
this.lastUpdate = process.hrtime.bigint();
|
this.lastUpdate = process.hrtime.bigint();
|
||||||
this.isUpdating = false;
|
this.isUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue