Skip to content

Commit

Permalink
chore: add language identifiers, +link
Browse files Browse the repository at this point in the history
  • Loading branch information
brnhensley committed May 29, 2023
1 parent cdf985d commit 78fc348
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ redirects:

## Syntax

```
```py
newrelic.agent.create_distributed_trace_payload()
```

Expand All @@ -25,7 +25,7 @@ This method is used for generating payloads used to connect transactions within
Python agent version 4.2.0.100 or higher.

<Callout variant="caution">
This API has been deprecated. Please use newrelic.agent.insert_distributed_trace_headers instead.
This API has been deprecated. Please use [`newrelic.agent.insert_distributed_trace_headers`](/docs/apm/agents/python-agent/python-agent-api/insertdistributedtraceheaders-python-agent-api) instead.
</Callout>

Distributed tracing must be [enabled](/docs/enable-distributed-tracing#python).
Expand All @@ -40,7 +40,7 @@ This call is used to implement distributed tracing. It generates a payload that

## Return values

When successful, returns a `DistributedTracePayload` object, which inherits from Python's builtin `dict` type and has the following additional methods:
When successful, returns a `DistributedTracePayload` object, which inherits from Python's built in `dict` type and has the following additional methods:

* `text`: Generate a JSON encoded string version of the payload.
* `http_safe`: Generate a base64 encoded string version of the payload.
Expand All @@ -57,13 +57,12 @@ When unsuccessful, returns `None`. This can happen when distributed tracing is n

An example of using `create_distributed_trace_payload` in creating two [external traces](/docs/agents/python-agent/python-agent-api/external-trace) from within single a background task:

```
```py
@newrelic.agent.background_task()
def main(url):
header_key = newrelic.agent.ExternalTrace.cat_distributed_trace_key

with newrelic.agent.ExternalTrace('my_external_library',
url, method='GET'):
with newrelic.agent.ExternalTrace('my_external_library', url, method='GET'):
# Generate the payload in the context of the ExternalTrace
# span that sends it
payload = newrelic.agent.create_distributed_trace_payload()
Expand All @@ -72,8 +71,7 @@ def main(url):

data = _process_response(response)

with newrelic.agent.ExternalTrace('my_external_library',
url, method='POST'):
with newrelic.agent.ExternalTrace('my_external_library', url, method='POST'):
# Generate the payload in the context of the ExternalTrace
# span that sends it
payload = newrelic.agent.create_distributed_trace_payload()
Expand All @@ -85,7 +83,7 @@ def main(url):

An example of using `create_distributed_trace_payload` in creating an [external trace](/docs/agents/python-agent/python-agent-api/external-trace):

```
```py
def _bind_url(url, *args, **kwargs):
# _bind_url is called with the args and kwargs sent to the `get`
# method below
Expand Down

0 comments on commit 78fc348

Please sign in to comment.