Skip to content

Commit ce216ac

Browse files
authored
fix(ray): stop instrumenting ray internal actors (#15083)
Before this change, we were instrumenting internal/private ray actors which was leading to noise/orphan spans. We now don't instrument internal actors and actors whose names start by `_`
1 parent 167d291 commit ce216ac

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

ddtrace/contrib/internal/ray/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@
6666
6767
- The integration disables Ray's built-in OpenTelemetry tracing to avoid duplicate telemetry.
6868
- Actor methods like ``ping`` and ``_polling`` are excluded from tracing to reduce noise.
69+
- Actors whose names start with an underscore (_) are not instrumented.
6970
"""

ddtrace/contrib/internal/ray/patch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
RAY_MODULE_DENYLIST = {
7272
"ray.dag",
7373
"ray.experimental",
74+
"ray.data._internal",
7475
}
7576

7677

@@ -499,6 +500,10 @@ def inject_tracing_into_actor_class(wrapped, instance, args, kwargs):
499500
if any(module_name.startswith(denied_module) for denied_module in RAY_MODULE_DENYLIST):
500501
return cls
501502

503+
# Actor beginning with _ are considered internal and will not be traced
504+
if class_name.startswith("_"):
505+
return cls
506+
502507
# Determine if the class is a JobSupervisor
503508
is_job_supervisor = f"{module_name}.{class_name}" == "ray.dashboard.modules.job.job_supervisor.JobSupervisor"
504509
# We do not want to instrument ping and polling to remove noise
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
ray: This fix stops instrumenting internal Ray actors (those starting with underscore) that were
5+
causing excessive noise, and adds ``ray.data._internal`` to the module denylist.

tests/contrib/ray/test_ray.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,28 @@ def increment_get_and_double(self):
104104

105105
assert current_value == 2, f"Unexpected result: {current_value}"
106106

107+
@pytest.mark.snapshot(token="tests.contrib.ray.test_ray.test_ignored_actored", ignores=RAY_SNAPSHOT_IGNORES)
108+
def test_ignored_actors(self):
109+
@ray.remote
110+
class _InternalActor:
111+
def one(self):
112+
return 1
113+
114+
actor = _InternalActor.remote()
115+
current_value = ray.get(actor.one.remote())
116+
assert current_value == 1, f"Unexpected result: {current_value}"
117+
118+
class MockDeniedActor:
119+
def get_value(self):
120+
return 42
121+
122+
MockDeniedActor.__module__ = "ray.data._internal"
123+
MockDeniedActor = ray.remote(MockDeniedActor)
124+
125+
denied_actor = MockDeniedActor.remote()
126+
value = ray.get(denied_actor.get_value.remote())
127+
assert value == 42, f"Unexpected result: {value}"
128+
107129
@pytest.mark.snapshot(token="tests.contrib.ray.test_ray.test_nested_tasks", ignores=RAY_SNAPSHOT_IGNORES)
108130
def test_nested_tasks(self):
109131
@ray.remote

0 commit comments

Comments
 (0)