Додан моніторінг застосунку
Додани веб компоненти карточок територій та повідомлень
This commit is contained in:
22
api/middleware/metrics.js
Normal file
22
api/middleware/metrics.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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();
|
||||
};
|
||||
Reference in New Issue
Block a user