Skip to content

Commit

Permalink
Python: Getting Started pyramid (#7830)
Browse files Browse the repository at this point in the history
* Python: Getting Started pyramid

* 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] authored Sep 20, 2023
1 parent 1d55231 commit c271b82
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/platforms/python/guides/pyramid/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ redirect_from:
description: "Learn about using Sentry with Pyramid."
---

The Pyramid integration adds support for the [Pyramid Web Framework](https://trypyramid.com/). It requires Pyramid 1.6 or later.
The Pyramid integration adds support for the [Pyramid Web Framework](https://trypyramid.com/).

## Install

Expand All @@ -24,19 +24,16 @@ To configure the SDK, initialize it with the integration before or after your ap

```python
import sentry_sdk

from sentry_sdk.integrations.pyramid import PyramidIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
PyramidIntegration(),
],

# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production,
traces_sample_rate=1.0,
integrations=[
PyramidIntegration(),
],
)

from pyramid.config import Configurator
Expand All @@ -45,6 +42,31 @@ with Configurator() as config:
# ...
```

## Verify

```python
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

sentry_sdk.init(...) # same as above

def hello_world(request):
1/0 # raises an error
return Response('Hello World!')

if __name__ == '__main__':
with Configurator() as config:
config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()

server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
```

When you point your browser to [http://localhost:6543/](http://localhost:6543/) an error event will be sent to [sentry.io](https://sentry.io).

## Behavior

- The Sentry Python SDK will install the Pyramid integration for all of your apps. The integration hooks into Pyramid itself, not any of your apps specifically.
Expand Down Expand Up @@ -79,3 +101,8 @@ You can pass the following keyword arguments to `PyramidIntegration()`:
- `myroute` if you set `transaction_style="route_name"`

The default is `"route_name"`.

## Supported Versions

- Pyramid: 1.6+
- Python: 2.7+

1 comment on commit c271b82

@vercel
Copy link

@vercel vercel bot commented on c271b82 Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs.sentry.dev
docs.sentry.io
sentry-docs-git-master.sentry.dev

Please sign in to comment.