-
Notifications
You must be signed in to change notification settings - Fork 766
opentelemetry-instrumentation: teach opentelemetry-instrument about gevent #3699
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
Merged
+73
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...telemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py
Outdated
Show resolved
Hide resolved
...telemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py
Outdated
Show resolved
Hide resolved
b66f315
to
be971fb
Compare
DylanRussell
approved these changes
Aug 29, 2025
tammy-baylis-swi
approved these changes
Aug 29, 2025
…event Introduce OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH=patch_all environment variable that calls gevent monkey module patch_all method before starting up the distro and sdk. The environment variable should useful also for apps instrumented via the opentelemetry-operator. The flag removes the following warning (and hang) when running locust: $ opentelemetry-instrument locust /lib/python3.10/site-packages/locust/__init__.py:16: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See gevent/gevent#1016. Modules that had direct imports (NOT patched): ['urllib3.util (/lib/python3.10/site-packages/urllib3/util/__init__.py)', 'urllib3.util.ssl_ (/lib/python3.10/site-packages/urllib3/util/ssl_.py)']. monkey.patch_all()
Co-authored-by: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com>
7dc08bf
to
90c9af7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Introduce
OTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCH=patch_all
environment variable that calls gevent monkey modulepatch_all
method before starting up the distro and sdk. The environment variable should useful also for apps instrumented via the opentelemetry-operator.The flag removes the following warning (and hang) when running locust:
With the change:
While we only support patch_all, it's trivial to add support for more gevent patch methods (https://www.gevent.org/api/gevent.monkey.html#use-as-a-module).
The name contains
EXPERIMENTAL
because this is also patching code used by our exporters and while it appears to work it's not something we should encourage.Fixes #3629
Type of change
Please delete options that are not relevant.
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
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.