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

Custom sampler fix #3026

Merged
merged 34 commits into from
Nov 21, 2022
Merged

Conversation

jeremydvoss
Copy link
Contributor

@jeremydvoss jeremydvoss commented Nov 4, 2022

Description

While the custom sampler injection code worked for unit testing and manual testing. I have discovered a circular dependency bug that can easily occur when the user's sampler depends on trace or sampler modules. So, I'm moving the custom sampler injection to a higher level (configuration) like most entry points to eliminate that issue.

Fixes #3013

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • 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?

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

  • test_trace_init_custom_sampler_with_env_non_existent_entry_point: Verify default sampler is used when entry point does not exist.
  • test_trace_init_custom_sampler_with_env: Verify custom sampler is used when entry point is configured correctly.
  • test_trace_init_custom_sampler_with_env_bad_factory: Verify default sampler is used when factory does not produce a Sampler.
  • test_trace_init_custom_sampler_with_env_unused_arg: Verify custom sampler does not break when superfluous argument given.
  • test_trace_init_custom_ratio_sampler_with_env: Verify custom sampler with rate arg is used when entry point is configured correctly.
  • test_trace_init_custom_ratio_sampler_with_env_bad_arg: Verify default sampler is used when the argument is misconfigured and the factory raises an exception.
  • test_trace_init_custom_ratio_sampler_with_env_missing_arg: Verify default sampler is used when the argument is missing and the factory raises an exception.
  • test_trace_init_custom_ratio_sampler_with_env_multiple_entry_points: Verify that when multiple sampler entry points exist, only the one specified by the env var is used.
    NOTE: Since TracerProvider is mocked in configuration tests, we test that a default sampler is used by confirming that None was passed in for the Sampler. A test in test_trace.py then confirms that TracerProvider uses the default sampler when None is passed in.

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

@jeremydvoss jeremydvoss marked this pull request as ready for review November 7, 2022 19:24
@jeremydvoss jeremydvoss requested a review from a team November 7, 2022 19:24
@jeremydvoss
Copy link
Contributor Author

@lzchen @srikanthccv @aabmass . Tagging everyone who participated in the initial PR.

@jeremydvoss
Copy link
Contributor Author

This PR needs the "Skip Public API check" tag.

jeremydvoss and others added 4 commits November 10, 2022 10:17
…_.py

Co-authored-by: Leighton Chen <lechen@microsoft.com>
…_.py

Co-authored-by: Leighton Chen <lechen@microsoft.com>
…_.py

Co-authored-by: Leighton Chen <lechen@microsoft.com>
@lzchen lzchen added the Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Sampler injection can cause a runtime circular dependency in certain situations.
4 participants