Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reset async instrumentation aggregations each collection interval #2510

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

Merged
merged 2 commits into from
Mar 9, 2022

Conversation

aabmass
Copy link
Member

@aabmass aabmass commented Mar 8, 2022

Description

Fixes the bug where async instruments' aggregations were not being reset after each collection interval. Since they observe a total value, they should be reset each collection. For example

def total_number_of_processes_callback() -> Iterable[Measurement]:
    yield Measurement(get_current_cpu_time())

meter.create_observable_counter(
  "system_processes_count",
  cpu_time_callback,
  description="The total number of processes that have run on this machine",
)

The SDK would report the wrong values like so:

expected total num proceses actual reported by SDK
20 20
24 44
30 74

This PR fixes it so we correctly report the total num processes.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Updated tests to capture behavior. Also manually tested with prometheus and scraping /proc/stat

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added

@aabmass aabmass added sdk Affects the SDK package. metrics labels Mar 8, 2022
@aabmass aabmass requested a review from a team March 8, 2022 23:35
@aabmass aabmass force-pushed the async-agg-resets branch from fa8acd8 to 9e35e62 Compare March 8, 2022 23:37
@aabmass aabmass added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Mar 8, 2022
@ocelotl ocelotl merged commit 290d7b5 into open-telemetry:main Mar 9, 2022
ocelotl pushed a commit to ocelotl/opentelemetry-python that referenced this pull request Mar 10, 2022
@aabmass aabmass deleted the async-agg-resets branch March 11, 2022 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics sdk Affects the SDK package. Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants