- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Add toString implementation to exponential histograms #133969
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
Conversation
| Pinging @elastic/es-storage-engine (Team:StorageEngine) | 
        
          
                ...ogram/src/main/java/org/elasticsearch/exponentialhistogram/AbstractExponentialHistogram.java
          
            Show resolved
            Hide resolved
        
      | histogram.setMin(-100); | ||
| histogram.setMax(200); | ||
| histogram.setSum(1234.5); | ||
| histogram.tryAddBucket(2, 3, false); // negative bucket | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR but the boolean isPositive parameter makes it a bit harder to read than it needs to be. Maybe add tryAddPositiveBucket and tryAddNegativeBucket methods that internal call tryAddBucket(long index, long count, boolean isPositive) and make it private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a follow-up PR doing this but also replacing most usages of FixedCapacityHistogram with the new builder instead.
Currently exponential histograms still use the standard
Object.toStringimplementation.This representation is not very helpful when debugging or when e.g.
equalTo()assertions fail.Therefore this PR adds a
toStringimplementation printing the simple class name (also for anonymous classes) plus the actual histogram contents, giving a more pleasant experience: