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

fix: ensure string url is used for dynatrace sdk trace #92

Closed andrewbrown248 closed 11 months ago

andrewbrown248 commented 11 months ago

AIOHTTP can make a client session request with a str or class:yarl.URL instance.

The dynatrace sdk.trace_outgoing_web_request is expecting a string.

This fix just ensure that any class:yarl.URL objects are cast to a string before passing to the dynatrace sdk.

We've applied this fix to a service that was hitting this error condition and validated that it's working for us.

Original error stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiobotocore/httpsession.py", line 208, in send
   response = await self._session.request(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/autodynatrace/wrappers/aiohttp/wrapper.py", line 17, in dynatrace_request
   with sdk.trace_outgoing_web_request(url, method, headers) as tracer:
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/oneagent/sdk/__init__.py", line 260, in trace_outgoing_web_request

   self._nsdk, self._nsdk.outgoingwebrequesttracer_create(url, method))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctypes.ArgumentError: argument 1: ValueError: Attempt to pass non-string type to SDK function expecting a string. Actual type: <class 'yarl.URL'>
dynatrace-cla-bot commented 11 months ago

CLA assistant check
All committers have signed the CLA.

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

schlbra commented 11 months ago

Our organization is waiting on this fix as well. Is there any way to prioritize this PR?

andrewbrown248 commented 11 months ago

@dlopes7 -- who do I talk to about getting this merged?

sammypbaird commented 5 months ago

This fixes the issue I was experiencing on our code! Could you create a release of this so that I can pull it into my project?

sammypbaird commented 4 months ago

@dlopes7 , are there any plans to create a new release for this library, which incorporates this fix? Thank you!

abdusahin commented 4 months ago

same here, when is this going to be released ?