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 Monkey Patch for Gevent #218

Merged
merged 9 commits into from
Jul 5, 2024
Merged

Add Monkey Patch for Gevent #218

merged 9 commits into from
Jul 5, 2024

Conversation

harrryr
Copy link
Contributor

@harrryr harrryr commented Jun 21, 2024

Issue #, if available:
Some customers are using gevent in their Python application with opentelemetry, and this causes the application to crash due to maximum recursion depth exceeded error. This is because gevent uses a specific version of the ssl module and runs monkey.patch_all() to patch the ssl module to the required version.

The monkey command patches already existing modules to the required version, which may cause problems if there are other applications already using the module before monkey is ran.

Because Opentelemetry is also using the ssl module , it creates a conflict and causes the application to crash. The recommended solution is to run moneky.patch_all() in opentelemetry beforehand so that such conflicts do not occur.

Description of changes:
The issue experienced by customers is specifically due to the ssl module, therefore, we can run monkey.patch_ssl() command to only monkey the ssl module and reduce the scope. The distro will check if the customer application has the gevent module installed, and if so, run the monkey.patch_ssl().

Test
Built opentelemetry docker image with the change, modified the operator to install opentelemetry on sample python application with the image. Checked that the sample application has opentelemetry running and doesn't crash when APIs are called.

Test run: https://github.com/aws-observability/aws-otel-python-instrumentation/actions/runs/9813426624

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@harrryr harrryr requested a review from a team as a code owner June 21, 2024 22:20
@harrryr harrryr force-pushed the fix-gunicorn branch 3 times, most recently from 9bb0abb to 767c3d9 Compare June 24, 2024 22:18
@harrryr harrryr force-pushed the fix-gunicorn branch 2 times, most recently from f4b552b to 72878e0 Compare June 25, 2024 20:59
@harrryr harrryr force-pushed the fix-gunicorn branch 2 times, most recently from 4d4635f to cbd5f28 Compare June 25, 2024 21:45
@harrryr harrryr force-pushed the fix-gunicorn branch 15 times, most recently from 81e034c to 431ab46 Compare July 4, 2024 00:00
@harrryr harrryr merged commit 7f25ce2 into main Jul 5, 2024
11 checks passed
@harrryr harrryr deleted the fix-gunicorn branch July 5, 2024 23:40
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.

None yet

3 participants