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

Fix auto-instrumentation dependency conflict detection #530

Conversation

owais
Copy link
Contributor

@owais owais commented Jun 2, 2021

Description

Fixes #529

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 A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

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

@owais owais changed the title Release for V1.3.0 and 0.22b0 (#526) Fix auto-instrumentation dependency conflict detection Jun 2, 2021
@owais owais force-pushed the instrumentation-check-dep-conflicts-without-markers branch 3 times, most recently from f488345 to 6d3e4c5 Compare June 2, 2021 18:41
@owais owais marked this pull request as ready for review June 2, 2021 18:57
@owais owais requested a review from a team as a code owner June 2, 2021 18:57
@owais owais requested review from codeboten and srikanthccv and removed request for a team June 2, 2021 18:57
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Fix looks good, just one comment



def get_dependency_conflicts(
deps: Collection[str],
) -> Optional[DependencyConflict]:
for dep in deps:
try:
get_distribution(str(dep))
get_distribution(dep)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding a catch all here to prevent any other exceptions from causing the script to exit unexpectedly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could but I don't think there is anything too special about this and I expect it to work always unless in truly exceptional cases like the filesystem misbehaving or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an additional RequirementParseError that should catch most issues with invalid requirement strings being passed to this func.

return get_dependency_conflicts(deps)
main_deps = dist.requires()
instrumentation_deps = []
for dep in dist.requires(("instruments",)):
Copy link
Contributor

@lzchen lzchen Jun 4, 2021

Choose a reason for hiding this comment

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

Just to clarify, this would generate the Requirements for whatever is in extra_requires["instruments"] IN ADDITION TO the regular install_requires correct? In this case, the logic underneath will only parse through the ones that are not in the regualr install_requires?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. pkg_resource does not have an API to fetch only a specific extra require group. We could have used something like dist.requires(only_extra=('instruments',)) but it doesn't exist :)



def get_dependency_conflicts(
deps: Collection[str],
) -> Optional[DependencyConflict]:
for dep in deps:
try:
get_distribution(str(dep))
get_distribution(dep)
Copy link
Contributor

Choose a reason for hiding this comment

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

What was the original issue behind this? get_distribution behavior if the dep was not installed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot parse requirement strings that might also contain markers (extra requires section name).

get_distribution("lib == 1.0") works but get_distribution('lib == 1.0; extra = "instruments"') does not.

@owais owais force-pushed the instrumentation-check-dep-conflicts-without-markers branch 6 times, most recently from b189239 to eef7a13 Compare June 4, 2021 12:51
@owais owais force-pushed the instrumentation-check-dep-conflicts-without-markers branch from eef7a13 to efc735d Compare June 4, 2021 13:11
@owais owais requested a review from lzchen June 4, 2021 13:27
@lzchen lzchen merged commit 5b125b1 into open-telemetry:main Jun 4, 2021
@owais owais deleted the instrumentation-check-dep-conflicts-without-markers branch January 26, 2022 08:23
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.

opentelemetry-instrument command fails if incompatible instrumentation is found
4 participants