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 metricLimit and lru to DimensionAwareMetricsRegistry #69

Closed Qard closed 5 years ago

Qard commented 5 years ago

The metricLevel option allows limiting the number of metrics held by the registry in order to prevent denial of service attacks. The lru flag changes the metric dropping strategy from "least recently added" to "least recently used"

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 411


Totals Coverage Status
Change from base Build 406: 0.08%
Covered Lines: 770
Relevant Lines: 846

💛 - Coveralls
Qard commented 5 years ago

Nope, nothing breaking. I originally started with a slightly more invasive change that offloaded the key generation to another library (see: object-identity-map) but chose to simplify it to just this as the tests were a bit too dependent on the structure of the final key.

There is still a related issue I would like to fix which is that, due to the key generation algorithm dropping the keys, it's possible to have two different dimension sets that have differently named pairs with similar values result in a collision. For example: { a: 'first', b: 'second' } and { c: 'first', d: 'second' } would result in the same final key currently.