Code Monkey home page Code Monkey logo

statful-client-nodejs's People

Contributors

bcamarneiro avatar brunopalos avatar dependabot[bot] avatar franciscomota avatar gracasilva avatar hugovalente-mindera avatar jmtavares avatar maloky avatar miguelcnf avatar mistic avatar senzzzi avatar sujatharamanmindera avatar txnfail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

statful-client-nodejs's Issues

Client Improvements

There are some improvements we need to do on the client:

  • Make validator to not allow that flushInterval < timeout.
  • Tests for system stats, blocked, and default config values.
  • Verify merge order between global, global defaults and method parameters.
  • Add start e stop methods to the client. The stop method should assure that all metrics in buffer are sent before client closes.
  • Create a constants file.
  • Remove close from prototype.
  • Move some helper request functions into a request class.

express-middleware

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.

Memory leak when systemStats are enabled

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.