From c003c22bb1efcc2b288746e27cf18200dc92ead0 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 30 Nov 2022 11:52:32 +0100 Subject: [PATCH 1/5] Add support for PHP to beforeSendTransaction --- src/platforms/common/configuration/options.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/common/configuration/options.mdx b/src/platforms/common/configuration/options.mdx index 0e5b35219899dc..a1af126c4b5703 100644 --- a/src/platforms/common/configuration/options.mdx +++ b/src/platforms/common/configuration/options.mdx @@ -567,7 +567,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. This can be used, for instance, for manual PII stripping before sending. From 950255f78b78dafc8904711e629b0c8d978eea58 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 30 Nov 2022 12:19:31 +0100 Subject: [PATCH 2/5] Add before_send_transaction examples --- .../before-send-transaction/php.laravel.mdx | 13 +++++++++++++ .../before-send-transaction/php.mdx | 10 ++++++++++ .../common/configuration/filtering.mdx | 18 ++++++++++++++---- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/platform-includes/configuration/before-send-transaction/php.laravel.mdx create mode 100644 src/platform-includes/configuration/before-send-transaction/php.mdx diff --git a/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx b/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx new file mode 100644 index 00000000000000..6287d9a4983f0c --- /dev/null +++ b/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx @@ -0,0 +1,13 @@ +In the Laravel config, a closure can be used to modify the event or return a completely new one. If you return `null`, the event will be discarded. + +```php {filename:config/sentry.php} +'before_send_transaction' => function (\Sentry\Event $event): ?\Sentry\Event { + return $event; +}, +``` + + + +Learn more in [Closures and Config Caching](/platforms/php/guides/laravel/configuration/laravel-options/#closures-and-config-caching). + + diff --git a/src/platform-includes/configuration/before-send-transaction/php.mdx b/src/platform-includes/configuration/before-send-transaction/php.mdx new file mode 100644 index 00000000000000..2533bd58b65551 --- /dev/null +++ b/src/platform-includes/configuration/before-send-transaction/php.mdx @@ -0,0 +1,10 @@ +In PHP, a closure can be used to modify the event or return a completely new one. If you return `null`, the event will be discarded. + +```php +\Sentry\init([ + 'dsn' => '___PUBLIC_DSN___', + 'before_send_transaction' => function (\Sentry\Event $event): ?\Sentry\Event { + return $event; + }, +]); +``` diff --git a/src/platforms/common/configuration/filtering.mdx b/src/platforms/common/configuration/filtering.mdx index 4eb578d9ad1abf..dba9f458dd9c30 100644 --- a/src/platforms/common/configuration/filtering.mdx +++ b/src/platforms/common/configuration/filtering.mdx @@ -22,8 +22,6 @@ All Sentry SDKs support the callback m - - Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs documentation](/product/error-monitoring/breadcrumbs/). @@ -85,9 +83,11 @@ In this example, the fingerprint is forced to a common value if an exception of -## Using Sampling to Filter Transaction Events +## Filtering Transaction Events + +To prevent certain transactions from being reported to Sentry, use the or configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want. -To prevent certain transactions from being reported to Sentry, use the configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want. (It also allows you to sample different transactions at different rates.) +### Using **Note:** The and config options are mutually exclusive. If you define a to filter out certain transactions, you must also handle the case of non-filtered transactions by returning the rate at which you'd like them sampled. @@ -95,6 +95,16 @@ In its simplest form, used just for filtering the transaction, it looks like thi +It also allows you to sample different transactions at different rates. + Learn more about configuring the sample rate. + + +### Using + + + + + \ No newline at end of file From 9cdef00068005b0c37ccf2fc6a00d20138966e00 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 30 Nov 2022 12:26:09 +0100 Subject: [PATCH 3/5] Fix synatx error --- src/platforms/common/configuration/filtering.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/common/configuration/filtering.mdx b/src/platforms/common/configuration/filtering.mdx index dba9f458dd9c30..441fc63aa6bf7a 100644 --- a/src/platforms/common/configuration/filtering.mdx +++ b/src/platforms/common/configuration/filtering.mdx @@ -99,7 +99,7 @@ It also allows you to sample different transactions at different rates. Learn more about configuring the sample rate. - + ### Using From e3cc2feda79b52f3bbcf24838c1f3e243d7f86e8 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 30 Nov 2022 13:01:29 +0100 Subject: [PATCH 4/5] Update code examples --- .../configuration/before-send-transaction/php.laravel.mdx | 4 ++-- .../configuration/before-send-transaction/php.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx b/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx index 6287d9a4983f0c..a9d9acd668e0ac 100644 --- a/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx +++ b/src/platform-includes/configuration/before-send-transaction/php.laravel.mdx @@ -1,8 +1,8 @@ In the Laravel config, a closure can be used to modify the event or return a completely new one. If you return `null`, the event will be discarded. ```php {filename:config/sentry.php} -'before_send_transaction' => function (\Sentry\Event $event): ?\Sentry\Event { - return $event; +'before_send_transaction' => function (\Sentry\Event $transaction): ?\Sentry\Event { + return $transaction; }, ``` diff --git a/src/platform-includes/configuration/before-send-transaction/php.mdx b/src/platform-includes/configuration/before-send-transaction/php.mdx index 2533bd58b65551..677266183a15d8 100644 --- a/src/platform-includes/configuration/before-send-transaction/php.mdx +++ b/src/platform-includes/configuration/before-send-transaction/php.mdx @@ -3,8 +3,8 @@ In PHP, a closure can be used to modify the event or return a completely new one ```php \Sentry\init([ 'dsn' => '___PUBLIC_DSN___', - 'before_send_transaction' => function (\Sentry\Event $event): ?\Sentry\Event { - return $event; + 'before_send_transaction' => function (\Sentry\Event $transaction): ?\Sentry\Event { + return $transaction; }, ]); ``` From 9fb6eb7fc1424ff3aa40af9b4f936c5c0f9cb81a Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Wed, 30 Nov 2022 19:59:02 +0100 Subject: [PATCH 5/5] Revert filter updates --- .../common/configuration/filtering.mdx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/platforms/common/configuration/filtering.mdx b/src/platforms/common/configuration/filtering.mdx index 441fc63aa6bf7a..4eb578d9ad1abf 100644 --- a/src/platforms/common/configuration/filtering.mdx +++ b/src/platforms/common/configuration/filtering.mdx @@ -22,6 +22,8 @@ All Sentry SDKs support the callback m + + Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs documentation](/product/error-monitoring/breadcrumbs/). @@ -83,11 +85,9 @@ In this example, the fingerprint is forced to a common value if an exception of -## Filtering Transaction Events - -To prevent certain transactions from being reported to Sentry, use the or configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want. +## Using Sampling to Filter Transaction Events -### Using +To prevent certain transactions from being reported to Sentry, use the configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want. (It also allows you to sample different transactions at different rates.) **Note:** The and config options are mutually exclusive. If you define a to filter out certain transactions, you must also handle the case of non-filtered transactions by returning the rate at which you'd like them sampled. @@ -95,16 +95,6 @@ In its simplest form, used just for filtering the transaction, it looks like thi -It also allows you to sample different transactions at different rates. - Learn more about configuring the sample rate. - - -### Using - - - - - \ No newline at end of file