OneAgent SDK for Python oneagent.initialize fails

I encounter an error calling OneAgent SDK for Python oneagent.initialize within a docker container and I’m getting

InitResult(status=-1, error=SDKError(-1342308345, 'onesdk_initialize_2: Could not load agent.'))

that does not correspond to any of the errors listed at

I’m using oneagent-sdk==1.3.0.20191113.161138 and I’ve installed the latest dynatrace-install.sh from api/v1/deployment/installer/agent/unix/paas-sh

Other printouts during the initialization

initialize: ref count = 0
Initializing SDK with options=['loglevelsdk=finest', 'loglevel=finest'], libname=None.
Loading native SDK library "/usr/local/lib/python3.6/site-packages/oneagent/_impl/native/libonesdk_shared.so".
Native SDK library "/usr/local/lib/python3.6/site-packages/oneagent/_impl/native/libonesdk_shared.so" version 1.5.1 loaded.
2021-06-01 13:42:12.545 UTC [d9a3884f] info    [onesdk] Initializing Dynatrace OneAgent SDK for C/C++ ...
2021-06-01 13:42:12.545 UTC [d9a3884f] info    [onesdk] SDK stub version 1.5.1.4, build date 2019.10.23 12:58:09.
2021-06-01 13:42:12.545 UTC [d9a3884f] fine    [onesdk] Preparing arguments...
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]   Options:
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]     Agent active:  true
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]     Agent module:  'liboneagentloader.so'
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]     SDK log level: finest 
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]   Additional options:
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]     loglevel=finest
2021-06-01 13:42:12.545 UTC [d9a3884f] config  [onesdk]     ONESDK_INTERNAL_CA627667445C40F0_INIT_FLAGS=0
2021-06-01 13:42:12.545 UTC [d9a3884f] fine    [onesdk] Loading agent module...
2021-06-01 13:42:12.549 UTC [d9a3884f] info    [onesdk] Could not load agent module for Dynatrace OneAgent SDK for C/C++: liboneagentloader.so: cannot open shared object file: No such file or directory
Failed initializing agent.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/oneagent/__init__.py", line 271, in _try_init_noref
    nativeagent.checkresult(sdk, sdk.initialize(flags), 'onesdk_initialize_2')
  File "/usr/local/lib/python3.6/site-packages/oneagent/_impl/native/nativeagent.py", line 43, in checkresult
    raise SDKError(error_code, msg + ': ' + emsg)
oneagent.common.SDKError: (-1342308345, 'onesdk_initialize_2: Could not load agent.')
Continuing with stub-SDK only.
error during oneagent initialization: InitResult(status=-1, error=SDKError(-1342308345, 'onesdk_initialize_2: Could not load agent.'))

I see that liboneagentloader.so does exist at /opt/dynatrace/oneagent/agent/lib64/ even though it reports that

[onesdk] Could not load agent module for Dynatrace OneAgent SDK for C/C++: liboneagentloader.so: cannot open shared object file: No such file or directory

What else should I check?

Thank you

Hello, there are some things you could check here:

The main issues you could have are using a musl image (like alpine) or installing the oneagent-sdk lib for a different architecture. Do you have more details about how your Dockerfile looks like and how have you installed the oneagent-sdk pip package?

Issue  resolved -- docker image was missing the step

export LD_PRELOAD=/opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so