etsy / statsd-jvm-profiler

Simple JVM Profiler Using StatsD and Other Metrics Backends
MIT License
330 stars 93 forks source link

Why use a gauge for time measures? #15

Closed vsmart closed 9 years ago

vsmart commented 9 years ago

Hi, I wonder why you use a gauge for recording the GC run time, as opposed to a count or a timing measure. Does this not mean one value will be overwritten by the next measure, and the total time might be lost? https://github.com/etsy/statsd-jvm-profiler/blob/d4a138230f8eb4cf00fa85c6d5f3bc92363de430/src/main/java/com/etsy/statsd/profiler/profilers/MemoryProfiler.java#L81-L82

Any response or insight would be appreciated! Thanks!

ajsquared commented 9 years ago

The first metric there is the total time spent in GC up to the current time as recorded by the JVM, so we want to simply record the value at the time the profiler emits metrics.

The second metric is the amount of time spent in GC since the last time the profiler emitted metrics. There's no particular reason to use a gauge for this one and we certainly could use a timing measure instead, but we don't have to worry about the total time since the JVM is already doing that for us and we're recording it in a different metric.

Hope that helps!

vsmart commented 9 years ago

Ok, that makes sense. Thank you.