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

unable to instrument - Flask, gevent WSGIServer, gevent.spawn #95

Open cw-mdebi opened 8 months ago

cw-mdebi commented 8 months ago

Hello,

I have been trying to instrument python process with autodynatrace and not having success. Can you please help and guide on how to get it to work.

I have installed autodynatrace​ python package and are able to see logs in dynatrace​. But it is not getting instrumented to show python process as service or linked log lines. In my observation in dynatrace technology is coming as only docker and python; Oneagent is not getting listed.

I have following type of processes in our app

I have following relevant packages installed

autodynatrace==2.0.0
oneagent-sdk==1.5.0.20221221.150433
Flask==1.1.2
gevent==22.10.2

and have set the following environment variables

AUTOWRAPT_BOOTSTRAP=autodynatrace
AUTODYNATRACE_FORKABLE=True    ## Tried changing it to True / False, but with limited success.

I understand that we can either instrument parent or child process. I guess gevent.spawn will have impact here?

I ran the troubleshooting guide from sdk page - https://github.com/Dynatrace/OneAgent-SDK-for-Python#troubleshooting - it seems to work and output is follows. However, when I run python process, I do not see any autodynatrace log in flask process output even after tweaking AUTODYNATRACE_LOG_LEVEL .

2023-11-24 12:40:52.130 UTC [7fb907870780] DEBUG   [py_sdk] initialize: ref count = 0
2023-11-24 12:40:52.130 UTC [7fb907870780] INFO    [py_sdk] Initializing SDK on Python=3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] with options=['loglevelsdk=finest', 'loglevel=finest'], libname=None.
2023-11-24 12:40:52.219 UTC [7fb907870780] INFO    [py_sdk] Loading native SDK library "/usr/local/lib/python3.10/dist-packages/oneagent/_impl/native/libonesdk_shared.so".
2023-11-24 12:40:52.219 UTC [7fb907870780] INFO    [py_sdk] Native SDK library "/usr/local/lib/python3.10/dist-packages/oneagent/_impl/native/libonesdk_shared.so" version 1.7.1 loaded.
2023-11-24 12:40:52.220 UTC [07877839] info    [onesdk] Initializing Dynatrace OneAgent SDK for C/C++ ...
2023-11-24 12:40:52.220 UTC [07877839] info    [onesdk] SDK stub version 1.7.1.1, build date 2022.12.15 10:27:48.
2023-11-24 12:40:52.220 UTC [07877839] fine    [onesdk] Preparing arguments...
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]   Options:
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]     Agent active:  true
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]     Agent module:  ''
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]     SDK log level: finest
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]   Additional options:
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]     loglevel=finest
2023-11-24 12:40:52.220 UTC [07877839] config  [onesdk]     ONESDK_INTERNAL_CA627667445C40F0_INIT_FLAGS=0
2023-11-24 12:40:52.220 UTC [07877839] fine    [onesdk] Loading agent module...
2023-11-24 12:40:52.234 UTC [07877839] fine    [onesdk] Loaded agent module provided by process agent.
2023-11-24 12:40:52.234 UTC [07877839] fine    [onesdk] Initializing agent module...
2023-11-24 12:40:52.264 UTC [07877839] info    [onesdk] Loaded agent module version: 1.277.165.20231024-150054
2023-11-24 12:40:52.264 UTC [07877839] info    [onesdk] Dynatrace OneAgent SDK for C/C++ agent module loaded successfully.
2023-11-24 12:40:52.264 UTC [07877839] fine    [onesdk] Initializing agent...
2023-11-24 12:40:52.264 UTC [07877839] info    [onesdk] Loaded extension API metrics.
2023-11-24 12:40:54.549 UTC [07877839] info    [onesdk] Dynatrace OneAgent SDK for C/C++ initialized successfully.
2023-11-24 12:40:54.550 UTC [07877839] info    [onesdk] Loaded extension API techtype.
2023-11-24 12:40:54.550 UTC [7fb907870780] DEBUG   [py_sdk] initialize successful, adding tech types...
2023-11-24 12:40:54.550 UTC [7fb907870780] DEBUG   [py_sdk] tech type reporting complete
InitResult=InitResult(status=InitResult.STATUS_INITIALIZED, error=None)
Agent state: 0
Agent found: True
Agent is compatible: True
Agent version: 1.277.165.20231024-150054/1.7.1

Appreciate your time and response. Thank you.