pure_eval
Learn about `pure_eval` and how to add it to your integrations list.
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
.
pip install --upgrade 'sentry-sdk[pure_eval]'
Add PureEvalIntegration()
to your integrations
list:
import sentry_sdk
from sentry_sdk.integrations.pure_eval import PureEvalIntegration
sentry_sdk.init(
dns="https://examplePublicKey@o0.ingest.sentry.io/0",
integrations=[
PureEvalIntegration(),
],
)
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.6+
The versions above apply for Sentry Python SDK version 2.0+
, which drops support for some legacy Python and framework versions. If you're looking to use Sentry with older Python or framework versions, consider using an SDK version from the 1.x
major line of releases.
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").