Skip to main content

[Python] How does continue_trace() work?

Issue

I am having trouble getting continue_trace() to properly propagate the trace information.

Applies To

  • Users of Custom Instrumentation

Symptoms

  • I'm calling continue_trace() but the trace headers do not seem to be applying

Resolution

continue_trace() returns the entire transaction with the trace headers, which you can then pass to start_transaction(). You will need to have the sentry_trace and baggage headers before hand before it is passed to continue_trace()

Here is an example of how continue_trace() could be used:

    sentry_trace = "0123456789abcdef0123456789abcdef-0123456789abcdef"
    baggage = "sentry-trace_id=123456789abcdef0123456789abcdef"    transaction = sentry_sdk.continue_trace(
        {"sentry-trace": sentry_trace, "baggage": baggage},
        op="demo",
        name="transaction"
    )    with sentry_sdk.start_transaction(transaction):
        print("starting transaction")
Did this answer your question?