Skip to content

Commit 93ce310

Browse files
committed
Review fixes
1 parent 082d56c commit 93ce310

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sentry_sdk/integrations/ray.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def new_remote(f=None, *args, **kwargs):
5555
def wrapper(user_f):
5656
# type: (Callable[..., Any]) -> Any
5757
@functools.wraps(user_f)
58-
def new_func(*f_args, _tracing=None, **f_kwargs):
58+
def new_func(*f_args, _sentry_tracing=None, **f_kwargs):
5959
# type: (Any, Optional[dict[str, Any]], Any) -> Any
6060
_check_sentry_initialized()
6161

6262
transaction = sentry_sdk.continue_trace(
63-
_tracing or {},
63+
_sentry_tracing or {},
6464
op=OP.QUEUE_TASK_RAY,
6565
name=qualname_from_function(user_f),
6666
origin=RayIntegration.origin,
@@ -79,18 +79,18 @@ def new_func(*f_args, _tracing=None, **f_kwargs):
7979

8080
return result
8181

82-
# Patching new_func signature to add the _tracing parameter to it
82+
# Patching new_func signature to add the _sentry_tracing parameter to it
8383
# Ray later inspects the signature and finds the unexpected parameter otherwise
8484
signature = inspect.signature(new_func)
8585
params = list(signature.parameters.values())
8686
params.append(
8787
inspect.Parameter(
88-
"_tracing",
88+
"_sentry_tracing",
8989
kind=inspect.Parameter.KEYWORD_ONLY,
9090
default=None,
9191
)
9292
)
93-
new_func.__signature__ = signature.replace(parameters=params)
93+
new_func.__signature__ = signature.replace(parameters=params) # type: ignore[attr-defined]
9494

9595
if f:
9696
rv = old_remote(new_func)
@@ -113,7 +113,9 @@ def _remote_method_with_header_propagation(*args, **kwargs):
113113
for k, v in sentry_sdk.get_current_scope().iter_trace_propagation_headers()
114114
}
115115
try:
116-
result = old_remote_method(*args, **kwargs, _tracing=tracing)
116+
result = old_remote_method(
117+
*args, **kwargs, _sentry_tracing=tracing
118+
)
117119
span.set_status(SPANSTATUS.OK)
118120
except Exception:
119121
span.set_status(SPANSTATUS.INTERNAL_ERROR)

tests/integrations/ray/test_ray.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def example_task():
100100
else:
101101
example_task = ray.remote(example_task)
102102

103+
# Function name shouldn't be overwritten by Sentry wrapper
104+
assert example_task._function_name == "tests.integrations.ray.test_ray.example_task"
105+
103106
with sentry_sdk.start_transaction(op="task", name="ray test transaction"):
104107
worker_envelopes = ray.get(example_task.remote())
105108

0 commit comments

Comments
 (0)