Skip to content

Commit 81b51ff

Browse files
committed
Update sample and README.
1 parent dd20c24 commit 81b51ff

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The SDK supports Python 2 ≥ 2.7 and Python 3 ≥ 3.4. Only the official CPytho
3636

3737
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) and therefore the SDK for C/C++ is required and delivered with the Python SDK. See [here](https://github.com/Dynatrace/OneAgent-SDK-for-C#dynatrace-oneagent-sdk-for-cc-requirements) for its requirements, which also apply to the SDK for Python.
3838

39-
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. required Dynatrace OneAgent version is also shown here (it is the same as [listed in the OneAgent SDK for C/C++'s documentation](https://github.com/Dynatrace/OneAgent-SDK-for-C/blob/master/README.md#compatibility-of-dynatrace-oneagent-sdk-for-cc-releases-with-oneagent-releases)).
39+
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 Dynatrace OneAgent version (it is the same as [listed in the OneAgent SDK for C/C++'s documentation](https://github.com/Dynatrace/OneAgent-SDK-for-C/blob/master/README.md#compatibility-of-dynatrace-oneagent-sdk-for-cc-releases-with-oneagent-releases)).
4040

4141
|OneAgent SDK for Python|OneAgent SDK for C/C++|Dynatrace OneAgent|
4242
|:----------------------|:---------------------|:-----------------|
@@ -112,7 +112,7 @@ See the API documentation for the [`try_init` function](https://dynatrace.github
112112

113113
To use the SDK, get a reference to the [`SDK`](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/sdkref.html#oneagent.sdk.SDK)
114114
singleton by calling its static [`get`](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/sdkref.html#oneagent.sdk.SDK.get)
115-
static method. The first thing you may want to do with this object, is checking if the agent is active by comparing the value of the
115+
method. The first thing you may want to do with this object, is checking if the agent is active by comparing the value of the
116116
[`agent_state`](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/sdkref.html#oneagent.sdk.SDK.agent_state)
117117
property to the [`oneagent.common.AgentState`](https://dynatrace.github.io/OneAgent-SDK-for-Python/docs/sdkref.html#oneagent.common.AgentState) constants.
118118

@@ -164,15 +164,15 @@ strings. Byte strings must always use the UTF-8 encoding!
164164
<a name="features-and-how-to-use-them"></a>
165165
## Features and how to use them
166166

167-
The feature sets differ slightly with each language implementation. More functionality will be added over time, see <a href="https://answers.dynatrace.com/spaces/483/dynatrace-product-ideas/idea/198106/planned-features-for-oneagent-sdk.html" target="_blank">Planned features for OneAgent SDK</a> for details on upcoming features.
167+
The feature sets differ slightly with each language implementation. More functionality will be added over time, see [Planned features for OneAgent SDK](https://answers.dynatrace.com/spaces/483/dynatrace-product-ideas/idea/198106/planned-features-for-oneagent-sdk.html) for details on upcoming features.
168168

169169
A more detailed specification of the features can be found in [Dynatrace OneAgent SDK](https://github.com/Dynatrace/OneAgent-SDK#features).
170170

171-
|Feature|Required OneAgent SDK for Python version|
172-
|:------|:--------|
173-
|Trace incoming and outgoing remote calls |>=1.0.0 |
174-
|SQL database requests |>=1.0.0 |
175-
|Incoming web requests |>=1.0.0 |
171+
|Feature |Required OneAgent SDK for Python version|
172+
|:-----------------------------------------|:--------|
173+
|Trace incoming and outgoing remote calls |1.0.0 |
174+
|SQL database requests |1.0.0 |
175+
|Incoming web requests |1.0.0 |
176176

177177
<a name="remote-calls"></a>
178178
### Remote calls
@@ -289,7 +289,7 @@ To debug your OneAgent SDK for Python installation, execute the following Python
289289

290290
```python
291291
import oneagent
292-
oneagent.logger.setLevel(0)
292+
oneagent.logger.setLevel(1)
293293
init_result = oneagent.try_init(['loglevelsdk=finest', 'loglevel=finest'])
294294
print('InitResult=' + repr(init_result))
295295
```
@@ -298,7 +298,7 @@ If you get output containing `InitResult=InitResult(status=0, error=None)`, your
298298

299299
Known gotchas:
300300

301-
* `ImportError` or `ModuleNotFoundError` in line 1 that says that there is no module named `oneagent`.
301+
* `ImportError` or `ModuleNotFoundError` in line 1 that says that there is no module named `oneagent`.
302302

303303
Make sure that the `pip install` or equivalent succeeded (see [here](#installation)). Also make sure you use the `pip` corresponding to your `python` (if in doubt, use `python -m pip` instead of `pip` for installing).
304304

samples/basic-sdk-sample/basic_sdk_sample.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ def outgoing_remote_call(success):
4848
# Note that this property can only be accessed after starting the
4949
# tracer. See the documentation on tagging for more information.
5050
strtag = call.outgoing_dynatrace_string_tag
51-
52-
if not success:
53-
# This demonstrates how an exception leaving a tracer's
54-
# with-block will mark the tracer as failed.
55-
raise RuntimeError('remote error message')
56-
do_remote_call(strtag)
51+
do_remote_call(strtag, success)
5752
except RuntimeError: # Swallow the exception raised above.
5853
pass
5954
print('-remote')
6055

61-
failed = [False]
56+
failed = [None]
6257

63-
def do_remote_call_thread_func(strtag):
58+
def do_remote_call_thread_func(strtag, success):
6459
try:
6560
print('+thread')
6661
# We use positional arguments to specify required values and named
@@ -70,6 +65,8 @@ def do_remote_call_thread_func(strtag):
7065
'dupypr://localhost/dummyEndpoint',
7166
protocol_name='DUMMY_PY_PROTOCOL', str_tag=strtag)
7267
with incall:
68+
if not success:
69+
raise RuntimeError('Remote call failed on the server side.')
7370
dbinfo = getsdk().create_database_info(
7471
'Northwind', onesdk.DatabaseVendor.SQLSERVER,
7572
onesdk.Channel(onesdk.ChannelType.TCP_IP, '10.0.0.42:6666'))
@@ -92,26 +89,28 @@ def do_remote_call_thread_func(strtag):
9289
"UPDATE baz SET foo = foo + 1 WHERE qux = 23;")
9390
traced_db_operation(dbinfo, "COMMIT;")
9491
print('-thread')
95-
except Exception:
96-
failed[0] = True
92+
except Exception as e:
93+
failed[0] = e
9794
raise
9895

9996

100-
def do_remote_call(strtag):
97+
def do_remote_call(strtag, success):
10198
# This function simulates doing a remote call by calling a function
10299
# do_remote_call_thread_func in another thread, passing a string tag. See
103100
# the documentation on tagging for more information.
104101

102+
failed[0] = None
105103
workerthread = threading.Thread(
106104
target=do_remote_call_thread_func,
107-
args=(strtag,))
105+
args=(strtag, success))
108106
workerthread.start()
109107

110108
# Note that we need to join the thread, as all tagging assumes synchronous
111109
# calls.
112110
workerthread.join()
113111

114-
assert not failed[0]
112+
if failed[0] is not None:
113+
raise failed[0] #pylint:disable=raising-bad-type
115114

116115
def mock_incoming_web_request():
117116
sdk = getsdk()

0 commit comments

Comments
 (0)