---
title: "Options"
description: "Learn more about how the SDK can be configured via options. These are being passed to the init function and therefore set when the SDK is first initialized."
url: https://docs.sentry.io/platforms/python/configuration/options/
---

# Options | Sentry for Python

Options are passed to the `init()` function as optional keyword arguments:

```python
import sentry_sdk

sentry_sdk.init(
    dsn="___PUBLIC_DSN___",
    max_breadcrumbs=50,
    debug=True,
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # Add request headers and IP for users,
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,

    # By default the SDK will try to use the SENTRY_RELEASE
    # environment variable, or infer a git commit
    # SHA as release, however you may want to set
    # something more human-readable.
    # release="myapp@1.0.0",
)
```

## [Available Options](https://docs.sentry.io/platforms/python/configuration/options.md#available-options)



## [Core Options](https://docs.sentry.io/platforms/python/configuration/options.md#core-options)

Options that can be read from an environment variable (`SENTRY_DSN`, `SENTRY_ENVIRONMENT`, `SENTRY_RELEASE`) are read automatically.

### [dsn](https://docs.sentry.io/platforms/python/configuration/options.md#dsn)

| Type         | `str`        |
| ------------ | ------------ |
| Default      | `None`       |
| ENV Variable | `SENTRY_DSN` |

The DSN tells the SDK where to send the events. If this option is not set, the SDK will just not send any data. The `dsn` config option takes precedence over the environment variable. Learn more about [DSN utilization](https://docs.sentry.io/product/sentry-basics/dsn-explainer.md#dsn-utilization).

### [debug](https://docs.sentry.io/platforms/python/configuration/options.md#debug)

| Type         | `bool`         |
| ------------ | -------------- |
| Default      | `False`        |
| ENV Variable | `SENTRY_DEBUG` |

Turns debug mode on or off. When `True`, the SDK will attempt to print out debugging information. This can be useful if something goes wrong with event sending. The default is always `False`. It's generally not recommended to turn it on in production because of the increase in log output.

The `debug` config option takes precedence over the environment variable.

### [release](https://docs.sentry.io/platforms/python/configuration/options.md#release)

| Type         | `str`            |
| ------------ | ---------------- |
| Default      | `None`           |
| ENV Variable | `SENTRY_RELEASE` |

Sets the release. If not set, the SDK will try to automatically configure a release out of the box but it's a better idea to manually set it to guarantee that the release is in sync with your deploy integrations. Release names are strings, but some formats are detected by Sentry and might be rendered differently. See [the releases documentation](https://docs.sentry.io/platforms/python/configuration/releases.md) to learn how the SDK tries to automatically configure a release.

The `release` config option takes precedence over the environment variable.

Learn more about how to send release data so Sentry can tell you about regressions between releases and identify the potential source in [the product documentation](https://docs.sentry.io/product/releases.md) or the [sandbox](https://sandbox.sentry.io/?scenario=releases\&projectSlug=python\&source=docs).

### [environment](https://docs.sentry.io/platforms/python/configuration/options.md#environment)

| Type         | `str`                |
| ------------ | -------------------- |
| Default      | `production`         |
| ENV Variable | `SENTRY_ENVIRONMENT` |

Sets the environment. This string is freeform and set to `production` by default. A release can be associated with more than one environment to separate them in the UI (think `staging` vs `production` or similar).

The `environment` config option takes precedence over the environment variable.

### [spotlight](https://docs.sentry.io/platforms/python/configuration/options.md#spotlight)

| Type         | `str \| bool`      |
| ------------ | ------------------ |
| Default      | `None`             |
| ENV Variable | `SENTRY_SPOTLIGHT` |

Enable [Sentry Spotlight](https://github.com/getsentry/spotlight). Specify the URL that Spotlight is running on. If set to the boolean `True` the default Spotlight URL `"http://localhost:8969/stream"` is used.

### [dist](https://docs.sentry.io/platforms/python/configuration/options.md#dist)

| Type    | `str`  |
| ------- | ------ |
| Default | `None` |

The distribution of the application. Distributions are used to disambiguate build or deployment variants of the same release of an application. The dist can be for example a build number.

### [sample\_rate](https://docs.sentry.io/platforms/python/configuration/options.md#sample_rate)

| Type    | `float` |
| ------- | ------- |
| Default | `1.0`   |

Configures the sample rate for error events, in the range of `0.0` to `1.0`. The default is `1.0`, which means that 100% of error events will be sent. If set to `0.1`, only 10% of error events will be sent. Events are picked randomly.

### [error\_sampler](https://docs.sentry.io/platforms/python/configuration/options.md#error_sampler)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

A function responsible for determining the percentage chance a given error event will be sent to Sentry. This configuration option accepts a function, which takes two parameters (the `event` and the `hint`), and which returns a boolean (indicating whether the event should be sent to Sentry), or returns a number between `0` (0% chance of being sent) and `1` (100% chance of being sent).

If this configuration option is specified, the `sample_rate` option is ignored.

### [ignore\_errors](https://docs.sentry.io/platforms/python/configuration/options.md#ignore_errors)

| Type    | `list` |
| ------- | ------ |
| Default | `[]`   |

A list of exception class names that shouldn't be sent to Sentry. Errors that are an instance of these exceptions or a subclass of them, will be filtered out before they're sent to Sentry.

By default, all errors are sent.

### [max\_breadcrumbs](https://docs.sentry.io/platforms/python/configuration/options.md#max_breadcrumbs)

| Type    | `int` |
| ------- | ----- |
| Default | `100` |

This variable controls the total amount of breadcrumbs that should be captured. This defaults to `100`, but you can set this to any number. However, you should be aware that Sentry has a [maximum payload size](https://develop.sentry.dev/sdk/data-model/envelopes/#size-limits) and any events exceeding that payload size will be dropped.

### [attach\_stacktrace](https://docs.sentry.io/platforms/python/configuration/options.md#attach_stacktrace)

| Type    | `bool`  |
| ------- | ------- |
| Default | `False` |

When enabled, stack traces are automatically attached to all messages logged. Stack traces are always attached to exceptions; however, when this option is set, stack traces are also sent with messages. This option, for instance, means that stack traces appear next to all log messages.

Grouping in Sentry is different for events with stack traces and without. As a result, you will get new groups as you enable or disable this flag for certain events.

### [send\_default\_pii](https://docs.sentry.io/platforms/python/configuration/options.md#send_default_pii)

| Type    | `bool` |
| ------- | ------ |
| Default | `None` |

If this flag is enabled, [certain personally identifiable information (PII)](https://docs.sentry.io/platforms/python/data-management/data-collected.md) is added by active integrations.

If you enable this option, be sure to manually remove what you don't want to send using our features for managing [*Sensitive Data*](https://docs.sentry.io/platforms/python/data-management/sensitive-data.md).

### [event\_scrubber](https://docs.sentry.io/platforms/python/configuration/options.md#event_scrubber)

| Type    | `sentry_sdk.scrubber.EventScrubber` |
| ------- | ----------------------------------- |
| Default | `None`                              |

Scrubs the event payload for sensitive information such as cookies, sessions, and passwords from a `denylist`. It can additionally be used to scrub from another `pii_denylist` if `send_default_pii` is disabled. See how to [configure the scrubber here](https://docs.sentry.io/platforms/python/data-management/sensitive-data.md#event-scrubber).

### [include\_source\_context](https://docs.sentry.io/platforms/python/configuration/options.md#include_source_context)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

When enabled, source context will be included in events sent to Sentry. This source context includes the five lines of code above and below the line of code where an error happened.

### [include\_local\_variables](https://docs.sentry.io/platforms/python/configuration/options.md#include_local_variables)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

When enabled, the SDK will capture a snapshot of local variables to send with the event to help with debugging.

### [add\_full\_stack](https://docs.sentry.io/platforms/python/configuration/options.md#add_full_stack)

| Type    | `bool`  |
| ------- | ------- |
| Default | `False` |

When capturing errors, Sentry stack traces typically only include frames that start the moment an error occurs. But if the `add_full_stack` option is enabled (set to `True`), all frames from the start of execution will be included in the stack trace sent to Sentry.

Note: Grouping of issues in Sentry is based on stack traces. If you change this value in an existing Sentry setup new groups for already known errors will be created.

### [max\_stack\_frames](https://docs.sentry.io/platforms/python/configuration/options.md#max_stack_frames)

| Type    | `int` |
| ------- | ----- |
| Default | `100` |

This option limits the number of stack frames that will be captured when `add_full_stack` is enabled.

### [server\_name](https://docs.sentry.io/platforms/python/configuration/options.md#server_name)

| Type    | `str`  |
| ------- | ------ |
| Default | `None` |

This option can be used to supply a server name. When provided, the name of the server is sent along and persisted in the event. For many integrations, the server name actually corresponds to the device hostname, even in situations where the machine is not actually a server.

### [project\_root](https://docs.sentry.io/platforms/python/configuration/options.md#project_root)

| Type    | `str`         |
| ------- | ------------- |
| Default | `os.getcwd()` |

The full path to the root directory of your application.

The `project_root` is used to mark frames in a stack trace either as being in your application or outside of the application.

### [in\_app\_include](https://docs.sentry.io/platforms/python/configuration/options.md#in_app_include)

| Type    | `list[str]` |
| ------- | ----------- |
| Default | `[]`        |

A list of string prefixes of module names that belong to the app. This option takes precedence over `in_app_exclude`.

Sentry differentiates stack frames that are directly related to your application ("in application") from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The application package is automatically marked as `inApp`. The difference is visible in [sentry.io](https://sentry.io), where only the "in application" frames are displayed by default.

### [in\_app\_exclude](https://docs.sentry.io/platforms/python/configuration/options.md#in_app_exclude)

| Type    | `list[str]` |
| ------- | ----------- |
| Default | `[]`        |

A list of string prefixes of module names that do not belong to the app, but rather to third-party packages. Modules considered not part of the app will be hidden from stack traces by default.

This option can be overridden using `in_app_include`.

### [max\_request\_body\_size](https://docs.sentry.io/platforms/python/configuration/options.md#max_request_body_size)

| Type    | `str`    |
| ------- | -------- |
| Default | `medium` |

This parameter controls whether integrations should capture HTTP request bodies. It can be set to one of the following values:

* `never`: Request bodies are never sent.
* `small`: Only small request bodies will be captured. The cutoff for small depends on the SDK (typically 4KB).
* `medium`: Medium and small requests will be captured (typically 10KB).
* `always`: The SDK will always capture the request body as long as Sentry can make sense of it.

Please note that the Sentry server [limits HTTP request body size](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/#variable-size). The server always enforces its size limit, regardless of how you configure this option.

### [max\_value\_length](https://docs.sentry.io/platforms/python/configuration/options.md#max_value_length)

| Type    | `int`     |
| ------- | --------- |
| Default | `100 000` |

The number of characters after which the values containing text in the event payload will be truncated.

In SDK versions prior to `2.34.0`, the default was `1024`.

### [ca\_certs](https://docs.sentry.io/platforms/python/configuration/options.md#ca_certs)

| Type    | `str`  |
| ------- | ------ |
| Default | `None` |

A path to an alternative CA bundle file in PEM-format.

### [send\_client\_reports](https://docs.sentry.io/platforms/python/configuration/options.md#send_client_reports)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

Set this boolean to `False` to disable sending of client reports. Client reports allow the client to send status reports about itself to Sentry, such as information about events that were dropped before being sent.

### [auto\_session\_tracking](https://docs.sentry.io/platforms/python/configuration/options.md#auto_session_tracking)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

Whether sessions should be automatically recorded and sent to Sentry.

## [Integration Configuration](https://docs.sentry.io/platforms/python/configuration/options.md#integration-configuration)

### [integrations](https://docs.sentry.io/platforms/python/configuration/options.md#integrations)

| Type    | `list[sentry_sdk.integrations.Integration]` |
| ------- | ------------------------------------------- |
| Default | `[]`                                        |

List of integrations to enable in addition to [auto-enabling integrations](https://docs.sentry.io/platforms/python/integrations.md). This setting can be used to override the default config options for a specific auto-enabling integration or to add an integration that is not auto-enabled.

### [disabled\_integrations](https://docs.sentry.io/platforms/python/configuration/options.md#disabled_integrations)

| Type    | `list[sentry_sdk.integrations.Integration]` |
| ------- | ------------------------------------------- |
| Default | `[]`                                        |

List of integrations that will be disabled. This setting can be used to explicitly turn off specific [auto-enabling](https://docs.sentry.io/platforms/python/integrations.md#available-integrations) or [default](https://docs.sentry.io/platforms/python/integrations/default-integrations.md) integrations.

### [auto\_enabling\_integrations](https://docs.sentry.io/platforms/python/configuration/options.md#auto_enabling_integrations)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

Configures whether [auto-enabling integrations](https://docs.sentry.io/platforms/python/integrations.md#available-integrations) should be enabled.

When set to `False`, no auto-enabling integrations will be enabled by default, even if the corresponding framework/library is detected.

### [default\_integrations](https://docs.sentry.io/platforms/python/configuration/options.md#default_integrations)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

Configures whether [default integrations](https://docs.sentry.io/platforms/python/integrations/default-integrations.md) should be enabled.

Setting `default_integrations` to `False` disables all default integrations **as well as all auto-enabling integrations**, unless they are specifically added in the `integrations` option, described above.

## [Hooks](https://docs.sentry.io/platforms/python/configuration/options.md#hooks)

These options can be used to hook the SDK in various ways to customize the reporting of events.

### [before\_send](https://docs.sentry.io/platforms/python/configuration/options.md#before_send)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

This function is called with the event payload, and can return a modified event object, or `None` to skip reporting the event. This can be used, for instance, for manual PII stripping before sending.

By the time `before_send` is executed, all scope data has already been applied to the event. Further modification of the scope won't have any effect.

### [before\_send\_transaction](https://docs.sentry.io/platforms/python/configuration/options.md#before_send_transaction)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

This function is called with a transaction event object, and can return a modified transaction event object, or `None` to skip reporting the event. One way this might be used is for manual PII stripping before sending.

### [before\_breadcrumb](https://docs.sentry.io/platforms/python/configuration/options.md#before_breadcrumb)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

This function is called with a breadcrumb object before the breadcrumb is added to the scope. When nothing is returned from the function, the breadcrumb is dropped. To pass the breadcrumb through, return the first argument, which contains the breadcrumb object. The callback typically gets a second argument (called a "hint") which contains the original object from which the breadcrumb was created to further customize what the breadcrumb should look like.

### [before\_send\_log](https://docs.sentry.io/platforms/python/configuration/options.md#before_send_log)

| Type    | `Optional[Callable[Log, Hint] -> Optional[Log]]` |
| ------- | ------------------------------------------------ |
| Default | `None`                                           |

A function that will be called for each log. It can be used to modify the log before it's sent to Sentry or to filter specific logs out altogether (if it returns `None`).

New in SDK version `2.35.0`. Prior to `2.35.0`, this option was experimental.

### [traces\_sampler](https://docs.sentry.io/platforms/python/configuration/options.md#traces_sampler)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. This configuration option accepts a function, which takes one parameter (the `sampling_context`). The given `sampling_context` contains information about the transaction and the context in which it's being created. The function 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.

## [Transport Options](https://docs.sentry.io/platforms/python/configuration/options.md#transport-options)

Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments.

### [transport](https://docs.sentry.io/platforms/python/configuration/options.md#transport)

| Type    | `sentry_sdk.transport.Transport` |
| ------- | -------------------------------- |
| Default | `None`                           |

Switches out the transport used to send events. It can, for instance, be used to capture events for unit-testing or to send it through some more complex setup that requires proxy authentication.

### [transport\_queue\_size](https://docs.sentry.io/platforms/python/configuration/options.md#transport_queue_size)

| Type    | `int` |
| ------- | ----- |
| Default | `100` |

### [http\_proxy](https://docs.sentry.io/platforms/python/configuration/options.md#http_proxy)

| Type    | `Optional[str]` |
| ------- | --------------- |
| Default | `None`          |

When set, a proxy can be configured for outbound requests. This is also used for HTTPS requests, unless a separate `https_proxy` is configured.

If not set or set to `None`, the SDK will attempt to default to the system-wide configured proxy, if possible. For instance, on Unix systems, the `http_proxy` environment variable will be picked up.

If the SDK shouldn't use a proxy, set the option to `""`.

### [https\_proxy](https://docs.sentry.io/platforms/python/configuration/options.md#https_proxy)

| Type    | `Optional[str]` |
| ------- | --------------- |
| Default | `None`          |

Configures a separate proxy for outgoing HTTPS requests.

If not set (or set to `None`), the SDK will attempt to default to the system-wide configured proxy.

If no proxy should be used, set the option to `""`.

### [proxy\_headers](https://docs.sentry.io/platforms/python/configuration/options.md#proxy_headers)

| Type    | `dict[str, str]` |
| ------- | ---------------- |
| Default | `None`           |

A dict containing additional proxy headers (usually for authentication) to be forwarded to `urllib3`'s [`ProxyManager`](https://urllib3.readthedocs.io/en/1.24.3/reference/index.html#urllib3.poolmanager.ProxyManager).

### [shutdown\_timeout](https://docs.sentry.io/platforms/python/configuration/options.md#shutdown_timeout)

| Type    | `int` |
| ------- | ----- |
| Default | `2`   |

Controls how many seconds to wait before shutting down. The SDK sends events from a background queue. This queue is given a certain amount to drain pending events. Setting this value too low may cause problems for sending events from command line applications. Setting the value too high will cause the application to block for a long time for users experiencing network connectivity problems.

### [keep\_alive](https://docs.sentry.io/platforms/python/configuration/options.md#keep_alive)

| Type    | `bool`  |
| ------- | ------- |
| Default | `False` |

Determines whether to keep the connection alive between requests. This can be useful in environments where you encounter frequent network issues such as connection resets.

### [cert\_file](https://docs.sentry.io/platforms/python/configuration/options.md#cert_file)

| Type         | `str`              |
| ------------ | ------------------ |
| Default      | `None`             |
| ENV Variable | `CLIENT_CERT_FILE` |

Path to the client certificate to use. If set, supersedes the `CLIENT_CERT_FILE` environment variable.

### [key\_file](https://docs.sentry.io/platforms/python/configuration/options.md#key_file)

| Type         | `str`             |
| ------------ | ----------------- |
| Default      | `None`            |
| ENV Variable | `CLIENT_KEY_FILE` |

Path to the key file to use. If set, supersedes the `CLIENT_KEY_FILE` environment variable.

### [socket\_options](https://docs.sentry.io/platforms/python/configuration/options.md#socket_options)

| Default | `None` |
| ------- | ------ |

An optional list of socket options to use. These provide fine-grained, low-level control over the way the SDK connects to Sentry. If provided, the options will override the default `urllib3` [socket options](https://urllib3.readthedocs.io/en/stable/reference/urllib3.connection.html#urllib3.connection.HTTPConnection).

```python
import socket
from urllib3.connection import HTTPConnection

sentry_sdk.init(
    socket_options=HTTPConnection.default_socket_options + [
        (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
    ],
)
```

## [Tracing Options](https://docs.sentry.io/platforms/python/configuration/options.md#tracing-options)

### [traces\_sample\_rate](https://docs.sentry.io/platforms/python/configuration/options.md#traces_sample_rate)

| Type    | `float` |
| ------- | ------- |
| Default | `None`  |

A number between `0` and `1`, controlling the percentage chance a given transaction will be sent to Sentry. (`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app. Either this or `traces_sampler` must be defined to enable tracing.

If `traces_sample_rate` is `0`, this means that no new traces will be created. However, if you have another service (for example a JS frontend) that makes requests to your service that include trace information, those traces will be continued and thus transactions will be sent to Sentry.

If you want to disable all tracing you need to set `traces_sample_rate=None`. In this case, no new traces will be started and no incoming traces will be continued.

### [traces\_sampler](https://docs.sentry.io/platforms/python/configuration/options.md#traces_sampler)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. This configuration option accepts a function, which takes one parameter (the `sampling_context`). The given `sampling_context` contains information about the transaction and the context in which it's being created. The function 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.

### [trace\_propagation\_targets](https://docs.sentry.io/platforms/python/configuration/options.md#trace_propagation_targets)

| Type    | `list`   |
| ------- | -------- |
| Default | `['.*']` |

An optional property that controls which downstream services receive tracing data, in the form of a `sentry-trace` and a `baggage` header attached to any outgoing HTTP requests.

The option may contain a list of strings or regex against which the URLs of outgoing requests are matched. If one of the entries in the list matches the URL of an outgoing request, trace data will be attached to that request. String entries do not have to be full matches, meaning the URL of a request is matched when it *contains* a string provided through the option.

If `trace_propagation_targets` is not provided, trace data is attached to every outgoing request from the instrumented client.

### [strict\_trace\_continuation](https://docs.sentry.io/platforms/python/configuration/options.md#strict_trace_continuation)

| Type    | `boolean` |
| ------- | --------- |
| Default | `False`   |

If set to `True`, the SDK will only continue a trace if the `org_id` of the incoming trace found in the `baggage` header matches the `org_id` of the current Sentry client and only if BOTH are present.

If set to `False`, consistency of `org_id` will only be enforced if both are present. If either are missing, the trace will be continued.

The client's organization ID is extracted from the DSN or can be set with the `org_id` option. If the organization IDs do not match, the SDK will start a new trace instead of continuing the incoming one. This is useful to prevent traces of unknown third-party services from being continued in your application.

### [org\_id](https://docs.sentry.io/platforms/python/configuration/options.md#org_id)

| Type | `str` |
| ---- | ----- |

An optional organization ID for your Sentry project.

The SDK will try to extract the organization ID from the DSN. If it cannot be found, or if you need to override it (if you use Relay or self-hosted), you can provide the ID with this option.

The organization ID is used for features like [strict trace continuation](https://docs.sentry.io/platforms/python/configuration/options.md#strict_trace_continuation).

### [functions\_to\_trace](https://docs.sentry.io/platforms/python/configuration/options.md#functions_to_trace)

| Type    | `list[str]` |
| ------- | ----------- |
| Default | `[]`        |

An optional list of functions that should be set up for tracing. For each function in the list, a span will be created when the function is executed. Functions in the list are represented as strings containing the fully qualified name of the function.

This is a convenient option, making it possible to have one central place for configuring what functions to trace, instead of having custom instrumentation scattered all over your code base.

To learn more, see the [Custom Instrumentation](https://docs.sentry.io/platforms/python/tracing/instrumentation/custom-instrumentation.md#define-span-creation-in-a-central-place) documentation.

### [enable\_backpressure\_handling](https://docs.sentry.io/platforms/python/configuration/options.md#enable_backpressure_handling)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

When enabled, a new monitor thread will be spawned to perform health checks on the SDK. If the system is unhealthy, the SDK will keep halving the `traces_sample_rate` set by you in 10 second intervals until recovery. This down sampling helps ensure that the system stays stable and reduces SDK overhead under high load.

This option is enabled by default.

### [enable\_db\_query\_source](https://docs.sentry.io/platforms/python/configuration/options.md#enable_db_query_source)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

When enabled, the source location will be added to database queries.

### [db\_query\_source\_threshold\_ms](https://docs.sentry.io/platforms/python/configuration/options.md#db_query_source_threshold_ms)

| Type    | `int` |
| ------- | ----- |
| Default | `100` |

The threshold in milliseconds for adding the source location to database queries. The query location will be added to the query for queries slower than the specified threshold.

### [enable\_http\_request\_source](https://docs.sentry.io/platforms/python/configuration/options.md#enable_http_request_source)

| Type    | `bool` |
| ------- | ------ |
| Default | `True` |

When enabled, the source location will be added to outgoing HTTP requests.

### [http\_request\_source\_threshold\_ms](https://docs.sentry.io/platforms/python/configuration/options.md#http_request_source_threshold_ms)

| Type    | `int` |
| ------- | ----- |
| Default | `100` |

The threshold in milliseconds for adding the source location to an outgoing HTTP request. The request location will be added to the request for requests slower than the specified threshold.

### [trace\_ignore\_status\_codes](https://docs.sentry.io/platforms/python/configuration/options.md#trace_ignore_status_codes)

| Type    | `bool`        |
| ------- | ------------- |
| Default | `frozenset()` |

An optional property that disables tracing for HTTP requests with certain status codes.

Requests are not traced if the status code is contained in the provided set.

If `trace_ignore_status_codes` is not provided, requests with any status code may be traced.

### [custom\_repr](https://docs.sentry.io/platforms/python/configuration/options.md#custom_repr)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

A custom [repr](https://docs.python.org/3/library/functions.html#repr) function to run while serializing an object. Use this to control how your custom objects and classes are visible in Sentry.

Return a string for that repr value to be used or `None` to continue serializing how Sentry would have done it anyway.

```python
def custom_repr(obj):
    if isinstance(obj, MyCustomClass):
        return "<MyCustomClass>"
    else
        return None

sentry_sdk.init(custom_repr=custom_repr)
```

## [Profiling Options](https://docs.sentry.io/platforms/python/configuration/options.md#profiling-options)

### [profile\_lifecycle](https://docs.sentry.io/platforms/python/configuration/options.md#profile_lifecycle)

| Type    | `str`    |
| ------- | -------- |
| Default | `manual` |

Determines how the profiler will run, accepts two values: `manual` or `trace`.

In `manual` mode, you control when the profiler collects data by explicitly calling `sentry_sdk.profiler.start_profiler` and `sentry_sdk.profiler.stop_profiler`. You are entirely in control of when the profiler runs.

In `trace` mode, the profiler starts and stops automatically based on active spans: the profiler continues to run while there is at least one active span, and stops when there are no active spans.

### [profiler\_mode](https://docs.sentry.io/platforms/python/configuration/options.md#profiler_mode)

| Type    | `str`  |
| ------- | ------ |
| Default | `None` |

Determines which scheduler the profiler uses to record profiles. Can be `"thread"`, `"gevent"`, `"unknown"`, or `"sleep"` (deprecated, only for backwards compatibility). If not set, the SDK will determine the best scheduler to use. Only change this option if you know what you are doing.

### [profiles\_sample\_rate](https://docs.sentry.io/platforms/python/configuration/options.md#profiles_sample_rate)

| Type    | `float` |
| ------- | ------- |
| Default | `None`  |

A number between `0` and `1`, controlling the percentage chance a given profile will be sent to Sentry. (`0` represents 0% while `1` represents 100%.) Applies equally to all profiles created in the app. The `profiles_sample_rate` setting is relative to the `traces_sample_rate` setting.

Either this or `profiles_sampler` must be defined to enable profiling.

### [profiles\_sampler](https://docs.sentry.io/platforms/python/configuration/options.md#profiles_sampler)

| Type    | `function` |
| ------- | ---------- |
| Default | `None`     |

A function responsible for determining the percentage chance a recorded profile will be sent to Sentry. The function takes one parameter (the `sampling_context`). The given `sampling_context` contains information about the transaction linked to the profile and the context in which it's being created. The function must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering profiles, by returning `0` for those that are unwanted.

Either this or `profiles_sample_rate` must be defined to enable profiling. Additionally, tracing must be enabled for profiling to work.

### [profile\_session\_sample\_rate](https://docs.sentry.io/platforms/python/configuration/options.md#profile_session_sample_rate)

| Type    | `float` |
| ------- | ------- |
| Default | `None`  |

A number between `0` and `1`, controlling the percentage chance a given session will be profiled. The sampling decision is evaluated only once at SDK initialization.

## [Logs Options](https://docs.sentry.io/platforms/python/configuration/options.md#logs-options)

### [enable\_logs](https://docs.sentry.io/platforms/python/configuration/options.md#enable_logs)

| Type    | `bool`  |
| ------- | ------- |
| Default | `False` |

Enables Sentry structured logs, allowing you to use the `sentry_sdk.logger` APIs to send logs to Sentry. This option must be set to `True` to automatically capture logs from Python’s built-in logging module or other supported logging integrations.

New in SDK version `2.35.0`. Prior to `2.35.0`, this option was experimental.
