Skip to content

Clarify that continue_trace does not start transaction #9771

Closed

Description

@szokeasaurusrex

Core or SDK?

Platform/SDK

Which part? Which one?

Python

Description

The documentation should clarify the fact that while continue_trace creates transactions, it does not start them. For instance, if one has the following code:

with sentry_sdk.continue_trace(sampled=True, ...):
    ...  # do something ...

The generated transaction does not get sent to Sentry (despite the sampled=True) because the transaction was not started with start_transaction.

Suggested Solution

The above sample can be corrected as follows:

transaction = sentry_sdk.continue_trace(sampled=True, ...)
with sentry_sdk.start_transaction(transaction):
    ...  # do something ...

This way, the transaction is continued from the trace, and it gets started properly.


We should include an example like the above somewhere in the docs, and also explain that transactions must always be started with start_transaction. A good place to do this might be here.

Making these changes will help avoid the confusion that led to getsentry/sentry-python#2990 being opened, even though the behavior described in that issue is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions