Skip to content

Conversation

@alexmojaki
Copy link
Contributor

Fixes problem reported in https://pydanticlogfire.slack.com/archives/C06EDRBSAH3/p1737061346996829

Before this PR, this:

from concurrent.futures import ThreadPoolExecutor

from ddtrace.contrib.internal.futures.patch import patch

import logfire

# Removing one of these or changing the order will cause the error to disappear.
patch()
logfire.configure()

ThreadPoolExecutor().submit(lambda: None).result()

raises:

Traceback (most recent call last):
  File "/Users/alex/Library/Application Support/JetBrains/PyCharm2024.3/scratches/scratch_990.py", line 11, in <module>
    ThreadPoolExecutor().submit(lambda: None).result()
  File "/Users/alex/.pyenv/versions/3.12.6/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/alex/.pyenv/versions/3.12.6/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/alex/.pyenv/versions/3.12.6/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alex/work/logfire/.venv/lib/python3.12/site-packages/ddtrace/contrib/internal/futures/threading.py", line 36, in _wrap_execution
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
TypeError: <lambda>() got an unexpected keyword argument 'carrier'

Executor.submit has the signature (self, fn, /, *args, **kwargs). Although fn is now positional-only, ddtrace pays special attention to that name in https://github.com/DataDog/dd-trace-py/blob/26dc258020126a7527f973c26494f0dd1016dead/ddtrace/contrib/internal/futures/threading.py#L7-L23

So avoiding that name does the trick.

@alexmojaki alexmojaki enabled auto-merge (squash) January 17, 2025 13:43
@alexmojaki alexmojaki merged commit 6c3e619 into main Jan 17, 2025
13 checks passed
@alexmojaki alexmojaki deleted the alex/executors-fn branch January 17, 2025 13:46
@codecov
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (294aa41) to head (496464d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #802   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          138       138           
  Lines        11044     11044           
  Branches      1565      1565           
=========================================
  Hits         11044     11044           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nairb774
Copy link

Thanks for quickly fixing this - really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants