statful / statful-client-nodejs Goto Github PK
View Code? Open in Web Editor NEWStatful client for NodeJS applications. This client is intended to gather metrics and send them to Statful.
Home Page: https://www.statful.com
Statful client for NodeJS applications. This client is intended to gather metrics and send them to Statful.
Home Page: https://www.statful.com
There are some improvements we need to do on the client:
One use case that seems to become a pattern in expressjs applications is to measure the interval between receiving and responding to a request.
This pattern can be abstracted with a simple middleware function similar to:
function timer(start = new Date()) {
return (end = new Date()) => (end - start);
}
module.exports = (client) => (req, res, next) => {
req.__timer = timer();
res.on('finish', () => client.timer('response_time', req.__timer()));
next();
};
And could be used in a similar manner to:
const Statful = require('statful');
const statfulMiddleware = require('statful/middleware')
const statfulClient = new Statful(/*config*/);
const app = express();
app.use(statfulMiddlware(statfulClient))
I can start a PR with this, but I was wondering if it's desirable to add this directly to the statful client, or if it should be in a separate project.
There's a memory leak when systemStats are set to true. The function "sendFlushStats" puts the system stats metrics in the buffers, the "flush" method is called if the buffers are full and the "sendFlushStats" is called again. Because of that there's a loop every time the buffers are at the "maximum capacity" before sending the metrics.
flush
is not exposed and close
only closes the socket. This means that when exiting, buffered metrics might not be sent.
My proposal is to expose flush
and also flush when close
is invoked.
I might prepare a PR for this.
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.