Skip to content

Commit 2e4a9ae

Browse files
Improve before_send_transactiondocs (#6509)
Co-authored-by: Anton Pirker <[email protected]>
1 parent 53cd1ee commit 2e4a9ae

File tree

1 file changed

+21
-1
lines changed
  • src/platform-includes/configuration/before-send-transaction

1 file changed

+21
-1
lines changed

src/platform-includes/configuration/before-send-transaction/python.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
In Python a function can be used to modify the transaction event or return a completely new one. If you return `None`, the event will be discarded.
1+
In Python, a function can be used to modify the transaction event or return a new instance. If you return `None`, the event will be discarded.
22

33
```python
44
import sentry_sdk
@@ -13,3 +13,23 @@ sentry_sdk.init(
1313
before_send_transaction=strip_sensitive_data,
1414
)
1515
```
16+
17+
Addtionally, you may filter out transaction events based on the request URL, like `/healthcheck`.
18+
19+
```python
20+
from urllib.parse import urlparse
21+
22+
def filter_transactions(event, hint):
23+
url_string = event["request"]["url"]
24+
parsed_url = urlparse(url_string)
25+
26+
if parsed_url.path == "/healthcheck":
27+
return None
28+
29+
return event
30+
31+
sentry_sdk.init(
32+
# ...
33+
before_send_transaction=filter_transactions,
34+
)
35+
```

0 commit comments

Comments
 (0)