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

Fixing inescapable character bug for Windows path string #1100

Merged
merged 21 commits into from
Jun 3, 2022

Conversation

jeremydvoss
Copy link
Contributor

@jeremydvoss jeremydvoss commented May 20, 2022

Description

Added an escape call in sitecustomize to fix unescapable character bug in auto-instrumentation on Windows.
Fixes #2703 on opentelemetry-python

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?

Tested with server_uninstrumented.py script. Confirmed spans are printed on Windows.

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.

@jeremydvoss jeremydvoss requested a review from a team May 20, 2022 19:11
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 20, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@ghost
Copy link

ghost commented May 20, 2022

I expected my PR # to be 1098, but it is apparently 1100. Since this is my first PR, I am not sure how to write the CHANGELOG knowing the PR number that will be created in the future. I can fix the CHANGELOG in another commit

CHANGELOG.md Outdated Show resolved Hide resolved
@aabmass
Copy link
Member

aabmass commented May 23, 2022

Is this the cause of #1102? I don't understand how this is fixing the issue, all that #1066 did was move the stripping of python path earlier in the file.

Or was the stripping code broken on windows all along and now it's causing an exception to be raised earlier?

@jeremydvoss
Copy link
Contributor Author

jeremydvoss commented May 24, 2022

Is this the cause of #1102? I don't understand how this is fixing the issue, all that #1066 did was move the stripping of python path earlier in the file.

Or was the stripping code broken on windows all along and now it's causing an exception to be raised earlier?

That code block was always broken on Windows, But since it was later in the finally block, it didn't cause an issue every time. The underlying problem is that we passed the re.sub function a raw string, when what it needs is an escaped pattern. This isn't an issue on Linux because linux paths use "/" which do not need to be escaped. But Windows paths use "\" and therefore do need to be escaped. By adding an escape, the string should satisfy re.sub on Linux and Windows

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

I read what you wrote in #1102 closer and understand 👍 thanks

Fixed negative look ahead to prevent removing path when it is the only
one.
Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Thanks for bearing with me. LGTM!

@srikanthccv
Copy link
Member

@jeremydvoss Fix the lint and we are good to merge this.

CHANGELOG.md Outdated Show resolved Hide resolved
opentelemetry-instrumentation/tests/test_utils.py Outdated Show resolved Hide resolved
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.

9 participants