@@ -19,14 +19,14 @@ This SDK enables Dynatrace customers to extend request level visibility into Pyt
19
19
* [ Incoming web requests] ( #incoming-web-requests )
20
20
* [ Outgoing web requests] ( #outgoing-web-requests )
21
21
* [ Trace in-process asynchronous execution] ( #trace-in-process-asynchronous-execution )
22
- * [ Custom request attributes ] ( #custom-request-attributes )
22
+ * [ Custom Request Attributes ] ( #custom-request-attributes )
23
23
* [ Custom services] ( #custom-services )
24
24
* [ 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 )
27
28
- [ Troubleshooting] ( #troubleshooting )
28
- * [ Installation issues] ( #installation-issues )
29
- * [ Post-installation issues] ( #post-installation-issues )
29
+ * [ Extended SDK State] ( #extended-sdk-state )
30
30
- [ Repository contents] ( #repository-contents )
31
31
- [ Help & Support] ( #help--support )
32
32
* [ Read the manual] ( #read-the-manual )
@@ -40,12 +40,14 @@ This SDK enables Dynatrace customers to extend request level visibility into Pyt
40
40
## Requirements
41
41
42
42
The 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 ` .
45
47
46
48
The Dynatrace OneAgent SDK for Python is a wrapper of the [ Dynatrace OneAgent SDK for C/C++] ( https://github.com/Dynatrace/OneAgent-SDK-for-C )
47
49
and 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 )
49
51
for its requirements, which also apply to the SDK for Python.
50
52
51
53
The 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
56
58
57
59
| OneAgent SDK for Python| OneAgent SDK for C/C++| Dynatrace OneAgent| Support status |
58
60
| :----------------------| :---------------------| :-----------------| :------------------|
61
+ | 1.3 | 1.5.1 | ≥1.179 | Supported |
59
62
| 1.2 | 1.4.1 | ≥1.161 | Supported |
60
63
| 1.1 | 1.3.1 | ≥1.151 | Supported |
61
64
| 1.0 | 1.1.0 | ≥1.141 | EAP (not supported)|
@@ -429,7 +432,6 @@ the callback of a periodic timer.
429
432
``` python
430
433
with sdk.trace_custom_service(' onTimer' , ' CleanupTask' ):
431
434
# Do the cleanup task
432
- :
433
435
```
434
436
435
437
Check out the documentation at:
@@ -535,31 +537,34 @@ See the documentation for more information:
535
537
* [ General information on tagging] ( https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/tagging.html )
536
538
* [ Messaging tracers in the specification repository] ( https://github.com/Dynatrace/OneAgent-SDK#messaging )
537
539
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)
540
543
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.
543
547
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 ` .
545
550
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
+ ```
551
554
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.
559
558
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
560
565
566
+ <a name =" installation-issues " ></a >
561
567
<a name =" post-installation-issues " ></a >
562
- ### Post-installation issues
563
568
564
569
To debug your OneAgent SDK for Python installation, execute the following Python code:
565
570
@@ -580,6 +585,34 @@ Known gotchas:
580
585
Make sure that the ` pip install ` or equivalent succeeded (see [ here] ( #installation ) ). Also make sure you use the ` pip ` corresponding to your
581
586
` python ` (if in doubt, use ` python -m pip ` instead of ` pip ` for installing).
582
587
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
+
583
616
584
617
<a name =" extended-sdk-state " ></a >
585
618
### Extended SDK State
0 commit comments