yaorg / node-measured

A Node metrics library for measuring and reporting application-level metrics, inspired by Coda Hale, Yammer Inc's Dropwizard Metrics Libraries
https://yaorg.github.io/node-measured/
MIT License
517 stars 52 forks source link

feat: Add optional `keepAlive` option to Meter and Timer #64

Closed tuckbick closed 5 years ago

tuckbick commented 5 years ago

This PR unrefs timers by default, eliminating headaches for people unsure about why their unit tests keep hanging.

It also eliminates having to break a 1 line piece of code into 3:

// no unref-ing
collection.meter('responses').mark()

// with unref-ing
const responsesMeter = collection.meter('responses');
responsesMeter.unref();
responsesMeter.mark();

// with PR, keepAlive = false
collection.meter('responses').mark()

// with PR, keepAlive = true
collection.meter('responses', {keepAlive: true}).mark()

I've set the default to false since that was most helpful for my team. However, I could be convinced to have it default to true.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 374


Totals Coverage Status
Change from base Build 372: 0.4%
Covered Lines: 759
Relevant Lines: 835

💛 - Coveralls