Closed Kami closed 1 year ago
@tammoippen Thanks for the review.
Do you think it would also make sense to implement the same changes for histogram()
function?
I quickly looked at the implementation and that would require more re-factoring to get it to work (Figure.histogram()
, Histogram
class, etc.).
@tammoippen Thanks for the review.
Do you think it would also make sense to implement the same changes for
histogram()
function?I quickly looked at the implementation and that would require more re-factoring to get it to work (
Figure.histogram()
,Histogram
class, etc.).
I think for this PR the change to hist
is enough. Afterwards, we can see, if we introduce aggregated variants to Figure.
I believe I've addressed all the feedback:
hist()
using hist_aggregated()
Please let me know if I missing something.
Base: 97.10% // Head: 97.11% // Increases project coverage by +0.01%
:tada:
Coverage data is based on head (
b506b51
) compared to base (589fe49
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Thank you for the PR. I will sort out the CI errors, they are not linked with your changes. 🎉
@tammoippen Thanks.
I also tried to get tests / CI to work under Python 3.11, but it turns out it's hard to to because the project still supports Python 2.7 and there are some backward incompatible changes in newer versions of pytest which are needed for newer Python versions.
Having said that, I see you dropped support for 2.7 (#52), so I will revisit that change and see if I can make it to work.
EDIT: Never mind, I just noticed you've already done that as part of #52 - thanks!
Background, Context
A lot of Python libraries such as OpenTelemetry Metrics API (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md) support histograms.
The problem is that those libraries expose pre-aggregated data (counts for each bucket) and not raw data. This is done intentionally since storing raw data could be very expensive in terms of memory usage in case there are a lot of samples.
Here is an example of data available by OpenTelemetry metrics Histogram view:
As you can see, we get we get counts for each bucket. Buckets go from (n[i], n[i+1]) whereas first item is -infinity and the last item is +infinity. In this example, buckets would look something like this:
[(-inf, 10), (11, 20), (21, 50), ..., (10000, +inf)]
.Proposed Change / Implementation
In this change I added a new function for graphing data which is already split into counts and bins.
This pull request is not final (I just copied the existing code + made small change to show how it should work), I just wanted to get the discussion going (with some code and examples) so we can agree on the API which should be exposed.
With the sample data above, this new function and bins which look like this:
We get the following histogram:
Feedback is welcome, especially on naming and things like that.
TODO