The usecase
We got multiple changelogs stored in the database, and want to create a histogram monitoring the duration between changes.
The problem
There doesn't seem to be a way to set the start time of a Historgram.Timer
, e.g we want to set it to lastUpdated
given the current changelog.
Avenues of approach
1 Subclassing Histogram
Should work. However the java-lib use protected
/package-private
extensively, thus making it hard without copying large portions of the library.
2 Using reflection
After a Histogram.Timer
is created it should be possible to use reflection to set the start
field. The field is marked as private final
, and thus a SecurityManager could stop us in some environments.
Ideas?
Neither of the solutions seems like the correct way to go, and I suspect that I'm overlooking a simpler solution (but could find anything at SO or google). We're using grafana to visualize our metrics, if thats at all helpful in this scenario.
You don't need to subclass
Histogram
, as you don't need to useHistogram.Timer
only because your histogram is measuring times.Simply call
myHistogram.observe(System.now() - lastUpdated)
every time you record a new change in the database.