Skip to content

Commit 98ef63a

Browse files
authored
Version 1.5.0 (#25)
1 parent fa4dd20 commit 98ef63a

File tree

16 files changed

+234
-63
lines changed

16 files changed

+234
-63
lines changed

.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
*.pyc
22
*.pyo
3+
*.lib
4+
*.pdb
5+
*.so
6+
*.a
7+
*.launch
38
build/
49
__pycache__/
510
onesdk_shared.dll
@@ -10,7 +15,13 @@ dist/
1015
/tmp/
1116
*.egg-info
1217
.pytest_cache/
18+
venv/
19+
.venv/
20+
.tox/
21+
.vscode
22+
*.whl
23+
db.sqlite3
24+
/.checkstyle
1325
/.project
1426
/.pydevproject
15-
/.README.md.html
16-
/.settings
27+
.settings/

README.md

Lines changed: 83 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,38 @@ This SDK enables Dynatrace customers to extend request level visibility into Pyt
2424
* [Messaging](#messaging)
2525
+ [Outgoing Messages](#outgoing-messages)
2626
+ [Incoming Messages](#incoming-messages)
27+
- [W3C trace context](#w3c-trace-context)
2728
- [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)
2829
- [Troubleshooting](#troubleshooting)
2930
* [Extended SDK State](#extended-sdk-state)
31+
* [Shutdown crashes](#shutdown-crashes)
3032
- [Repository contents](#repository-contents)
3133
- [Help & Support](#help--support)
3234
* [Read the manual](#read-the-manual)
3335
* [Let us help you](#let-us-help-you)
3436
- [Release notes](#release-notes)
37+
* [Version 1.5.0](#version-150)
3538
- [License](#license)
3639

3740
<!-- tocstop -->
3841

3942
<a name="requirements"></a>
4043
## Requirements
4144

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
45+
The latest release of the SDK supports Python 3 only, see below for exact support status of Python versions.
46+
47+
Only the official CPython (that is, the "normal" Python, i.e. the Python implementation
4348
from <https://python.org>) is supported and only on Linux (musl libc which is used, e.g., on Alpine Linux, is currently not supported)
4449
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`.
50+
It is always advised to use the latest patch version of your minor versoin of Python, as these usually contain security
51+
fixes and other important bugfixes.
52+
53+
Additionally, `pip` with the `wheel` and `setuptools` package installed is required for installation,
54+
and on Linux, the system needs to be [`manylinux1`-compatible](https://www.python.org/dev/peps/pep-0513/).
55+
`pip` versions before 8.1.0 are known not to work, but generally it is advised to always use the latest pip version.
56+
Due to factors such as changes in package hosting by PyPI and Python itself,
57+
Dynatrace cannot guarantee that SDK installation is, or will continue to be,
58+
possible with old pip versions.
4759

4860
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)
4961
and therefore the SDK for C/C++ is required and delivered with the Python SDK. See
@@ -56,17 +68,34 @@ Dynatrace OneAgent version (it is the same as
5668

5769
<a name="pycversiontab"></a>
5870

59-
|OneAgent SDK for Python|OneAgent SDK for C/C++|Dynatrace OneAgent|Support status |
60-
|:----------------------|:---------------------|:-----------------|:------------------|
61-
|1.4 |1.6.1 |≥1.179 |Supported |
62-
|1.3 |1.5.1 |≥1.179 |Supported |
63-
|1.2 |1.4.1 |≥1.161 |Deprecated¹ |
64-
|1.1 |1.3.1 |≥1.151 |Deprecated¹ |
65-
|1.0 |1.1.0 |≥1.141 |EAP (not supported)|
71+
|OneAgent SDK for Python|Bundled OneAgent SDK for C/C++|Required OneAgent|Required Python|Support status |
72+
|:----------------------|:-----------------------------|:----------------|:--------------|:--------------|
73+
|1.5 |1.7.1 |≥1.251 |≥3.5 |Supported|
74+
|1.4 |1.6.1 |≥1.179 |2.7.x or ≥3.4 |Supported|
75+
|1.3 |1.5.1 |≥1.179 |2.7.x or ≥3.4 |Deprecated with support ending 2023-07-01|
76+
|1.2 |1.4.1 |≥1.161 |2.7.x or ≥3.4 |Deprecated with support ending 2023-07-01|
77+
|1.1 |1.3.1 |≥1.151 |2.7.x or ≥3.4 |Deprecated with support ending 2023-07-01|
78+
|1.0 |1.1.0 |≥1.141 |2.7.x or ≥3.4 |Deprecated with support ending 2023-07-01|
79+
80+
Note that this table only states the support status of the mentioned OneAgent SDK for Python version
81+
with the included OneAgent SDK for C/C++, not the OneAgent itself.
82+
83+
The "required Python" column indicates the Python versions with which the SDK version was developed and tested.
84+
We may additionally announce deprecations for older versions of Python in combination with specific or all versions of the SDK,
85+
meaning that we will no longer provide support for these combinations after the given date, even if the SDK version itself
86+
is supported and technically running on that Python version.
87+
We also strongly advise against using Python versions that are no longer supported by your Python vendor.
88+
89+
We intend to deprecate Python versions effective around 6 months after the Python project stops supporting them as documented by the
90+
Python project: <https://devguide.python.org/versions/>. We will announce every deprecation explicitly, usually 6 months before
91+
it becomes effective.
6692

67-
> 1. *Deprecated* releases of the OneAgent SDK for Python are still supported but this
68-
> might change with a future release. Applications using those deprecated versions should
69-
> be upgraded to the latest release.
93+
<a name="pysupporttab"></a>
94+
95+
| Python version | Deprecation status |
96+
|:---------------|:---------------|
97+
| 3.4.x-3.6.x | Deprecation announcement with exact date pending, *not before* 2023-07-01 |
98+
| 2.7.x | Deprecated with support (with compatible SDK versions) ending 2023-07-01 |
7099

71100
<a name="#using-the-oneagent-sdk-for-python-in-your-application"></a>
72101
## Using the OneAgent SDK for Python in your application
@@ -80,6 +109,8 @@ To install the latest version of the OneAgent SDK for Python, use the PyPI packa
80109
python -m pip install --upgrade oneagent-sdk
81110
```
82111

112+
`pip`, `setuptools` and `wheel` need to be installed and should be up to date before running this command.
113+
83114
To verify your installation, execute
84115

85116
```bash
@@ -218,6 +249,7 @@ A more detailed specification of the features can be found in [Dynatrace OneAgen
218249

219250
|Feature |Required OneAgent SDK for Python version|
220251
|:-----------------------------------------|:--------|
252+
|W3C trace context for log enrichment |≥1.5.0 |
221253
|Custom services |≥1.2.0 |
222254
|Messaging |≥1.2.0 |
223255
|In-process linking |≥1.1.0 |
@@ -546,6 +578,35 @@ See the documentation for more information:
546578
* [General information on tagging](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/tagging.html)
547579
* [Messaging tracers in the specification repository](https://github.com/Dynatrace/OneAgent-SDK#messaging)
548580

581+
<a name="w3c-trace-context"></a>
582+
## W3C trace context
583+
584+
This feature allows you to retrieve a W3C TraceContext trace ID and span ID referencing the current PurePath node,
585+
as defined in <https://www.w3.org/TR/trace-context>.
586+
587+
This trace ID and span ID information is not intended for tagging and
588+
context-propagation scenarios and primarily designed for log-enrichment use
589+
cases. Refer to [General information on tagging](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/tagging.html)
590+
for tagging traces (see also the usage examples elsewhere in this document).
591+
592+
The following example shows how to print the current trace & span ID to stdout
593+
in a format that works well with Dynatrace Log Monitoring
594+
(see <https://www.dynatrace.com/support/help/shortlink/log-monitoring-log-enrichment> for more):
595+
596+
```python
597+
with sdk.trace_custom_service('onTimer', 'CleanupTask'): # Or any other tracer
598+
tinfo = sdk.tracecontext_get_current()
599+
print('[!dt dt.trace_id={},dt.span_id={}] handle incoming message'.format(tinfo.trace_id, tinfo.span_id))
600+
```
601+
602+
See the documentation for more information:
603+
604+
* [`tracecontext_get_current`](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/sdkref.html#oneagent.sdk.SDK.tracecontext_get_current)
605+
* [Information on trace tagging](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/tagging.html)
606+
* [W3C trace context in the SDK specification repository](https://github.com/Dynatrace/OneAgent-SDK#tracecontext)
607+
608+
609+
549610
<a name="forking"></a>
550611
<a name="using-the-oneagent-sdk-for-python-with-forked-child-processes-only-available-on-linux"></a>
551612
## Using the OneAgent SDK for Python with forked child processes (only available on Linux)
@@ -708,7 +769,6 @@ Make sure your issue is not already solved in the [available documentation](#doc
708769

709770
**Open a [GitHub issue](https://github.com/Dynatrace/OneAgent-SDK-for-Python/issues) to:**
710771
* Report minor defects or typos.
711-
* Ask for improvements or changes in the SDK API.
712772
* Ask any questions related to the community effort.
713773

714774
SLAs don't apply for GitHub tickets.
@@ -722,25 +782,20 @@ SLAs apply according to the customer's support level.
722782
<a name="release-notes"></a>
723783
## Release notes
724784

725-
### Version 1.4.0
785+
### Version 1.5.0
726786

727-
* Don't look for agent module in `PATH/LD_LIBRARY_PATH/..`. and
728-
disallow a relative path in the `DT_HOME` directory on Windows to prevent DLL hijacking issues.
787+
Changes:
729788

730-
* Fixed a bug that might lead to crashes in the SDK's shutdown phase
789+
* Adds limited [W3C trace context](#w3c-trace-context) support (for log enrichment).
790+
* This version **no longer supports Python 2 (Python 2.7.x)**.
791+
* This version **no longer supports Python 3.4.x**.
731792

732-
* Support for **Python versions < 3.5** is deprecated. The OneAgent SDK for Python
733-
will still work with this release, but this might change in the future.
793+
Announcements:
734794

735-
* Following versions of the **OneAgent SDK for Python** are considered deprecated
736-
and might not be supported in the future. Applications using it should be upgraded to the latest release.
737-
* [Version 1.1.0](https://github.com/Dynatrace/OneAgent-SDK-for-Python/releases/tag/v1.1.0)
738-
* [Version 1.2.0](https://github.com/Dynatrace/OneAgent-SDK-for-Python/releases/tag/v1.2.0)
739-
* [Version 1.2.1](https://github.com/Dynatrace/OneAgent-SDK-for-Python/releases/tag/v1.2.1)
795+
* ⚠️ **Deprecation announcement for older SDK versions:** Version 1.3 and all older versions have been put on the path to deprecation and will no longer be supported starting July 1, 2023. We strongly advise customers to upgrade to newest versions to avoid incompatibility and security risks. Customers need to upgrade to at least 1.4 but are encouraged to upgrade to the newest available version (1.5) if using Python >3.4 as there are no known incompatibilities or breaking changes other than the increased minimum Python version.
796+
* ⚠️ **Deprecation announcement for using any SDK version with older Python versions:** Python 2.7.x has been put on the path to deprecation and no version of the SDK will be supported on this Python version starting July 1, 2023. Furthermore, we intend to release a similar deprecation announcement regarding versions 3.4-3.6 (which are no longer maintained by the Python project) soon (we plan that this will not become effective before 2023-07-01).
740797

741-
> For older versions of the OneAgent SDK for Python, please see
742-
the [GitHub releases page](https://github.com/Dynatrace/OneAgent-SDK-for-Python/releases),
743-
and the [PyPI release history](https://pypi.org/project/oneagent-sdk/#history).
798+
See <https://github.com/Dynatrace/OneAgent-SDK-for-Python/releases> for older releases.
744799

745800
<a name="license"></a>
746801
## License

constraints.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
pylint<2.5
1+
tox<4
2+
pylint<2.5; python_version >= '3.0'
3+
pylint<1.10; python_version < '3.0'
4+
sphinx<6
5+
pytest<5; python_version < '3.5'
6+
pytest<7.2; python_version >= '3.5'

docs/conf.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@
3939

4040
from oneagent.version import __version__ as version
4141

42-
# Fix spurious "= None" for instance attributes
43-
# https://github.com/sphinx-doc/sphinx/issues/2044
44-
from sphinx.ext.autodoc import (
45-
ClassLevelDocumenter, InstanceAttributeDocumenter)
46-
47-
def iad_add_directive_header(self, sig):
48-
ClassLevelDocumenter.add_directive_header(self, sig)
49-
50-
InstanceAttributeDocumenter.add_directive_header = iad_add_directive_header
51-
52-
5342
# -- General configuration ------------------------------------------------
5443

5544
# If your documentation needs a minimal Sphinx version, state it here.
@@ -96,7 +85,7 @@ def iad_add_directive_header(self, sig):
9685
#
9786
# This is also used if you do content translation via gettext catalogs.
9887
# Usually you set "language" from the command line for these cases.
99-
language = None
88+
language = 'en'
10089

10190
# List of patterns, relative to source directory, that match files and
10291
# directories to ignore when looking for source files.
@@ -121,7 +110,7 @@ def iad_add_directive_header(self, sig):
121110
# further. For a list of options available for each theme, see the
122111
# documentation.
123112
#
124-
# html_theme_options = {}
113+
html_theme_options = {'sidebarwidth': 500}
125114

126115
# Add any paths that contain custom static files (such as style sheets) here,
127116
# relative to this directory. They are copied after the builtin static files,

docs/tagging.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,6 @@ Note these points:
120120
* You should take care that obtaining the incoming tag is not an expensive
121121
operation, as it can not be accounted for in the timings of the resulting
122122
path.
123+
* Both the string and byte tag are returned as a :class:`bytes` object
124+
(:code:`str` bytestring in Python 2).
125+
This is due to an oversight that cannot be fixed anymore without breaking compatibility.

samples/basic-sdk-sample/basic_sdk_sample.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ def mock_process_incoming_message():
219219
# the tracer ends.
220220
tracer.set_vendor_message_id('message_id')
221221
with tracer:
222-
print('handle incoming message')
222+
223+
# Use tracecontext_get_current to log a trace/span ID identifiying the current node.
224+
tinfo = sdk.tracecontext_get_current()
225+
print('[!dt dt.trace_id={},dt.span_id={}] handle incoming message'.format(
226+
tinfo.trace_id, tinfo.span_id))
227+
223228
tracer.set_correlation_id('correlation_id')
224229

225230
def mock_outgoing_message():

src/oneagent/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def initialize(sdkopts=(), sdklibname=None, forkable=False):
242242
Python SDK version.
243243
:param bool forkable: Use the SDK in 'forkable' mode.
244244
245-
:rtype: .InitResult
245+
:rtype: InitResult
246246
'''
247247

248248
global _sdk_ref_count #pylint:disable=global-statement

src/oneagent/_impl/native/sdkctypesiface.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
CCSID_UTF16_BE = 1201
4242
CCSID_UTF16_LE = 1203
4343

44+
_ONESDK_TRACE_ID_BUFFER_SIZE = 33
45+
_ONESDK_SPAN_ID_BUFFER_SIZE = 17
46+
4447
bool_t = ctypes.c_int32
4548
result_t = ctypes.c_uint32 if WIN32 else ctypes.c_int32
4649
xchar_p = ctypes.c_wchar_p if WIN32 else ctypes.c_char_p
@@ -503,6 +506,8 @@ def __init__(self, libname):
503506

504507
self._init_custom_service()
505508

509+
self._init_trace_context()
510+
506511

507512
def _init_custom_service(self):
508513
initfn = self._initfn
@@ -566,6 +571,15 @@ def _init_messaging(self):
566571
(handle_t, CCStringPInArg),
567572
None).__doc__ = '(tracer_handle, correlation_id)'
568573

574+
def _init_trace_context(self):
575+
initfn = self._initfn
576+
initfn(
577+
'tracecontext_get_current',
578+
(ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p, ctypes.c_size_t,),
579+
result_t,
580+
public=False)
581+
582+
569583

570584
def initialize(self, init_flags=0):
571585
result = self._initialize_2(init_flags)
@@ -761,6 +775,14 @@ def tracer_get_outgoing_tag(self, tracer, use_byte_tag=False):
761775
assert cnt + 1 == tagsz.value
762776
return buf.value
763777

778+
def tracecontext_get_current(self):
779+
trace_id_buf = ctypes.create_string_buffer(b'0' * (_ONESDK_TRACE_ID_BUFFER_SIZE - 1))
780+
span_id_buf = ctypes.create_string_buffer(b'0' * (_ONESDK_SPAN_ID_BUFFER_SIZE - 1))
781+
result = self._tracecontext_get_current(
782+
trace_id_buf, len(trace_id_buf), span_id_buf, len(span_id_buf))
783+
return result, u8_to_str(trace_id_buf.value), u8_to_str(span_id_buf.value)
784+
785+
764786
def tracer_set_incoming_byte_tag(self, tracer, tag):
765787
self._tracer_set_incoming_dynatrace_byte_tag(tracer, tag, len(tag))
766788

src/oneagent/_impl/native/sdknulliface.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ def tracer_error(self, tracer_h, error_class, error_message):
209209
pass
210210

211211
def tracer_get_outgoing_tag(self, tracer_h, use_byte_tag=False):
212-
if use_byte_tag:
213-
return six.binary_type()
214-
return six.text_type()
212+
# This was originally meant to return a string for use_byte_tag=False
213+
# but the real implementation doesn't do it that way.
214+
return six.binary_type()
215215

216216
def tracer_set_incoming_string_tag(self, tracer_h, tag):
217217
pass
@@ -281,3 +281,6 @@ def incomingmessageprocesstracer_set_correlation_id(self, handle, correlation_id
281281

282282
def customservicetracer_create(self, service_method, service_name):
283283
return NULL_HANDLE
284+
285+
def tracecontext_get_current(self):
286+
return (ErrorCode.NO_DATA, '00000000000000000000000000000000', '0000000000000000')

0 commit comments

Comments
 (0)