Skip to main content

[Python] How does continue_trace() work?

Updated over a month ago

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 = "7f410df7108e49d5a9f5d3ae7327cf5c-ad7951df7af88a3e"
    baggage = "sentry-trace_id=7f410df7108e49d5a9f5d3ae7327cf5c"    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?