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

DurationBuckets.exponential fails due to fractional nanoseconds #47

Open
evertlammerts opened this issue Oct 15, 2019 · 0 comments
Open

Comments

@evertlammerts
Copy link

DurationBuckets.exponential throws an IllegalArgumentException for large set of factors, because it is not possible to create a Duration based on a fractional nanosecond.:

java.lang.IllegalArgumentException: Unable to create a precise Duration with the specified factor

	at com.uber.m3.util.Duration.multiply(Duration.java:313)
	at com.uber.m3.tally.DurationBuckets.exponential(DurationBuckets.java:101)

The below code gives an idea of how I tried looking for a factor between 1 and 2 that can be used to create 20 buckets:

        BigDecimal curr = new BigDecimal("1.01");
        BigDecimal step = new BigDecimal("0.01");
        BigDecimal end = new BigDecimal("1.99");
        while (curr.compareTo(end) <= 0) {
            try {
                DurationBuckets.exponential(
                    Duration.ofMillis(1), curr.floatValue(), 20
                );
                System.out.println(curr);
            } catch (IllegalArgumentException e) {}
            curr = curr.add(step);
        }

None of them work. This virtually renders DurationBuckets.exponential useless.

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

No branches or pull requests

1 participant