From a952b9ff73d86ed6437af2d0ff573a8355189bf3 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Thu, 19 Jan 2023 11:49:12 +0100 Subject: [PATCH] Enable before_send_transaction for python (#6089) Document before_send_transaction for python (+ code snippet) --- .../before-send-transaction/python.mdx | 15 +++++++++++++++ src/platforms/common/configuration/filtering.mdx | 2 +- src/platforms/common/configuration/options.mdx | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 src/platform-includes/configuration/before-send-transaction/python.mdx diff --git a/src/platform-includes/configuration/before-send-transaction/python.mdx b/src/platform-includes/configuration/before-send-transaction/python.mdx new file mode 100644 index 0000000000000..1a9131af52ad4 --- /dev/null +++ b/src/platform-includes/configuration/before-send-transaction/python.mdx @@ -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, +) +``` diff --git a/src/platforms/common/configuration/filtering.mdx b/src/platforms/common/configuration/filtering.mdx index 96c312f742297..fbbc63460781e 100644 --- a/src/platforms/common/configuration/filtering.mdx +++ b/src/platforms/common/configuration/filtering.mdx @@ -101,7 +101,7 @@ It also allows you to sample different transactions at different rates. Learn more about configuring the sample rate. - + ### Using diff --git a/src/platforms/common/configuration/options.mdx b/src/platforms/common/configuration/options.mdx index 4b3560eb70d0b..07c4414e8a122 100644 --- a/src/platforms/common/configuration/options.mdx +++ b/src/platforms/common/configuration/options.mdx @@ -533,7 +533,7 @@ _(New in version 7.30.0)_ - + Enables the `LocalVariables` integration, which adds stack local variables to stack traces. @@ -584,7 +584,7 @@ This function is called with an SDK-specific message or error event object, and - + 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.