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

nhcb: basic implementation of custom buckets in histogram model #13486

Closed
5 tasks
Tracked by #13485
krajorama opened this issue Jan 28, 2024 · 2 comments
Closed
5 tasks
Tracked by #13485

nhcb: basic implementation of custom buckets in histogram model #13486

krajorama opened this issue Jan 28, 2024 · 2 comments
Assignees

Comments

@krajorama
Copy link
Member

krajorama commented Jan 28, 2024

Proposal

In the model/histogram package, in the Histogram and FloatHistogram types add a slice called customBounds

// customBounds holds the custom upper bounds for bucket definitions, otherwise nil.
// The upper bound +Inf is implicit, need not be stored.
// This slice is interned, to be treated as immutable and copied by reference.
// These numbers should be sorted from smallest to biggest.
customBounds []float64

Also add a constant to define the schema number that means custom buckets are in use. E.g. 127.

const CustomBucketsSchema = 127

In general the schema number dictates the semantics of the operations. When reading / validating the data it is ok to ignore the negative spans/counts/deltas and zero bucket information if schema == CustomBucketsSchema. Conversely it is ok to ignore customBounds when schema is different.

When writing a Histogram, the unused fields should be cleared, e.g. in Copy.

For the arithmetic functions in FloatHistogram: only do the operation for custom histograms if it is a scalar and custom histogram or it's two custom histograms with the same bucket layout. For the case of custom histogram vs exponential histogram and custom histograms that have different layout issue a Jeanette's warning. (See #13494 .)

Checklist:

  • add field
  • add CustomUpperBounds method
  • unit test for the above
  • the functions Copy() and CopyTo() should not deep copy the slice to intern the data
  • enhance all functions of Histogram and FloatHistogram and unit test.

Update1: removed the need to store +Inf and direct interface to get the upper bounds as they can be accessed via the bucket iterators.

@krajorama
Copy link
Member Author

@zenador is taking this on

@krajorama
Copy link
Member Author

Merged into nhcb branch.

@prometheus prometheus locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants