diff --git a/docs/platforms/python/configuration/options.mdx b/docs/platforms/python/configuration/options.mdx index 918ff9928f40b..e8e35469a61b6 100644 --- a/docs/platforms/python/configuration/options.mdx +++ b/docs/platforms/python/configuration/options.mdx @@ -246,6 +246,8 @@ The callback typically gets a second argument (called a "hint") which contains t + + ## Transport Options Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments. @@ -331,11 +333,7 @@ If you want to disable all tracing you need to set `traces_sample_rate=None`. In - - -A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning `0` for those that are unwanted. Either this or `traces_sample_rate` must be defined to enable tracing. - - + diff --git a/platform-includes/performance/sampling-function-intro/python.mdx b/platform-includes/performance/sampling-function-intro/python.mdx index 8a5365580b033..00317b5618e0f 100644 --- a/platform-includes/performance/sampling-function-intro/python.mdx +++ b/platform-includes/performance/sampling-function-intro/python.mdx @@ -1,4 +1,4 @@ -To use the sampling function, set the option in your `sentry-sdk.init()` to a function that will accept a dictionary and return a sample rate between 0 and 1. For example: +To use the sampling function, set the option in your `sentry-sdk.init()` to a function that will accept a dictionary and return a sample rate between `0` and `1`. For example: diff --git a/platform-includes/performance/traces-sampler-as-filter/python.mdx b/platform-includes/performance/traces-sampler-as-filter/python.mdx index 98fac790484fd..2819af2d183b9 100644 --- a/platform-includes/performance/traces-sampler-as-filter/python.mdx +++ b/platform-includes/performance/traces-sampler-as-filter/python.mdx @@ -3,12 +3,14 @@ import sentry_sdk from sentry_sdk.types import SamplingContext def traces_sampler(sampling_context: SamplingContext) -> float: + # Examine provided sampling context along with anything in the + # global namespace to compute the sample rate for this transaction if "...": # Drop this transaction, by setting its sample rate to 0% return 0 - else: - # Default sample rate for all others (replaces traces_sample_rate) - return 0.1 + + # Default sample rate for all others (replaces traces_sample_rate) + return 0.1 sentry_sdk.init( # ... diff --git a/platform-includes/performance/traces-sampler-as-sampler/python.mdx b/platform-includes/performance/traces-sampler-as-sampler/python.mdx index 08df0fbe96d9e..ecfb2a57b36ee 100644 --- a/platform-includes/performance/traces-sampler-as-sampler/python.mdx +++ b/platform-includes/performance/traces-sampler-as-sampler/python.mdx @@ -3,10 +3,6 @@ import sentry_sdk from sentry_sdk.types import SamplingContext def traces_sampler(sampling_context: SamplingContext) -> float: - # Examine provided context data (including parent decision, if any) - # along with anything in the global namespace to compute the sample rate - # or sampling decision for this transaction - # Use the parent sampling decision if we have an incoming trace. # Note: we strongly recommend respecting the parent sampling decision, # as this ensures your traces will be complete! @@ -14,18 +10,20 @@ def traces_sampler(sampling_context: SamplingContext) -> float: if parent_sampling_decision is not None: return float(parent_sampling_decision) + # Examine provided sampling context along with anything in the + # global namespace to compute the sample rate for this transaction if "...": # These are important - take a big sample return 0.5 elif "...": - # These are less important or happen much more frequently - only take 1% + # These are less important - only take 1% return 0.01 elif "...": - # These aren't something worth tracking - drop all transactions like this + # These aren't worth tracking - drop these transactions return 0 - else: - # Default sample rate - return 0.1 + + # Default sample rate + return 0.1 sentry_sdk.init( # ... diff --git a/platform-includes/performance/traces-sampler-config-option/python.mdx b/platform-includes/performance/traces-sampler-config-option/python.mdx new file mode 100644 index 0000000000000..6a94749ed0645 --- /dev/null +++ b/platform-includes/performance/traces-sampler-config-option/python.mdx @@ -0,0 +1,5 @@ + + +A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning `0` for those that are unwanted. Either this or `traces_sample_rate` must be defined to enable tracing. + +