Skip to content

Enable before_send_transaction for python #6089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.

```python
import sentry_sdk

def strip_sensitive_data(event, hint):
# modify event here
return event

sentry_sdk.init(
# ...

before_send_transaction=strip_sensitive_data,
)
```
2 changes: 1 addition & 1 deletion src/platforms/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ It also allows you to sample different transactions at different rates.

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/platforms/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ _(New in version 7.30.0)_

</ConfigKey>

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

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

</ConfigKey>

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

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.

Expand Down