Add Explicit Distro and Configurator Env Var Config to Contract Test Setup #398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this pull request do?
Fixes an issue where upgrading our OTel dependency version from 1.27.0 caused all of our contract tests to start failing in the main build.
The root cause was that in version 1.28.0 OpenTelemetry Python SDK migrated from
pkg_resources
toimportlib_metadata
for entry point discovery. This was a breaking change that had significant behavioral implications:sys.path
order, meaing packages installed in the local test environment (e.g. venv) were always prioritized. This made ADOT discovery predictable and consistent even without explicitly specifyingOTEL_PYTHON_DISTRO
andOTEL_PYTHON_CONFIGURATOR
in the contract test set up.sys.path
precedence. In short, the discovery order depends on factors like filesystem iteration order, installation timestamps, etc. - things that can vary between environments. This is why our contract tests were able to pass in original PR build to bump the OTel dependencies, but then started failing in our main build.Due to this unpredicatable ordering, our ADOT SDK was not able to instrument the sample apps in our contract tests correctly which then resulted in all the test assertions failing.
The solution is to explicitly configure the OpenTelemetry distro and configurator in our contract test set up. This approach follows OpenTelemetry's official recommendations when multiple distros are present.
This fix will enable us to safely upgrade our OTel dependency version from 1.27.0 which unblocks the Caton project.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.