pure_eval
This integration uses pure_eval to safely evaluate additional expressions in the source code and display their values alongside other local variables.
Install sentry-sdk from PyPI with the pure_eval extra or pip install pure_eval executing asttokens.
Copied
pip install --upgrade 'sentry-sdk[pure_eval]'
Add PureEvalIntegration() to your integrations list:
Copied
import sentry_sdk
from sentry_sdk.integrations.pure_eval import PureEvalIntegration
sentry_sdk.init(
dns="https://examplePublicKey@o0.ingest.sentry.io/0",
integrations=[
PureEvalIntegration(),
],
)
Copied
from types import SimpleNamespace
def main():
sentry_sdk.init(...) # same as above
namespace = SimpleNamespace()
namespace.d = {1: 2}
print(namespace.d[1] / 0)
main()
When you run this example script an error will be sent to Sentry. Through the PureEvalIntegration the stack trace of the error will include the values of namespace.d and namespace.d[1] which would not be shown without PureEvalIntegration.
- Python: 3.5+
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- pypi:sentry-sdk
- Version:
- 1.45.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/