Files
Sheep-Service/api/middleware/metrics.js
Rozenrod 85483b85bb Додан моніторінг застосунку
Додани веб компоненти карточок територій та повідомлень
2025-12-08 00:14:56 +02:00

22 lines
625 B
JavaScript

module.exports = (req, res, next) => {
const start = performance.now();
res.on("finish", () => {
const duration = performance.now() - start;
fetch("http://metrics:4005/push", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
type: "rest",
path: req.originalUrl,
method: req.method,
status: res.statusCode,
time: duration,
timestamp: Date.now()
})
}).catch(err => console.error(err));
});
next();
};