From 496464df05aed8dc307162fc7240d2f27378b513 Mon Sep 17 00:00:00 2001 From: Alex Hall Date: Fri, 17 Jan 2025 13:36:20 +0000 Subject: [PATCH] Fix conflict with ddtrace futures patching by renaming fn parameter --- logfire/_internal/integrations/executors.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/logfire/_internal/integrations/executors.py b/logfire/_internal/integrations/executors.py index 5176593e9..b438c76d4 100644 --- a/logfire/_internal/integrations/executors.py +++ b/logfire/_internal/integrations/executors.py @@ -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. @@ -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