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

Issue still persists with version 1.1.1 - Attempt to pass non-string type to SDK function expecting a string. Actual type: <class 'psycopg2.sql.Composed'> #74

Closed ConnectWise-Lalit closed 1 year ago

ConnectWise-Lalit commented 1 year ago

We are still facing the issue which was fixed under https://github.com/dynatrace-oss/OneAgent-SDK-Python-AutoInstrumentation/issues/72 with the newer update of autodynatrace 1.1.1

File "/app/.venv/lib/python3.7/site-packages/autodynatrace/wrappers/dbapi/__init__.py", line 33, in execute
web_1                   |     return self._trace_method(self.__wrapped__.execute, query, query, *args, **kwargs)
web_1                   |   File "/app/.venv/lib/python3.7/site-packages/autodynatrace/wrappers/dbapi/__init__.py", line 24, in _trace_method
web_1                   |     with sdk.trace_sql_database_request(self.db_info, query):
web_1                   |   File "/app/.venv/lib/python3.7/site-packages/oneagent/sdk/__init__.py", line 156, in trace_sql_database_request
web_1                   |     self._nsdk.databaserequesttracer_create_sql(database.handle, sql))
web_1                   | ctypes.ArgumentError: argument 2: <class 'ValueError'>: Attempt to pass non-string type to SDK function expecting a string. Actual type: <class 'psycopg2.sql.Composed'>

From the error stack trace we noticed trace_sql_database_request is getting called and which is present in oneagent sdk library https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/master/src/oneagent/sdk/__init__.py#L141

and it implicitly calls https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/master/src/oneagent/_impl/native/sdknulliface.py#L169

and function databaserequesttracer_create_sql can be the root of the above error which seems to be accepting string format