Skip to content

Commit

Permalink
Enable before_send_transaction for python (#6089)
Browse files Browse the repository at this point in the history
Document before_send_transaction for python (+ code snippet)
  • Loading branch information
antonpirker authored Jan 19, 2023
1 parent 4ff0700 commit a952b9f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

1 comment on commit a952b9f

@vercel
Copy link

@vercel vercel bot commented on a952b9f Jan 19, 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-git-master.sentry.dev
sentry-docs.sentry.dev
docs.sentry.io

Please sign in to comment.