open-telemetry / opentelemetry-python

OpenTelemetry Python API and SDK
https://opentelemetry.io
Apache License 2.0
1.81k stars 633 forks source link

Fix collection of exponential histogram #3798

Closed euroelessar closed 7 months ago

euroelessar commented 8 months ago

Description

Fix various small issues in exponential histogram collection discovered by a newly added test and issues mentioned below:

  1. maintain self._scale to be consistent with current bucket's scale
  2. consistently pass scale of the correct buckets alongside the buckets to method calls
  3. maintain min, max, sum, count, zero_count values across collection calls
  4. calculate the exponential bucket's index based on the index in the circular buffer based on the index_base instead of index_start, also take wrapping around the buffer into account
  5. calculate an expected span size based on the index_start and new index instead of index_end
  6. while collecting the data point, rotate the circular buffer so that index_start matches index_base

Fixes #3393 Fixes #3600 Fixes #3562

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Does This PR Require a Contrib Repo Change?

Answer the following question based on these examples of changes that would require a Contrib Repo Change:

Checklist:

rbtz-openai commented 8 months ago

cc: @ocelotl

xrmx commented 8 months ago

Love the explanation near the code changes, thanks @euroelessar !

euroelessar commented 7 months ago

@srikanthccv thanks! can you recommend some other approver/maintainer to review this pr as well so it could be merged, please?

srikanthccv commented 7 months ago

@ocelotl will do another review. He already assigned this to him.