Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram with negative values #1707

Open
joeo73 opened this issue Nov 15, 2019 · 9 comments
Open

Histogram with negative values #1707

joeo73 opened this issue Nov 15, 2019 · 9 comments
Labels
enhancement A general enhancement

Comments

@joeo73
Copy link
Contributor

joeo73 commented Nov 15, 2019

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.

@checketts
Copy link
Contributor

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.

@joeo73
Copy link
Contributor Author

joeo73 commented Nov 16, 2019

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.

@checketts
Copy link
Contributor

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.

@joeo73
Copy link
Contributor Author

joeo73 commented Nov 18, 2019

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}

@mweirauch
Copy link
Contributor

Just for reference, the discussion in OpenMetrics.

@shakuzen shakuzen added the enhancement A general enhancement label Dec 3, 2019
@marcingrzejszczak marcingrzejszczak added the waiting for feedback We need additional information before we can continue label Dec 20, 2023
Copy link

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.

Copy link

github-actions bot commented Jan 4, 2024

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.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2024
@joeo73-impinj
Copy link

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.

@jonatan-ivanov jonatan-ivanov removed waiting for feedback We need additional information before we can continue feedback-reminder labels Jan 8, 2024
@jonatan-ivanov
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants