@@ -19,14 +19,14 @@ This SDK enables Dynatrace customers to extend request level visibility into Pyt
1919 * [ Incoming web requests] ( #incoming-web-requests )
2020 * [ Outgoing web requests] ( #outgoing-web-requests )
2121 * [ Trace in-process asynchronous execution] ( #trace-in-process-asynchronous-execution )
22- * [ Custom request attributes ] ( #custom-request-attributes )
22+ * [ Custom Request Attributes ] ( #custom-request-attributes )
2323 * [ Custom services] ( #custom-services )
2424 * [ Messaging] ( #messaging )
25- * [ Outgoing Messages] ( #outgoing-messaging )
26- * [ Incoming Messages] ( #incoming-messaging )
25+ + [ Outgoing Messages] ( #outgoing-messages )
26+ + [ Incoming Messages] ( #incoming-messages )
27+ - [ Using the OneAgent SDK for Python with forked child processes (only available on Linux)] ( #using-the-oneagent-sdk-for-python-with-forked-child-processes-only-available-on-linux )
2728- [ Troubleshooting] ( #troubleshooting )
28- * [ Installation issues] ( #installation-issues )
29- * [ Post-installation issues] ( #post-installation-issues )
29+ * [ Extended SDK State] ( #extended-sdk-state )
3030- [ Repository contents] ( #repository-contents )
3131- [ Help & Support] ( #help--support )
3232 * [ Read the manual] ( #read-the-manual )
@@ -40,12 +40,14 @@ This SDK enables Dynatrace customers to extend request level visibility into Pyt
4040## Requirements
4141
4242The SDK supports Python 2 ≥ 2.7 and Python 3 ≥ 3.4. Only the official CPython (that is, the "normal" Python, i.e. the Python implementation
43- from < https://python.org > ) is supported and only on Linux (musl libc is currently not supported) and Windows with the x86 (including
44- x86-64) architecture. Additionally, ` pip ` ≥ 8.1.0 (2016-03-05) is required for installation.
43+ from < https://python.org > ) is supported and only on Linux (musl libc which is used, e.g., on Alpine Linux, is currently not supported)
44+ and Windows with the x86 (including x86-64) architecture.
45+ Additionally, ` pip ` ≥ 8.1.0 (2016-03-05) is required for installation, and on Linux, the system should be
46+ [ ` manylinux1 ` -compatible] ( https://www.python.org/dev/peps/pep-0513/ ) to ensure a smooth installation via ` pip ` .
4547
4648The Dynatrace OneAgent SDK for Python is a wrapper of the [ Dynatrace OneAgent SDK for C/C++] ( https://github.com/Dynatrace/OneAgent-SDK-for-C )
4749and therefore the SDK for C/C++ is required and delivered with the Python SDK. See
48- [ here] ( https://github.com/Dynatrace/OneAgent-SDK-for-C#dynatrace-oneagent-sdk-for-cc- requirements )
50+ [ here] ( https://github.com/Dynatrace/OneAgent-SDK-for-C#requirements )
4951for its requirements, which also apply to the SDK for Python.
5052
5153The version of the SDK for C/C++ that is included in each version of the SDK for Python is shown in the following table along with the required
@@ -56,6 +58,7 @@ Dynatrace OneAgent version (it is the same as
5658
5759| OneAgent SDK for Python| OneAgent SDK for C/C++| Dynatrace OneAgent| Support status |
5860| :----------------------| :---------------------| :-----------------| :------------------|
61+ | 1.3 | 1.5.1 | ≥1.179 | Supported |
5962| 1.2 | 1.4.1 | ≥1.161 | Supported |
6063| 1.1 | 1.3.1 | ≥1.151 | Supported |
6164| 1.0 | 1.1.0 | ≥1.141 | EAP (not supported)|
@@ -429,7 +432,6 @@ the callback of a periodic timer.
429432``` python
430433with sdk.trace_custom_service(' onTimer' , ' CleanupTask' ):
431434 # Do the cleanup task
432- :
433435```
434436
435437Check out the documentation at:
@@ -535,31 +537,34 @@ See the documentation for more information:
535537* [ General information on tagging] ( https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/tagging.html )
536538* [ Messaging tracers in the specification repository] ( https://github.com/Dynatrace/OneAgent-SDK#messaging )
537539
538- <a name =" troubleshooting " ></a >
539- ## Troubleshooting
540+ <a name =" forking " ></a >
541+ <a name =" using-the-oneagent-sdk-for-python-with-forked-child-processes-only-available-on-linux " ></a >
542+ ## Using the OneAgent SDK for Python with forked child processes (only available on Linux)
540543
541- <a name =" installation-issues " ></a >
542- ### Installation issues
544+ Some applications, especially web servers, use a concurrency model that is based on forked child processes.
545+ Typically a master process is started which is responsible only for creating and managing child processes by means of forking.
546+ The child processes do the real work, for example handling web requests.
543547
544- * ` ValueError ` when installing, complaining about missing ` DT_PYSDK_CSDK_PATH ` .
548+ The recommended way to use the Python SDK in such a scenario is as follows: You initialize the SDK in the master process setting
549+ the ` forkable ` argument to ` True ` .
545550
546- Make sure you are using pip to install a prebuilt package wheel for your system from PyPI, as described in [ Using the OneAgent SDK for
547- Python in your application] ( #installation ) . Also make sure you are using an up-to date version of ` pip ` , ` setuptools ` and ` wheel ` . You can
548- try upgrading them with ` python -m pip install --upgrade pip setuptools wheel ` (make sure to use the same ` python ` that you use to install
549- the ` oneagent-sdk ` package). ATTENTION: If you use the system-provided pip (e.g. installed via ` apt-get ` on Ubuntu) you should instead use
550- a ` pip ` inside a ` virtualenv ` (the same as your project), as uprading system-provided packages via ` pip ` may cause issues.
551+ ``` python
552+ oneagent.initialize(sdk_options, forkable = True )
553+ ```
551554
552- If this does not resolve the issue, make sure you are using a supported platform, as listed in [ Requirements] ( #requirements ) . If you * are*
553- using a supported system, you can try downloading the [ OneAgent SDK for C/C++] ( https://github.com/Dynatrace/OneAgent-SDK-for-C ) in the
554- version corresponding to your OneAgent SDK for Python as listed in [ the table in Requirements] ( #requirements ) . Then set the
555- ` DT_PYSDK_CSDK_PATH ` environment variable to the ` .so ` /` .dll ` file corresponding to your platform in the ` lib ` subdirectory of the C SDK
556- and retry the installation (e.g. in a bash shell, use ` export DT_PYSDK_CSDK_PATH=path/to/onesdk_shared.so ` ). If there is no corresponding
557- directory, your platfom is not supported. Otherwise, regardless if it works with that method or not, please report an issue as desribed in
558- [ Let us help you] ( #let-us-help-you ) .
555+ This way you will not be able to use the SDK in the master process (attempts to do so will be ignored, if applicable with
556+ an error code), but all forked child processes will share the same agent. This has a lower overhead, for example the
557+ startup of worker processes is not slowed down, and the per-worker memory overhead is reduced.
559558
559+ For more information on forked child processes, take a look at those resources:
560+ * [ Documentation on forking for the Dynatrace OneAgent SDK for C/C++] ( https://github.com/Dynatrace/OneAgent-SDK-for-C/blob/master/README.md#forking )
561+ * [ Forking sample application] ( ./samples/fork-sdk-sample/fork_sdk_sample.py )
562+
563+ <a name =" troubleshooting " ></a >
564+ ## Troubleshooting
560565
566+ <a name =" installation-issues " ></a >
561567<a name =" post-installation-issues " ></a >
562- ### Post-installation issues
563568
564569To debug your OneAgent SDK for Python installation, execute the following Python code:
565570
@@ -580,6 +585,34 @@ Known gotchas:
580585 Make sure that the ` pip install ` or equivalent succeeded (see [ here] ( #installation ) ). Also make sure you use the ` pip ` corresponding to your
581586 ` python ` (if in doubt, use ` python -m pip ` instead of ` pip ` for installing).
582587
588+ * Output ending in a message like ` InitResult=InitResult(status=-2, error=SDKError(-1342308345, 'Failed loading SDK stub from .../site-packages/oneagent/_impl/native/libonesdk_shared.so: "/.../libonesdk_shared.so: cannot open shared object file: No such file or directory". Check your installation of the oneagent-sdk Python package, e.g., try running ` pip install --verbose --force-reinstall oneagent-sdk` .')) ` .
589+
590+ Follow the advice of the message and run ` python -m pip install --verbose --force-reinstall oneagent-sdk `
591+ (or the equivalent pip invocation with the ` --verbose ` and ` --force-reinstall ` flags).
592+ It is likely that you will now see another message like
593+
594+ ******************************************************************************
595+ *** You are trying to build the Python SDK from source. ***
596+ *** This could mean that you are using an outdated version of pip (older ***
597+ *** than 8.1.0) or you are attempting to install the SDK on an ***
598+ *** unsupported platform. Please check the requirements at ***
599+ *** https://github.com/Dynatrace/OneAgent-SDK-for-Python#requirements ***
600+ ******************************************************************************
601+
602+ Make sure you are using pip to install a prebuilt package wheel for your system from PyPI, as described in [ Using the OneAgent SDK for
603+ Python in your application] ( #installation ) . Also make sure you are using an up-to date version of ` pip ` , ` setuptools ` and ` wheel ` . You can
604+ try upgrading them with ` python -m pip install --upgrade pip setuptools wheel ` (make sure to use the same ` python ` that you use to install
605+ the ` oneagent-sdk ` package). ATTENTION: If you use the system-provided pip (e.g. installed via ` apt-get ` on Ubuntu) you should instead use
606+ a ` pip ` inside a ` virtualenv ` (the same as your project), as upgrading system-provided packages via ` pip ` may cause issues.
607+
608+ If this does not resolve the issue, make sure you are using a supported platform, as listed in [ Requirements] ( #requirements ) . If you * are*
609+ using a supported system, you can try downloading the [ OneAgent SDK for C/C++] ( https://github.com/Dynatrace/OneAgent-SDK-for-C ) in the
610+ version corresponding to your OneAgent SDK for Python as listed in [ the table in Requirements] ( #requirements ) . Then set the
611+ ` DT_PYSDK_CSDK_PATH ` environment variable to the ` .so ` /` .dll ` file corresponding to your platform in the ` lib ` subdirectory of the C SDK
612+ and retry the installation (e.g. in a bash shell, use ` export DT_PYSDK_CSDK_PATH=path/to/onesdk_shared.so ` ). If there is no corresponding
613+ directory, your platform is not supported. Otherwise, regardless if it works with that method or not, please report an issue as described
614+ in [ Let us help you] ( #let-us-help-you ) .
615+
583616
584617<a name =" extended-sdk-state " ></a >
585618### Extended SDK State
0 commit comments