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

Standardizing timeout calculation in measurement consumer collect to nanoseconds #4074

Merged
merged 8 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Standardizing timeout calculation in measurement consumer collect to nanoseconds
([#4074](https://github.com/open-telemetry/opentelemetry-python/pull/4074))
- optional scope attributes for logger creation
([#4035](https://github.com/open-telemetry/opentelemetry-python/pull/4035))
- optional scope attribute for tracer creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ def collect(
metric_reader_storage = self._reader_storages[metric_reader]
# for now, just use the defaults
callback_options = CallbackOptions()
deadline_ns = time_ns() + timeout_millis * 10**6
deadline_ns = time_ns() + (timeout_millis * 1e6)

default_timeout_millis = 10000 * 10**6
default_timeout_ns = 10000 * 1e6

for async_instrument in self._async_instruments:

remaining_time = deadline_ns - time_ns()

if remaining_time < default_timeout_millis:
if remaining_time < default_timeout_ns:

callback_options = CallbackOptions(
timeout_millis=remaining_time
timeout_millis=remaining_time / 1e6
)

measurements = async_instrument.callback(callback_options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ def sleep_1(*args, **kwargs):

self.assertLess(
callback_options_time_call,
10000 * 10**6,
10000,
)