This method is used for accepting the payloads used to connect transactions within a distributed trace.
Python agent version 126.96.36.199 or higher.
This API has been deprecated. Please use newrelic.agent.accept_distributed_trace_headers instead.
Distributed tracing must be enabled.
This call is used to link transactions by parsing the distributed tracing payloads generated by
dictionary or string
Required. The payload to be accepted.
Optional, defaults to
When successful, returns
When unsuccessful, returns
False. Accepting a payload can fail for several reasons:
- The current transaction is not enabled.
- Accept was called outside the scope of a transaction.
- The payload is empty.
- Distributed tracing is not enabled.
accept_distributed_trace_payloadwas called after
create_distributed_trace_payload, and not before.
accept_distributed_trace_payloadwas called multiple times in a single transaction.
- The payload could not be parsed.
- The payload was sent from an untrusted account.
An example of using
accept_distributed_trace_payload in a background task:
@newrelic.agent.background_task()def handle(request):payload = request.headers.get('newrelic')if payload:newrelic.agent.accept_distributed_trace_payload(payload)_do_some_work()
An example of using
accept_distributed_trace_payload and creating a background task for each message:
import newrelic.agentnewrelic.agent.initialize('newrelic.ini')application = newrelic.agent.register_application(timeout=10.0)def main(queue):for message in queue.consume():with newrelic.agent.BackgroundTask(application, 'Queue Consume'):payload = message.headers.get('newrelic')newrelic.agent.accept_distributed_trace_payload(payload,transport_type='Queue')_process_message(message)
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.