Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conflict with ddtrace futures patching by renaming fn parameter #802

Merged
merged 1 commit into from
Jan 17, 2025
Merged
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
10 changes: 6 additions & 4 deletions logfire/_internal/integrations/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ def submit_t(s: ThreadPoolExecutor, fn: Callable[..., Any], /, *args: Any, **kwa
"""A wrapper around ThreadPoolExecutor.submit() that carries over OTEL context across threads."""
fn = partial(fn, *args, **kwargs)
carrier = get_context()
return submit_t_orig(s, _run_with_context, carrier=carrier, fn=fn, parent_config=None)
return submit_t_orig(s, _run_with_context, carrier=carrier, func=fn, parent_config=None)

def submit_p(s: ProcessPoolExecutor, fn: Callable[..., Any], /, *args: Any, **kwargs: Any):
"""A wrapper around ProcessPoolExecutor.submit() that carries over OTEL context across processes."""
fn = partial(fn, *args, **kwargs)
carrier = get_context()
return submit_p_orig(s, _run_with_context, carrier=carrier, fn=fn, parent_config=serialize_config())
return submit_p_orig(s, _run_with_context, carrier=carrier, func=fn, parent_config=serialize_config())

def _run_with_context(carrier: ContextCarrier, fn: Callable[[], Any], parent_config: dict[str, Any] | None) -> Any:
def _run_with_context(
carrier: ContextCarrier, func: Callable[[], Any], parent_config: dict[str, Any] | None
) -> Any:
"""A wrapper around a function that restores OTEL context from a carrier and then calls the function.

This gets run from within a process / thread.
Expand All @@ -45,7 +47,7 @@ def _run_with_context(carrier: ContextCarrier, fn: Callable[[], Any], parent_con
deserialize_config(parent_config) # pragma: no cover

with attach_context(carrier):
return fn()
return func()

except ImportError: # pragma: no cover

Expand Down
Loading