-
Notifications
You must be signed in to change notification settings - Fork 565
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
problems with generated exponential histogram #3767
Comments
One naive option would be to modify this block of code in the exporter: if data_point.positive.bucket_counts:
buckets = nonzero_slice(data_point.positive.bucket_counts)
if buckets:
positive = pb2.ExponentialHistogramDataPoint.Buckets(
offset=data_point.positive.offset,
bucket_counts=buckets,
)
else:
positive = None
else:
positive = None
if data_point.negative.bucket_counts:
buckets = nonzero_slice(data_point.negative.bucket_counts)
if buckets:
negative = pb2.ExponentialHistogramDataPoint.Buckets(
offset=data_point.negative.offset,
bucket_counts=buckets,
)
else:
negative = None
else:
negative = None also adding the function: def nonzero_slice(lst):
for i, value in enumerate(reversed(lst)):
if value != 0:
return lst[0:len(lst)-i-1]
return [] This produces a dump file (dump-corrected-python.txt) that has no negative buckets and the positive buckets include only the lowest, non-zero buckets. There is some overhead in searching for the last non-zero bucket, but it does produce a more compact representation of the payload (which also works with the downstream vendor). If this would be acceptable to the maintainers, I'm happy to code up a PR with this change. |
Describe your environment
Running with:
Requirements:
Steps to reproduce
Run
main.py
(below) and capture the dump of the exponential histogram.Source code:
This is run with the following script:
What is the expected behavior?
I expected to see a dump like that generated for the JavaScript SDK in
dump-js.txt.
What is the actual behavior?
The generated exponential histogram in dump-python.txt seems to have the following problems:
dump-js.txt
) trim unnecessary buckets, reducing the size of the payload.Additional context
None.
The text was updated successfully, but these errors were encountered: