micrometer
micrometer copied to clipboard
Histogram with negative values
I'm migrating from drop wizard to micrometer. I used to use a Histogram to record the difference between two time values.
Micrometer doesn't support negative values, but here is a good use case here for doing just that.
Can you help me understand how it would have negative AND positive values?
I understand a difference is subtracting times. So START - END would be negative, but END - START would be positive. Just reversing the order to measure a duration makes more sense and would be supported.
So a histogram with -1, -2, and -3 could just as easily be represented as 1, 2, and 3 with the understanding of that metric being a difference of time.
In my use case, am I tracking synchronization of time across servers measuring the difference on timestamped messages passed between the system. The value is a measure of clock drift (and network latency.)
The timestamp on a message from host FOO
may be after or before the time on host BAR
. Hence the calculated duration may be positive of negative.
Great use case! I think the problem you are running into is the minimumExpectedValue
defaults to 1
. See https://micrometer.io/docs/concepts#_scaling_and_histograms for how you can configure that.
Let me know if that works for you.
Setting this value doesn't have any affect. Ref the record method in AbstractDistributionSummary . It ignores all negative values. Sample code and output:
public void testDistribution() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
DistributionSummary summary = DistributionSummary
.builder("foo")
.minimumExpectedValue(-100L)
.tags(Tags.empty())
.register(meterRegistry);
summary.record(-10);
summary.record(10);
HistogramSnapshot result = summary.takeSnapshot();
System.out.println(result.toString());
summary.measure().forEach((m) -> {
System.out.println(m.toString());
});
}
Output:
HistogramSnapshot{count=1, total=10.0, mean=10.0, max=10.0}
Measurement{statistic='COUNT', value=1.0}
Measurement{statistic='TOTAL', value=10.0}
Measurement{statistic='MAX', value=10.0}
Just for reference, the discussion in OpenMetrics.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open.
What additional information is requested? There has been no movement on this in over 4 years, I assume this project is dead as I am talking to a bot.
You might want to talk to people then. :)
I think closing this was an accidental. Let me reopen it to track user interest: right now we don't support negative values since as far as I remember there are some arithmetical issues that we need to fix and max decaying to zero would be also weird.