Skip to content

Commit a952b9f

Browse files
authored
Enable before_send_transaction for python (#6089)
Document before_send_transaction for python (+ code snippet)
1 parent 4ff0700 commit a952b9f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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.
2+
3+
```python
4+
import sentry_sdk
5+
6+
def strip_sensitive_data(event, hint):
7+
# modify event here
8+
return event
9+
10+
sentry_sdk.init(
11+
# ...
12+
13+
before_send_transaction=strip_sensitive_data,
14+
)
15+
```

src/platforms/common/configuration/filtering.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ It also allows you to sample different transactions at different rates.
101101

102102
Learn more about <PlatformLink to="/configuration/sampling/">configuring the sample rate</PlatformLink>.
103103

104-
<PlatformSection supported={["node", "javascript", "php", "go"]} notSupported={["php.symfony"]}>
104+
<PlatformSection supported={["node", "javascript", "php", "go", "python"]} notSupported={["php.symfony"]}>
105105

106106
### Using <PlatformIdentifier name="before-send-transaction" />
107107

src/platforms/common/configuration/options.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ _(New in version 7.30.0)_
533533

534534
</ConfigKey>
535535

536-
<ConfigKey name="_experiments.include-stack-locals" supported={["node"]}>
536+
<ConfigKey name="\_experiments.include-stack-locals" supported={["node"]}>
537537

538538
Enables the `LocalVariables` integration, which adds stack local variables to
539539
stack traces.
@@ -584,7 +584,7 @@ This function is called with an SDK-specific message or error event object, and
584584

585585
</ConfigKey>
586586

587-
<ConfigKey name="before-send-transaction" supported={["javascript", "node", "php", "go"]} notSupported={["php.symfony"]}>
587+
<ConfigKey name="before-send-transaction" supported={["javascript", "node", "php", "go", "python"]} notSupported={["php.symfony"]}>
588588

589589
This function is called with an SDK-specific transaction event object, and can return a modified transaction event object, or `null` to skip reporting the event. One way this might be used is for manual PII stripping before sending.
590590

0 commit comments

Comments
 (0)