idanto / express-node-metrics Goto Github PK
View Code? Open in Web Editor NEWmetrics for node+express application
License: MIT License
metrics for node+express application
License: MIT License
Hi,
We would like to be able to collect metrics also for the metrics endpoint like all other endpoints.
Thanks :)
getting this error, while installing on v6.11.1
"stack": ["Error: Cannot find module '../build/Release/eventLoopStats'", " at Function.Module._resolveFilename (module.js:469:15)", " at Function.Module._load (module.js:417:25)", " at Module.require (module.js:497:17)", " at require (internal/module.js:20:19)", " at Object.<anonymous> (/opt/socket.io-chat/node_modules/event-loop-stats/src/eventLoopStats.js:1:84)", " at Module._compile (module.js:570:32)", " at Object.Module._extensions..js (module.js:579:10)", " at Module.load (module.js:487:32)", " at tryModuleLoad (module.js:446:12)", " at Function.Module._load (module.js:438:3)", " at Module.require (module.js:497:17)", " at require (internal/module.js:20:19)", " at Object.<anonymous> (/opt/socket.io-chat/node_modules/express-node-metrics/src/metrics.js:5:22)", " at Module._compile (module.js:570:32)", " at Object.Module._extensions..js (module.js:579:10)", " at Module.load (module.js:487:32)"], "level": "error", "message": "uncaughtException: Cannot find module '../build/Release/eventLoopStats'", "timestamp": "2017-09-12T04:57:22.470Z"
on host - Red Hat Enterprise Linux Server release 6.6
Calls to resetMetric() does not clean up any interval objects that are running. This happens with gc.releasedMem and gc.time processes because they use Meter objects which spawn intervals, which are never cleared. The result is a memory leak, new orphaned Timer and Meter objects getting left on the heap with each call to resetProcessMetrics(). To help illustrate, this is a hack I added locally to confirm and it does fix it but not in an elegant way.
if (trackedMetrics[NAMESPACES.process].gc) {
trackedMetrics[NAMESPACES.process].gc.releasedMem._meter.end();
trackedMetrics[NAMESPACES.process].gc.time._meter.end();
}
The package catch the event loop and not let mocha to finish his process when running tests.
example:
test:
'use strict';
const createFlowController = require('./metrics-controller');
describe('Testing create flow controller', function () {
it('some test',function () {
})
});
metrics-controller.js:
'use strict';
let express = require("express");
let router = express.Router();
let metrics = require('express-node-metrics').metrics; //TODO
router.get('/', function (req, res) {
res.json(JSON.parse(metrics.getAll(req.query.reset)));
});
module.exports = router;
Add documentation for how to use this package inside docker and how to work with your own fork
One of your dependencies - memwatch-next - has not been updated to support Node 10. It appears that AirBnb is supporting a fork of this package at https://www.npmjs.com/package/node-memwatch.
Please see this related issue andywer/leakage#27.
Wouldn't mind't opening a PR for this but i'm not sure how you would like to addresses this. Switching packages is probably a safe bet.
Add middleware test that uses real express & restify apps
How to reproduce:
Send request that not match to any route
Result
The package will crush at that line
Expected Solution:
log those cases under unknown route
Add logging to the package in TRACE level
The custom metric are returned only in getAll()
Create a new api that will return the custom metrics.
when I post to the path /v1/users/post and get 201 as a result the metrics object contain:
endpoints['v1/users/|post'][201]
and when I post to the same path with the same method and I get 409 :
endpoints['v1/users/|post'][409] ==undefined
and
endpoints['/|post'][409] is valid
screenshot is attached:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.