Skip to content

Commit 67cf19e

Browse files
fix(grpc): disable aio support [backport 2.9] (#9201)
Backport 4c6247b from #9182 to 2.9. The goal of this PR is to unblock the 2.9.0 release. This PR hides grpc.aio support behind an internal flag. This integration is broken and will be fixed in a future release. ## Checklist - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. ## Reviewer Checklist - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) Co-authored-by: Munir Abdinur <[email protected]>
1 parent 4d4b22f commit 67cf19e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

ddtrace/contrib/grpc/patch.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import os
2+
13
import grpc
24

35
from ddtrace import Pin
46
from ddtrace import config
57
from ddtrace.internal.schema import schematize_service_name
68
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w
79

10+
from ...internal.logger import get_logger
811
from ...internal.utils import get_argument_value
912
from ...internal.utils import set_argument_value
13+
from ...internal.utils.formats import asbool
1014
from ..trace_utils import unwrap as _u
1115
from . import constants
1216
from . import utils
@@ -15,6 +19,9 @@
1519
from .server_interceptor import create_server_interceptor
1620

1721

22+
log = get_logger(__name__)
23+
24+
1825
def get_version():
1926
# type: () -> str
2027
return getattr(grpc, "__version__", "")
@@ -63,6 +70,8 @@ def get_version():
6370
dict(
6471
_default_service=schematize_service_name(constants.GRPC_SERVICE_CLIENT),
6572
distributed_tracing_enabled=True,
73+
# TODO: Remove this configuration when grpc.aio support is fixed
74+
_grpc_aio_enabled=asbool(os.getenv("_DD_TRACE_GRPC_AIO_ENABLED", False)),
6675
),
6776
)
6877

@@ -88,15 +97,16 @@ def get_version():
8897
def patch():
8998
_patch_client()
9099
_patch_server()
91-
if HAS_GRPC_AIO:
100+
if HAS_GRPC_AIO and config.grpc._grpc_aio_enabled:
101+
log.debug("The ddtrace grpc aio patch is enabled. This is an experimental feature and may not be stable.")
92102
_patch_aio_client()
93103
_patch_aio_server()
94104

95105

96106
def unpatch():
97107
_unpatch_client()
98108
_unpatch_server()
99-
if HAS_GRPC_AIO:
109+
if HAS_GRPC_AIO and config.grpc._grpc_aio_enabled:
100110
_unpatch_aio_client()
101111
_unpatch_aio_server()
102112

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
issues:
3+
- |
4+
grpc: Tracing for the ``grpc.aio`` clients and servers is experimental and may not be stable. This integration is now disabled by default.

riotfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,8 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
17351735
"pytest-asyncio": "==0.21.1",
17361736
"pytest-randomly": latest,
17371737
},
1738+
# grpc.aio support is broken and disabled by default
1739+
env={"_DD_TRACE_GRPC_AIO_ENABLED": "true"},
17381740
venvs=[
17391741
Venv(
17401742
pys=select_pys(min_version="3.7", max_version="3.9"),

0 commit comments

Comments
 (0)