From 1133cff10ecc8724140913074404b781af8d66f7 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 7 Jul 2025 14:51:35 +0200 Subject: [PATCH 01/11] feat(python): Add a 3.0 version of the sampling page --- .../python/configuration/sampling.mdx | 22 ++- .../python/configuration/sampling__v3.x.mdx | 125 ++++++++++++++++++ .../custom-sampling-context/python.mdx | 24 ++-- 3 files changed, 158 insertions(+), 13 deletions(-) create mode 100644 docs/platforms/python/configuration/sampling__v3.x.mdx diff --git a/docs/platforms/python/configuration/sampling.mdx b/docs/platforms/python/configuration/sampling.mdx index b1846ad87163d..6b5aeda960c03 100644 --- a/docs/platforms/python/configuration/sampling.mdx +++ b/docs/platforms/python/configuration/sampling.mdx @@ -83,7 +83,27 @@ The information contained in the When using custom instrumentation to create a transaction, you can add data to the by passing it as an optional second argument to . This is useful if there's data to which you want the sampler to have access but which you don't want to attach to the transaction as `tags` or `data`, such as information that's sensitive or that’s too large to send with the transaction. For example: - +```python +sentry_sdk.start_transaction( + # kwargs passed to Transaction constructor - will be recorded on transaction + name="GET /search", + op="search", + data={ + "query_params": { + "animal": "dog", + "type": "very good" + } + }, + # `custom_sampling_context` - won't be recorded + custom_sampling_context={ + # PII + "user_id": "12312012", + # too big to send + "search_results": { ... } + } +) +``` + ## Inheritance diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx new file mode 100644 index 0000000000000..d515e332e2d1e --- /dev/null +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -0,0 +1,125 @@ +--- +title: Sampling +description: "Learn how to configure the volume of error and transaction events sent to Sentry." +sidebar_order: 60 +--- + +Adding Sentry to your app gives you a great deal of very valuable information about errors and performance you wouldn't otherwise get. And lots of information is good -- as long as it's the right information, at a reasonable volume. + +## Sampling Error Events + +To send a representative sample of your errors to Sentry, set the option in your SDK configuration to a number between `0` (0% of errors sent) and `1` (100% of errors sent). This is a static rate, which will apply equally to all errors. For example, to sample 25% of your errors: + + + +The error sample rate defaults to `1.0`, meaning all errors are sent to Sentry. + +Changing the error sample rate requires re-deployment. In addition, setting an SDK sample rate limits visibility into the source of events. Setting a [rate limit](/pricing/quotas/manage-event-stream-guide/#rate-limiting) for your project (which only drops events when volume is high) may better suit your needs. + +### Dynamically Sampling Error Events + +To sample error events dynamically, set the to a function that returns the desired sample rate for the event. The takes two arguments, and . `event` is the [Event](https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/_types.py) that will be sent to Sentry, `hint` includes Python's [sys.exc_info()](https://docs.python.org/3/library/sys.html#sys.exc_info) information in `hint["exc_info"]`. + + + +Your function **must return a valid value**. A valid value is either: + +- A **floating-point number** between `0.0` and `1.0` (inclusive) indicating the probability an error gets sampled, **or** +- A **boolean** indicating whether or not to sample the error. + + + +One potential use case for the is to apply different sample rates for different exception types. For instance, if you would like to sample some exception called `MyException` at 50%, discard all events of another exception called `MyIgnoredException`, and sample all other exception types at 100%, you could use the following code when initializing the SDK: + + + + + +You can define at most one of the and the . If both are set, the will control sampling, and the will be ignored. + + + +## Sampling Transaction Events + +We recommend sampling your transactions for two reasons: + +1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ page load or _every_ API request may add an undesirable load to your system. +2. Enabling sampling allows you to better manage the number of events sent to Sentry, so you can tailor your volume to your organization's needs. + +Choose a sampling rate with the goal of finding a balance between performance and volume concerns with data accuracy. You don't want to collect _too_ much data, but you want to collect sufficient data from which to draw meaningful conclusions. If you’re not sure what rate to choose, start with a low value and gradually increase it as you learn more about your traffic patterns and volume. + +## Configuring the Transaction Sample Rate + +The Sentry SDKs have two configuration options to control the volume of transactions sent to Sentry, allowing you to take a representative sample: + +1. Uniform sample rate (): + - Provides an even cross-section of transactions, no matter where in your app or under what circumstances they occur. + - Uses default [inheritance](#inheritance) and [precedence](#precedence) behavior +2. Sampling function () which: + - Samples different transactions at different rates + - Filters out some + transactions entirely + - Modifies default [precedence](#precedence) and [inheritance](#inheritance) behavior + +By default, none of these options are set, meaning no transactions will be sent to Sentry. You must set either one of the options to start sending transactions. + +### Setting a Uniform Sample Rate + + + +### Setting a Sampling Function + + + +## Sampling Context Data + +### Default Sampling Context Data + +The information contained in the object passed to the when a transaction is created varies by integration. + + + +### Custom Sampling Context Data + +When using custom instrumentation to create a transaction, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. + + + +## Inheritance + +Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services. + +(See Distributed Tracing for more about how that propagation is done.) + +If the transaction currently being created is one of those subsequent transactions (in other words, if it has a parent transaction), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. + + + +In some SDKs, for convenience, the function can return a boolean, so that a parent's decision can be returned directly if that's the desired behavior. + + + +If you're using a rather than a , the decision will always be inherited. + +## Forcing a Sampling Decision + +If you know at transaction creation time whether or not you want the transaction sent to Sentry, you also have the option of passing a sampling decision directly to the transaction constructor (note, not in the object). If you do that, the transaction won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. + + + +## Precedence + +There are multiple ways for a transaction to end up with a sampling decision. + +- Random sampling according to a static sample rate set in +- Random sampling according to a sample function rate returned by +- Absolute decision (100% chance or 0% chance) returned by +- If the transaction has a parent, inheriting its parent's sampling decision +- Absolute decision passed to + +When there's the potential for more than one of these to come into play, the following precedence rules apply: + +1. If a sampling decision is passed to , that decision will be used, overriding everything else. +2. If is defined, its decision will be used. It can choose to keep or ignore any parent sampling decision, use the sampling context data to make its own decision, or choose a sample rate for the transaction. We advise against overriding the parent sampling decision because it will break distributed traces. +3. If is not defined, but there's a parent sampling decision, the parent sampling decision will be used. +4. If is not defined and there's no parent sampling decision, will be used. diff --git a/platform-includes/performance/custom-sampling-context/python.mdx b/platform-includes/performance/custom-sampling-context/python.mdx index 640b3abdd266d..91744c3b6a754 100644 --- a/platform-includes/performance/custom-sampling-context/python.mdx +++ b/platform-includes/performance/custom-sampling-context/python.mdx @@ -1,20 +1,20 @@ ```python -sentry_sdk.start_transaction( - # kwargs passed to Transaction constructor - will be recorded on transaction +sentry_sdk.start_span( name="GET /search", op="search", data={ - "query_params": { - "animal": "dog", - "type": "very good" - } + "query_params": { + "animal": "dog", + "type": "very good" + } }, - # `custom_sampling_context` - won't be recorded - custom_sampling_context={ - # PII + # Attributes defined at root span start will be accessible in traces_sampler + # and they will be sent to Sentry unless filtered out manually. + # Note that these can only be primitive types or a list of a single primitive + # type. + attributes={ "user_id": "12312012", - # too big to send - "search_results": { ... } + "foo": "bar", } -); +) ``` From 386f922589012ec2be9670503b0c063677fd6d5c Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 7 Jul 2025 14:58:50 +0200 Subject: [PATCH 02/11] feat(python): Add a 3.0 version of the sampling page --- docs/platforms/python/configuration/sampling.mdx | 7 ++++++- docs/platforms/python/configuration/sampling__v3.x.mdx | 8 ++++---- .../performance/force-sampling-decision/python.mdx | 10 ++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/platforms/python/configuration/sampling.mdx b/docs/platforms/python/configuration/sampling.mdx index 6b5aeda960c03..928bfb6e072b8 100644 --- a/docs/platforms/python/configuration/sampling.mdx +++ b/docs/platforms/python/configuration/sampling.mdx @@ -125,7 +125,12 @@ If you're using a rather than a If you know at transaction creation time whether or not you want the transaction sent to Sentry, you also have the option of passing a sampling decision directly to the transaction constructor (note, not in the object). If you do that, the transaction won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. - +```python +sentry_sdk.start_transaction( + name="GET /search", + sampled=True +) +``` ## Precedence diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index d515e332e2d1e..22eec99af45dd 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -99,23 +99,23 @@ In some SDKs, for convenience, the -If you're using a rather than a , the decision will always be inherited. +If you're using a rather than a , the decision will always be inherited. The provided will only be used to generate a sample rate if there is sampling decision coming in from upstream. ## Forcing a Sampling Decision -If you know at transaction creation time whether or not you want the transaction sent to Sentry, you also have the option of passing a sampling decision directly to the transaction constructor (note, not in the object). If you do that, the transaction won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. +If you know at span creation time whether or not you want the root span (transaction) sent to Sentry, you also have the option of passing a sampling decision directly in the `start_span` API. If you do that, the root span won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. ## Precedence -There are multiple ways for a transaction to end up with a sampling decision. +There are multiple ways for a root span (transaction) to end up with a sampling decision. - Random sampling according to a static sample rate set in - Random sampling according to a sample function rate returned by - Absolute decision (100% chance or 0% chance) returned by - If the transaction has a parent, inheriting its parent's sampling decision -- Absolute decision passed to +- Absolute decision passed to When there's the potential for more than one of these to come into play, the following precedence rules apply: diff --git a/platform-includes/performance/force-sampling-decision/python.mdx b/platform-includes/performance/force-sampling-decision/python.mdx index 9a1f333fbd906..6939f5d20ff45 100644 --- a/platform-includes/performance/force-sampling-decision/python.mdx +++ b/platform-includes/performance/force-sampling-decision/python.mdx @@ -1,6 +1,8 @@ ```python -sentry_sdk.start_transaction( - name="GET /search", - sampled=True -); +sentry_sdk.start_span( + name="GET /search", + # Sample this span. Note that the `sampled` parameter is only taken into + # account for root-level spans (transactions). + sampled=True, +) ``` From 3889322f07ef5085a51c5c180aad92f3cb80a473 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 7 Jul 2025 15:47:05 +0200 Subject: [PATCH 03/11] some transaction -> root span renames --- docs/platforms/python/configuration/sampling__v3.x.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index 22eec99af45dd..f6313b14e2d6c 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -41,7 +41,7 @@ You can define at most one of the an ## Sampling Transaction Events -We recommend sampling your transactions for two reasons: +We recommend sampling your transactions (root spans) for two reasons: 1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ page load or _every_ API request may add an undesirable load to your system. 2. Enabling sampling allows you to better manage the number of events sent to Sentry, so you can tailor your volume to your organization's needs. @@ -75,23 +75,23 @@ By default, none of these options are set, meaning no transactions will be sent ### Default Sampling Context Data -The information contained in the object passed to the when a transaction is created varies by integration. +The information contained in the object passed to the when a root span is created varies by integration. ### Custom Sampling Context Data -When using custom instrumentation to create a transaction, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. +When using custom instrumentation to create a root span, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. ## Inheritance -Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services. +Whatever a root span's sampling decision, that decision will be passed to its child spans and from there to any root spans they subsequently cause in other services. (See Distributed Tracing for more about how that propagation is done.) -If the transaction currently being created is one of those subsequent transactions (in other words, if it has a parent transaction), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. +If the root span currently being created is one of those subsequent root spans (in other words, if it has a parent root span), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. From 4781bb8219aa28acd20ce622dba4053344a80a74 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Thu, 10 Jul 2025 13:34:53 +0200 Subject: [PATCH 04/11] root span -> transaction (less confusing) --- .../python/configuration/sampling__v3.x.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index f6313b14e2d6c..11b84c3032006 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -41,7 +41,7 @@ You can define at most one of the an ## Sampling Transaction Events -We recommend sampling your transactions (root spans) for two reasons: +We recommend sampling your transactions for two reasons: 1. Capturing a single trace involves minimal overhead, but capturing traces for _every_ page load or _every_ API request may add an undesirable load to your system. 2. Enabling sampling allows you to better manage the number of events sent to Sentry, so you can tailor your volume to your organization's needs. @@ -75,23 +75,23 @@ By default, none of these options are set, meaning no transactions will be sent ### Default Sampling Context Data -The information contained in the object passed to the when a root span is created varies by integration. +The information contained in the object passed to the when a transaction is created varies by integration. ### Custom Sampling Context Data -When using custom instrumentation to create a root span, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. +When using custom instrumentation to create a transaction, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. ## Inheritance -Whatever a root span's sampling decision, that decision will be passed to its child spans and from there to any root spans they subsequently cause in other services. +Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services. (See Distributed Tracing for more about how that propagation is done.) -If the root span currently being created is one of those subsequent root spans (in other words, if it has a parent root span), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. +If the transaction currently being created is one of those subsequent transactions (in other words, if it has a parent transaction), the upstream (parent) sampling decision will be included in the sampling context data. Your can use this information to choose whether to inherit that decision. In most cases, inheritance is the right choice, to avoid breaking distributed traces. A broken trace will not include all your services. @@ -103,13 +103,13 @@ If you're using a rather than a ## Forcing a Sampling Decision -If you know at span creation time whether or not you want the root span (transaction) sent to Sentry, you also have the option of passing a sampling decision directly in the `start_span` API. If you do that, the root span won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. +If you know at span creation time whether or not you want the transaction sent to Sentry, you also have the option of passing a sampling decision directly in the `start_span` API. If you do that, the transaction won't be subject to the , nor will be run, so you can count on the decision that's passed not to be overwritten. ## Precedence -There are multiple ways for a root span (transaction) to end up with a sampling decision. +There are multiple ways for a transaction to end up with a sampling decision. - Random sampling according to a static sample rate set in - Random sampling according to a sample function rate returned by From 738d30c3af55acdc6352e6af2928285eaec1a64f Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Thu, 10 Jul 2025 13:36:46 +0200 Subject: [PATCH 05/11] . --- .../performance/custom-sampling-context/python.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/performance/custom-sampling-context/python.mdx b/platform-includes/performance/custom-sampling-context/python.mdx index 91744c3b6a754..dcd236d832d1b 100644 --- a/platform-includes/performance/custom-sampling-context/python.mdx +++ b/platform-includes/performance/custom-sampling-context/python.mdx @@ -8,7 +8,7 @@ sentry_sdk.start_span( "type": "very good" } }, - # Attributes defined at root span start will be accessible in traces_sampler + # Attributes defined at root span (transaction) start will be accessible in traces_sampler # and they will be sent to Sentry unless filtered out manually. # Note that these can only be primitive types or a list of a single primitive # type. From 19faf1ed433a398fb5856ae9c0b708c4ec8f1ebe Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 14 Jul 2025 10:19:32 +0200 Subject: [PATCH 06/11] . --- docs/platforms/python/profiling/index.mdx | 2 +- .../default-sampling-context-platform/python.mdx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/platforms/python/profiling/index.mdx b/docs/platforms/python/profiling/index.mdx index 1ce29d7ffbc39..0157172228c6a 100644 --- a/docs/platforms/python/profiling/index.mdx +++ b/docs/platforms/python/profiling/index.mdx @@ -115,7 +115,7 @@ sentry_sdk.init( # To set a uniform sample rate # Set profiles_sample_rate to 1.0 to profile 100% # of sampled transactions. - # We recommend adjusting this value in production, + # We recommend adjusting this value in production. profiles_sample_rate=1.0, # Alternatively, to control sampling dynamically profiles_sampler=profiles_sampler diff --git a/platform-includes/performance/default-sampling-context-platform/python.mdx b/platform-includes/performance/default-sampling-context-platform/python.mdx index 94f0496671dd6..0a01984210df7 100644 --- a/platform-includes/performance/default-sampling-context-platform/python.mdx +++ b/platform-includes/performance/default-sampling-context-platform/python.mdx @@ -1,12 +1,12 @@ -For Python-based SDKs, it includes at least the following: +For the Python SDK, it includes at least the following: ```python { - "transaction_context": { - "name": # transaction title at creation time - "op": # short description of transaction type, like "http.request" - }, - "parent_sampled": # if this transaction has a parent, its sampling decision - ... # custom context as passed to `start_transaction` + "transaction_context": { + "name": # transaction title at creation time + "op": # short description of transaction type, like "http.request" + }, + "parent_sampled": # if this transaction has a parent, its sampling decision + ... # other attributes as passed to `start_span` } ``` From 41adb3ce70cf8b2f20a1222378e7fdac141634d6 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 14 Jul 2025 10:54:47 +0200 Subject: [PATCH 07/11] Remove unused snippets --- .../default-sampling-context/python.aiohttp.mdx | 9 --------- .../default-sampling-context/python.asgi.mdx | 9 --------- .../default-sampling-context/python.aws-lambda.mdx | 10 ---------- .../default-sampling-context/python.bottle.mdx | 12 ------------ .../default-sampling-context/python.celery.mdx | 9 --------- .../default-sampling-context/python.django.mdx | 12 ------------ .../default-sampling-context/python.falcon.mdx | 12 ------------ .../default-sampling-context/python.flask.mdx | 12 ------------ .../python.gcp-functions.mdx | 10 ---------- .../default-sampling-context/python.pyramid.mdx | 12 ------------ .../default-sampling-context/python.rq.mdx | 9 --------- .../default-sampling-context/python.tornado.mdx | 9 --------- .../default-sampling-context/python.tryton.mdx | 12 ------------ .../default-sampling-context/python.wsgi.mdx | 12 ------------ 14 files changed, 149 deletions(-) delete mode 100644 platform-includes/performance/default-sampling-context/python.aiohttp.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.asgi.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.aws-lambda.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.bottle.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.celery.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.django.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.falcon.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.flask.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.gcp-functions.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.pyramid.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.rq.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.tornado.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.tryton.mdx delete mode 100644 platform-includes/performance/default-sampling-context/python.wsgi.mdx diff --git a/platform-includes/performance/default-sampling-context/python.aiohttp.mdx b/platform-includes/performance/default-sampling-context/python.aiohttp.mdx deleted file mode 100644 index 72f4c27c26a51..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.aiohttp.mdx +++ /dev/null @@ -1,9 +0,0 @@ - - -The AIOHTTP integration adds the incoming request object: - -```python -{ - "aiohttp_request": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.asgi.mdx b/platform-includes/performance/default-sampling-context/python.asgi.mdx deleted file mode 100644 index 848bf2bacea85..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.asgi.mdx +++ /dev/null @@ -1,9 +0,0 @@ - - -The ASGI integration adds the request scope: - -```python -{ - "asgi_scope": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.aws-lambda.mdx b/platform-includes/performance/default-sampling-context/python.aws-lambda.mdx deleted file mode 100644 index 885892cc390f6..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.aws-lambda.mdx +++ /dev/null @@ -1,10 +0,0 @@ - - -The AWS Lambda integration adds the `event` and `context` passed to the function handler: - -```python -{ - "aws_event": , - "aws_context": , -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.bottle.mdx b/platform-includes/performance/default-sampling-context/python.bottle.mdx deleted file mode 100644 index e5b3e8771245a..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.bottle.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Bottle integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.celery.mdx b/platform-includes/performance/default-sampling-context/python.celery.mdx deleted file mode 100644 index 146c7ea1cfa23..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.celery.mdx +++ /dev/null @@ -1,9 +0,0 @@ - - -The Celery integration adds information about the current job: - -```python -{ - "celery_job": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.django.mdx b/platform-includes/performance/default-sampling-context/python.django.mdx deleted file mode 100644 index 5a728463af5af..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.django.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Django integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.falcon.mdx b/platform-includes/performance/default-sampling-context/python.falcon.mdx deleted file mode 100644 index 1da7785b14e47..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.falcon.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Falcon integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.flask.mdx b/platform-includes/performance/default-sampling-context/python.flask.mdx deleted file mode 100644 index f3ab70a7964ad..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.flask.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Flask integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.gcp-functions.mdx b/platform-includes/performance/default-sampling-context/python.gcp-functions.mdx deleted file mode 100644 index 8420a5a8a9ca6..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.gcp-functions.mdx +++ /dev/null @@ -1,10 +0,0 @@ - - -The Google Cloud Functions integration adds information about the environment and incoming event: - -```python -{ - "gcp_env": , - "gcp_event": , -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.pyramid.mdx b/platform-includes/performance/default-sampling-context/python.pyramid.mdx deleted file mode 100644 index d550e0ea5a3bd..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.pyramid.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Pyramid integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.rq.mdx b/platform-includes/performance/default-sampling-context/python.rq.mdx deleted file mode 100644 index 1562d1f243a56..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.rq.mdx +++ /dev/null @@ -1,9 +0,0 @@ - - -The RQ integration adds information about the current job: - -```python -{ - "rq_job": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.tornado.mdx b/platform-includes/performance/default-sampling-context/python.tornado.mdx deleted file mode 100644 index f95ef25ceccb9..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.tornado.mdx +++ /dev/null @@ -1,9 +0,0 @@ - - -The Tornado integration adds information about the current request: - -```python -{ - "tornado_request": # same as tornado.RequestHandler().request -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.tryton.mdx b/platform-includes/performance/default-sampling-context/python.tryton.mdx deleted file mode 100644 index d426a82d36430..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.tryton.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The Tryton integration adds the WSGI request [`environ` object](https://www.python.org/dev/peps/pep-3333/#environ-variables): - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` diff --git a/platform-includes/performance/default-sampling-context/python.wsgi.mdx b/platform-includes/performance/default-sampling-context/python.wsgi.mdx deleted file mode 100644 index f8e56c02c0e11..0000000000000 --- a/platform-includes/performance/default-sampling-context/python.wsgi.mdx +++ /dev/null @@ -1,12 +0,0 @@ - - -The WSGI integration adds the request environ: - -```python -{ - # This can be useful for cases in which the transaction starts before the URL - # is resolved into a route (meaning the transaction's name won't help much), - # as it contains parsed URL data - "wsgi_environ": -} -``` From 1850f7f834c145baf9887db2beceb27025ae1760 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 14 Jul 2025 12:17:14 +0200 Subject: [PATCH 08/11] typo --- platform-includes/performance/traces-sample-rate/python.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/performance/traces-sample-rate/python.mdx b/platform-includes/performance/traces-sample-rate/python.mdx index 97adb24cd1181..68b7fedcce331 100644 --- a/platform-includes/performance/traces-sample-rate/python.mdx +++ b/platform-includes/performance/traces-sample-rate/python.mdx @@ -4,7 +4,7 @@ sentry_sdk.init( # Set traces_sample_rate to 1.0 to capture 100% # of transactions for tracing. - # We recommend adjusting this value in production, + # We recommend adjusting this value in production. traces_sample_rate=1.0, ) ``` From b7ada8a75ffac31c0ecd3041fb0d94bf1f2320ec Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 14 Jul 2025 12:30:59 +0200 Subject: [PATCH 09/11] better order --- docs/platforms/python/configuration/sampling__v3.x.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index 11b84c3032006..2c76112aca137 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -81,10 +81,12 @@ The information contained in the ### Custom Sampling Context Data -When using custom instrumentation to create a transaction, you can add data to the by providing additional `attributes` to . All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. +When using custom instrumentation to create a transaction, you can add data to the by providing additional `attributes` to . +All span attributes provided at span start are accessible via the and will also ultimately be sent to Sentry. If you want to exclude an attribute, you can filter it out in a `before_send`. + ## Inheritance Whatever a transaction's sampling decision, that decision will be passed to its child spans and from there to any transactions they subsequently cause in other services. From b8fbf7cfe0bf7ee46c1a7f33a744d9b20565355b Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Mon, 14 Jul 2025 12:32:31 +0200 Subject: [PATCH 10/11] fix --- docs/platforms/python/configuration/sampling__v3.x.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index 2c76112aca137..3719a34bae320 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -101,7 +101,7 @@ In some SDKs, for convenience, the -If you're using a rather than a , the decision will always be inherited. The provided will only be used to generate a sample rate if there is sampling decision coming in from upstream. +If you're using a rather than a , the decision will always be inherited. The provided will only be used to generate a sample rate if there is no sampling decision coming in from upstream. ## Forcing a Sampling Decision From 1a5902715234d7f58f8a67f6fbfba9289b39d430 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 15 Jul 2025 09:02:18 +0200 Subject: [PATCH 11/11] Apply suggestions from code review Co-authored-by: Shannon Anahata --- docs/platforms/python/configuration/sampling__v3.x.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/platforms/python/configuration/sampling__v3.x.mdx b/docs/platforms/python/configuration/sampling__v3.x.mdx index 3719a34bae320..38eb9fa7fe878 100644 --- a/docs/platforms/python/configuration/sampling__v3.x.mdx +++ b/docs/platforms/python/configuration/sampling__v3.x.mdx @@ -4,11 +4,11 @@ description: "Learn how to configure the volume of error and transaction events sidebar_order: 60 --- -Adding Sentry to your app gives you a great deal of very valuable information about errors and performance you wouldn't otherwise get. And lots of information is good -- as long as it's the right information, at a reasonable volume. +Adding Sentry to your app gives you a great deal of valuable information about errors and performance you wouldn't otherwise get. And lots of information is good -- as long as it's the right information, at a reasonable volume. ## Sampling Error Events -To send a representative sample of your errors to Sentry, set the option in your SDK configuration to a number between `0` (0% of errors sent) and `1` (100% of errors sent). This is a static rate, which will apply equally to all errors. For example, to sample 25% of your errors: +To send a representative sample of your errors to Sentry, set the option in your SDK configuration to a number between `0.0` (0% of errors sent) and `1.0` (100% of errors sent). This is a static rate, which will apply equally to all errors. For example, to sample 25% of your errors: