Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.18 KB

currenttraceid-python-agent.mdx

File metadata and controls

42 lines (31 loc) · 1.18 KB
title type shortDescription tags metaDescription redirects freshnessValidatedDate
current_trace_id (Python agent API)
apiDoc
Returns the trace ID of the current transaction.
Agents
Python agent
Python agent API
New Relic Python API: Returns the trace ID of the current transaction, which is used by some other calls.
/docs/agents/python-agent/python-agent-api/currenttraceid-python-agent-api
/docs/agents/python-agent/python-agent-api/current_trace_id
never

Syntax [#syntax]

    newrelic.agent.current_trace_id()

Returns the trace ID of the current transaction or None if no transaction exists.

Description [#description]

Use current_trace_id to retrieve the trace ID of the current transaction.

Return values [#return-values]

Returns the trace ID of the current transaction. Returns None if there is no active transaction.

Examples [#examples]

Get the current trace ID [#function-trace-example]

    import newrelic.agent

    @newrelic.agent.background_task()
    def main():
        trace_id = newrelic.agent.current_trace_id()