Skip to content

Commit 1656e7d

Browse files
fix(tracer): fix multiprocessing queue on aws lambda (#7612)
#6929 introduced a bug as multiprocessing.Queue is not supported on AWS lambda platform. This fix prevents the use of the Queue on aws lambda, as this is used for a RC only feature, and lambda does not use RC. ## 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] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [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)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly 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) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. --------- Co-authored-by: Zachary Groves <[email protected]> Co-authored-by: ZStriker19 <[email protected]>
1 parent 0cfc263 commit 1656e7d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ddtrace/settings/config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from ..internal.constants import PROPAGATION_STYLE_B3_SINGLE
2929
from ..internal.logger import get_logger
3030
from ..internal.schema import DEFAULT_SPAN_SERVICE_NAME
31+
from ..internal.serverless import in_aws_lambda
3132
from ..internal.utils.formats import asbool
3233
from ..internal.utils.formats import parse_tags_str
3334
from ..pin import Pin
@@ -264,9 +265,11 @@ class Config(object):
264265
available and can be updated by users.
265266
"""
266267

267-
_extra_services_queue = multiprocessing.get_context("fork" if sys.platform != "win32" else "spawn").Queue(
268-
512
269-
) # type: multiprocessing.Queue
268+
_extra_services_queue = (
269+
None
270+
if in_aws_lambda()
271+
else multiprocessing.get_context("fork" if sys.platform != "win32" else "spawn").Queue(512)
272+
) # type: multiprocessing.Queue | None
270273

271274
class _HTTPServerConfig(object):
272275
_error_statuses = "500-599" # type: str
@@ -490,6 +493,8 @@ def __getattr__(self, name):
490493
return self._integration_configs[name]
491494

492495
def _add_extra_service(self, service_name: str) -> None:
496+
if self._extra_services_queue is None:
497+
return
493498
if self._remote_config_enabled and service_name != self.service:
494499
try:
495500
self._extra_services_queue.put_nowait(service_name)
@@ -498,7 +503,8 @@ def _add_extra_service(self, service_name: str) -> None:
498503

499504
def _get_extra_services(self):
500505
# type: () -> set[str]
501-
506+
if self._extra_services_queue is None:
507+
return set()
502508
try:
503509
while True:
504510
self._extra_services.add(self._extra_services_queue.get(timeout=0.002))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
lambda: This change disables the use of ``multiprocessing.queue`` in Lambda, because it is not supported in Lambda

0 commit comments

Comments
 (0)