New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn when transaction entered without calling start_transaction
#3003
base: master
Are you sure you want to change the base?
Warn when transaction entered without calling start_transaction
#3003
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one question.
The transaction will not be sent to Sentry. To fix, start the transaction by | ||
passing it to sentry_sdk.start_transaction, like so: | ||
|
||
with sentry_sdk.start_transaction(transaction): | ||
# code here | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transaction will not be sent to Sentry. To fix, start the transaction by | |
passing it to sentry_sdk.start_transaction, like so: | |
with sentry_sdk.start_transaction(transaction): | |
# code here | |
""" | |
The transaction will not be sent to Sentry. To fix, start the transaction by | |
passing it to sentry_sdk.start_transaction, like so: | |
with sentry_sdk.start_transaction(transaction): | |
# code here | |
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spacing is intentional; it makes the message appear nicely in the logs, like so:
[sentry] WARNING: Transaction was entered without being started with sentry_sdk.start_transaction.
The transaction will not be sent to Sentry. To fix, start the transaction by
passing it to sentry_sdk.start_transaction, like so:
with sentry_sdk.start_transaction(transaction):
# code here
00c2bc7
to
5cd3884
Compare
a090a5c
to
f8586eb
Compare
5cd3884
to
f1346b0
Compare
`sampled` being set to `False` is not the only reason why the `_span_recorder` might be `None`. Another explanation is that the transaction was not started via `start_transaction`.
Transactions that are discarded because `_span_recorder` is `None` can also be discarded because they were not started with `sentry_sdk.start_transaction`. This change updates the debug message accordingly. Fixes GH-3000
f8586eb
to
d0fc544
Compare
…ransaction` Users who enter a transaction without calling `start_transaction` likely intended to start the transaction, since without a call to `start_transaction`, their transaction will not get sent to Sentry. This warning message clarifies this behavior, and could help avoid the confusion that led to issue #2990.
The previous name, `_possibly_stated`, contains a typo, which this change fixes. Co-authored-by: Anton Pirker <anton.pirker@sentry.io>
f1346b0
to
84ab96a
Compare
d0fc544
to
534a301
Compare
logger.warning( | ||
"""Transaction was entered without being started with sentry_sdk.start_transaction. | ||
The transaction will not be sent to Sentry. To fix, start the transaction by | ||
passing it to sentry_sdk.start_transaction, like so: | ||
|
||
with sentry_sdk.start_transaction(transaction): | ||
# code here | ||
""" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log messages should not be multi-line because it makes it hard or impossible to grep through the logs (or do some other line based processing)
Please change the log message to be one line.
This change should prevent confusion like what led to #2990 being opened.