mikejihbe / metrics

A metrics library for Node.js
574 stars 56 forks source link

Timer Update #43

Closed bradmalloy closed 6 years ago

bradmalloy commented 7 years ago

Previously, timers in this library required that you time on your own and simply recorded an integer to the histogram. This update adds actual timers called with time() and stop() that add to the meter and histogram of the timer class.

bradmalloy commented 7 years ago

Ah, I see. My understanding was that users created individual instances of Timer(), which would mean that you can track multiple times at once. Would that work? I'm not opposed either way.

tolbertam commented 7 years ago

The way I've used Timer in the past which I think is typical is that i'll create 1 Timer per kind of operation my app does. For example, if I'm developing a web service backend I would have 1 Timer for each unique API endpoint. Since there can be many concurrent operations on an endpoint at a time, I think following the dropwizard approach would work good because you could still encapsulate the timing logic in one place (which I think is the main goal of your PR) while being able to time multiple events at a time.

tolbertam commented 6 years ago

This is superseded by #58