koishi-plugin-exporter
Version:
Koishi OpenMetrics Exporter
23 lines (22 loc) • 778 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.commands = void 0;
const prom_client_1 = require("prom-client");
const common_1 = require("../common");
const commands = (ctx, config, register) => {
const c = new prom_client_1.Counter({
name: common_1.prefix + common_1.metricNames.commands,
help: 'Commands that executed.',
registers: [register],
labelNames: ['instance_name', 'command_name', 'hour'],
});
ctx.on('command/before-execute', ({ command }) => {
const [command_name] = command.name.split('.', 1);
c.inc({
instance_name: config.name,
command_name,
hour: (0, common_1.getHour)(ctx),
});
});
};
exports.commands = commands;