Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sentry_sdk/integrations/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def new_remote(f=None, *args, **kwargs):

def wrapper(user_f):
# type: (Callable[..., Any]) -> Any
if inspect.isclass(user_f):
# Ray Actors
# (https://docs.ray.io/en/latest/ray-core/actors.html)
# are not supported
# (Only Ray Tasks are supported)
return old_remote(*args, **kwargs)(user_f)

@functools.wraps(user_f)
def new_func(*f_args, _sentry_tracing=None, **f_kwargs):
# type: (Any, Optional[dict[str, Any]], Any) -> Any
Expand Down
34 changes: 25 additions & 9 deletions tests/integrations/ray/test_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def example_task():
shutil.rmtree(ray_temp_dir, ignore_errors=True)


def test_tracing_in_ray_actors():
# Arbitrary keyword argument to test all decorator paths
@pytest.mark.parametrize("remote_kwargs", [{}, {"namespace": "actors"}])
def test_tracing_in_ray_actors(remote_kwargs):
setup_sentry()

ray.init(
Expand All @@ -194,16 +196,30 @@ def test_tracing_in_ray_actors():
)

# Setup ray actor
@ray.remote
class Counter:
def __init__(self):
self.n = 0
if remote_kwargs:

def increment(self):
with sentry_sdk.start_span(op="task", name="example actor execution"):
self.n += 1
@ray.remote(**remote_kwargs)
class Counter:
def __init__(self):
self.n = 0

def increment(self):
with sentry_sdk.start_span(op="task", name="example actor execution"):
self.n += 1

return sentry_sdk.get_client().transport.envelopes
else:

return sentry_sdk.get_client().transport.envelopes
@ray.remote
class Counter:
def __init__(self):
self.n = 0

def increment(self):
with sentry_sdk.start_span(op="task", name="example actor execution"):
self.n += 1

return sentry_sdk.get_client().transport.envelopes

with sentry_sdk.start_transaction(op="task", name="ray test transaction"):
counter = Counter.remote()
Expand Down
Loading