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

Add callback options with timeout to observable callbacks #2664

Merged
merged 3 commits into from
May 7, 2022

Conversation

aabmass
Copy link
Member

@aabmass aabmass commented May 6, 2022

Description

Add a CallbackOptions dataclass to be passed into observable callbacks. This is to pass along a timeout_millis param which the callbacks should respect. Any additional things we add in the future can be added to the dataclass in backward compatible way. The reason to use a dataclass over function arguments is:

  1. it is easier for users to get right, while python signatures can be tricky. this is the one of the main things users will provide that the SDK will invoke, so it's important to get right
  2. for the "generator form", where the callback is a generator that yields batches of Observations, we need a way to send the options in. Generators support a sending a single value to become the result of the yield expression. See updated docs for examples.

Part of #2663

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Need to update tests still

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:

  • The OTel specification has changed which prompted this PR to update the method interfaces of opentelemetry-api/ or opentelemetry-sdk/

  • The method interfaces of test/util have changed

  • Scripts in scripts/ that were copied over to the Contrib repo have changed

  • Configuration files that were copied over to the Contrib repo have changed (when consistency between repositories is applicable) such as in

    • pyproject.toml
    • isort.cfg
    • .flake8
  • When a new .github/CODEOWNER is added

  • Major changes to project information, such as in:

    • README.md
    • CONTRIBUTING.md
  • Yes. - Link to PR:

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@aabmass aabmass marked this pull request as ready for review May 6, 2022 23:17
@aabmass aabmass requested a review from a team May 6, 2022 23:17
@ocelotl
Copy link
Contributor

ocelotl commented May 6, 2022

I think this one could use a changelog entry

Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs contrib update?

docs/examples/metrics/example.py Show resolved Hide resolved
@ocelotl ocelotl merged commit db9d40b into open-telemetry:main May 7, 2022
@aabmass aabmass deleted the timeout-callbacks branch May 7, 2022 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants