Skip to content

Commit

Permalink
Python: Getting Started enhanced locals (#7862)
Browse files Browse the repository at this point in the history
* Python: Getting Started enhanced locals

* style(lint): Auto commit lint changes

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
antonpirker and getsantry[bot] committed Sep 20, 2023
1 parent c271b82 commit 68c37ce
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ description: "Learn about `pure_eval` and how to add it to your integrations lis
sidebar_order: 40
---

<!-- NOTE: Due to being in common, redirects are in vercel.json -->

This integration uses [`pure_eval`](https://github.com/alexmojaki/pure_eval) to safely evaluate additional expressions in the source code and display their values alongside other local variables.

<Note>

**This integration is experimental.** It may be removed in minor versions.

</Note>

## Install

Install `sentry-sdk` from PyPI with the `pure_eval` extra or `pip install pure_eval executing asttokens`.
Expand All @@ -40,6 +32,23 @@ sentry_sdk.init(
)
```

## Verify

```python
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`.

## Supported Versions

- Python: 3.5+

0 comments on commit 68c37ce

Please sign in to comment.