dynatrace-oss / OneAgent-SDK-Python-AutoInstrumentation

autodynatrace, a python library that implements automatic instrumentation using the OneAgent SDK for Python
Other
62 stars 28 forks source link

Concurrent futures: AttributeError: object has no attribute '__module__' #29

Closed tomdesair closed 4 years ago

tomdesair commented 4 years ago

Similar to issue #28, we encountered another issue with the futures module:

2020-07-10 16:55:11,863 ERROR    Exception inside application: 'functools.partial' object has no attribute '__module__'
--
  | Traceback (most recent call last):
  | File "/opt/apps/app_venv/lib/python3.8/site-packages/channels/http.py", line 192, in __call__
  | await self.handle(body_stream)
  | File "/opt/apps/app_venv/lib/python3.8/site-packages/asgiref/sync.py", line 284, in __call__
  | future = loop.run_in_executor(
  | File "/usr/local/lib/python3.8/asyncio/base_events.py", line 783, in run_in_executor
  | executor.submit(func, *args), loop=self)
  | File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 185, in submit
  | w = _WorkItem(f, fn, args, kwargs)
  | File "/opt/apps/app_venv/lib/python3.8/site-packages/autodynatrace/wrappers/concurrent/wrapper.py", line 12, in dynatrace_submit
  | function_name, module, class_name = ("__call__", fn.__module__, fn.__class__.__name__)
  | AttributeError: 'functools.partial' object has no attribute '__module__'

It seems that autodynatrace should not rely on the __module__ attribute to exist (don't ask me how this is possible 😄)

dlopes7 commented 4 years ago

Oh my, thanks for reporting.

I forgot that people can define __slots__. This limits what attributes are available, and in the case of functools.partial it removes __module__

I will add a check to see if the attributes we need are available before using them, will also need to think of some default if they are not

tomdesair commented 4 years ago

Thanks a lot!