### Conditional Dependencies Example (Celery) Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Shows how to install secondary dependencies based on specific Python versions, in addition to general dependencies. ```python "celery": { "deps": { "*": ["newrelic", "redis"], "py3.7": ["importlib-metadata<5.0"], }, ... } ``` -------------------------------- ### Conditional Dependencies Example (Flask) Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Illustrates how to specify conditional dependencies for a test suite, where certain packages are installed based on the version of the main package. ```python "flask": { "deps": { "*": ["Werkzeug"], "<3.0": ["Werkzeug<2.1.0"], }, ... } ``` -------------------------------- ### Example AI Commit Attribution Source: https://github.com/getsentry/sentry-python/blob/master/CLAUDE.md An example of how to format an AI commit attribution line using a specific agent model name. ```text Co-Authored-By: Claude Opus 4.6 ``` -------------------------------- ### Run Tox via uv Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Execute tox environments using the uv package manager. Tox and tox-uv are installed automatically into the .venv. ```bash uv run tox -e ``` -------------------------------- ### Install sentry-python in Editable Mode with uv Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Installs the sentry-python package in editable mode using uv. This allows local changes to the SDK code to be immediately effective without reinstallation. ```bash uv add --editable . ``` -------------------------------- ### Install Pre-commit Git Hooks Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Registers the git hooks for the pre-commit framework, which will automatically lint changes using ruff. This command is run after the dev dependencies are installed. ```bash uv run pre-commit install ``` -------------------------------- ### Get client using sentry_sdk.get_client() Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md Accessing the Sentry client via the hub is deprecated. This example shows the recommended way to get the current client using the top-level `sentry_sdk.get_client()` function. ```python import sentry_sdk client = sentry_sdk.get_client() ``` -------------------------------- ### Install Sentry SDK via pip Source: https://github.com/getsentry/sentry-python/blob/master/README.md Command to install or upgrade the Sentry SDK package in a Python environment. ```bash pip install --upgrade sentry-sdk ``` -------------------------------- ### Include Specific Package Versions for Testing Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Use the `include` key with a version specifier to define which versions of a package should be considered for testing. This example limits starlite tests to versions less than 2.x. ```python "starlite": { "include": "<2", ... } ``` -------------------------------- ### Pinning sentry-sdk Version Requirements Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Examples of how to specify version requirements for the sentry-sdk package in your project. This ensures compatibility and stability by locking to a specific major version or an exact version. ```text sentry-sdk>=2.0.0,<3.0.0 ``` ```text sentry-sdk==2.4.0 ``` -------------------------------- ### Install sentry-python in Editable Mode Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Installs the sentry-python package in editable mode using pip. This allows local changes to the SDK code to be immediately effective without reinstallation. ```bash pip install -e . ``` -------------------------------- ### Replace Hub.start_span with sentry_sdk.start_span Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md Direct usage of `Hub` and hub-based APIs is deprecated. This snippet shows how to replace `hub.start_span` with the top-level `sentry_sdk.start_span` for starting spans. ```python import sentry_sdk with sentry_sdk.start_span(...): # do something ``` -------------------------------- ### AI Commit Attribution Example Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Format for AI-generated commits, including the agent model name and a noreply email address. ```plaintext Co-Authored-By: ``` -------------------------------- ### Specify Minimum Python Version for a Package Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Use the `python` key with a version specifier to ensure a package's test suite only runs on compatible Python versions. This example restricts aiohttp tests to Python 3.7 and later. ```python "aiohttp": { "python": ">=3.7", ... } ``` -------------------------------- ### Exclude Specific Package Versions for Testing Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md The `include` key can also be used with `!=` specifiers to exclude specific versions from testing. This example excludes two alpha prereleases of starlite 2.0.0. ```python "starlite": { "include": "!=2.0.0a1,!=2.0.0a2", ... } ``` -------------------------------- ### Replace capture_event with capture_envelope Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md The `sentry_sdk.transport.Transport.capture_event` method is deprecated. This example shows the updated method `sentry_sdk.transport.Transport.capture_envelope` for capturing events. ```python import sentry_sdk # Assuming 'transport' is an instance of sentry_sdk.transport.Transport transport.capture_envelope(...) ``` -------------------------------- ### Replace Hub cloning with sentry_sdk.isolation_scope Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md Hub cloning functionality is deprecated. This example demonstrates replacing the deprecated `Hub(Hub.current)` with `sentry_sdk.isolation_scope` for managing isolated scopes. ```python import sentry_sdk with sentry_sdk.isolation_scope() as scope: # do something with the forked scope ``` -------------------------------- ### Pass Transport instance to sentry_sdk.init Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md Passing a function to the `transport` keyword argument in `sentry_sdk.init` is deprecated. This example shows how to pass a `sentry_sdk.transport.Transport` instance or subclass instead. ```python import sentry_sdk from sentry_sdk.transport import Transport class CustomTransport(Transport): # ... implementation ... pass sentry_sdk.init( ..., transport=CustomTransport(), ) ``` -------------------------------- ### Replace push_scope with new_scope or isolation_scope Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md The `push_scope` function is deprecated. This example shows how to use `sentry_sdk.new_scope` to fork the current scope or `sentry_sdk.isolation_scope` to fork the isolation scope. ```python import sentry_sdk with sentry_sdk.new_scope() as scope: # do something with `scope` ``` ```python import sentry_sdk with sentry_sdk.isolation_scope() as scope: # do something with `scope` ``` -------------------------------- ### Rename propagate_hub to propagate_scope Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md The `propagate_hub` parameter in `ThreadingIntegration()` has been deprecated and renamed to `propagate_scope`. This example implies the change in parameter name for thread-safe scope propagation. ```python from sentry_sdk.integrations.threading import ThreadingIntegration integration = ThreadingIntegration(propagate_scope=True) ``` -------------------------------- ### Use top-level profiler_mode and profiles_sample_rate Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md The `profiler_mode` and `profiles_sample_rate` options are deprecated within `_experiments`. This snippet demonstrates using them as top-level options in `sentry_sdk.init`. ```python import sentry_sdk sentry_sdk.init( ..., profiler_mode="thread", profiles_sample_rate=1.0, ) ``` -------------------------------- ### Debug Django App with LLDB and Editable Sentry SDK Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md This command is an update to the previous `lldb` debugging command. It includes an additional `--pythonpath` argument to specify the local directory of the sentry-python codebase, resolving 'module not found' errors when the SDK is installed in editable mode. ```bash lldb -- ../../uwsgi/uwsgi --pythonpath "$PWD/.venv/lib/python3.14/site-packages" \ --pythonpath "" \ --http :8000 \ --module mysite.wsgi:application \ --home "$PWD/.venv" \ --need-app \ ``` -------------------------------- ### Conditional Python Versioning Based on Package Version Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Employ a dictionary for the `python` key to define Python version requirements that depend on the package's own version. This example ensures httpx tests run on Python 3.9+ only if httpx version is 0.28 or higher. ```python "httpx": { "python": { # run the test suite for httpx v0.28+ on Python 3.9+ only ">=0.28": ">=3.9", }, } ``` -------------------------------- ### Modify scopes directly instead of configure_scope Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md The `configure_scope` function is deprecated. This snippet shows how to directly modify the current or isolation scope using `get_current_scope` or `get_isolation_scope`. ```python from sentry_sdk import get_current_scope scope = get_current_scope() # do something with `scope` ``` ```python from sentry_sdk import get_isolation_scope scope = get_isolation_scope() # do something with `scope` ``` -------------------------------- ### Migrate Transaction Name Update in Sentry SDK Source: https://github.com/getsentry/sentry-python/blob/master/MIGRATION_GUIDE.md Demonstrates how to update transaction names in Sentry SDK 2.x. Previously, `configure_scope` was used, but now `get_current_scope` should be used to mutate the transaction directly. This change simplifies the process of modifying transaction details. ```python transaction = sentry_sdk.transaction(...) # later in the code execution: with sentry_sdk.configure_scope() as scope: scope.set_transaction_name("new-transaction-name") ``` ```python transaction = sentry_sdk.transaction(...) # later in the code execution: scope = sentry_sdk.get_current_scope() scope.set_transaction_name("new-transaction-name") ``` -------------------------------- ### List All Tox Environments Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Use this command to see all available tox environments defined in the tox.ini file. This helps in understanding the testing matrix. ```bash uv run tox -l ``` -------------------------------- ### Run Linting and Formatting with ruff Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Uses uv to run ruff for checking and fixing code style in the tests and sentry_sdk directories. Also formats the code. ```bash uv run ruff check --fix tests sentry_sdk ``` ```bash uv run ruff format tests sentry_sdk ``` -------------------------------- ### Sync Development Dependencies with uv Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Synchronizes the project's virtual environment and development dependencies using uv. This command should be run after cloning the repository. ```bash cd sentry-python uv sync ``` -------------------------------- ### Lint and Format Code with Ruff Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Apply linting and formatting fixes to the tests and sentry_sdk directories using ruff. ```bash uv run ruff check --fix tests sentry_sdk ``` ```bash uv run ruff format tests sentry_sdk ``` -------------------------------- ### Initialize Sentry SDK Source: https://github.com/getsentry/sentry-python/blob/master/README.md Configures the Sentry SDK with a DSN and performance monitoring settings. This is the entry point for enabling error tracking and performance tracing in a Python application. ```python import sentry_sdk sentry_sdk.init( "https://12927b5f211046b575ee51fd8b1ac34f@o1.ingest.sentry.io/1", traces_sample_rate=1.0, ) ``` -------------------------------- ### Build uWSGI with Debug Symbols Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Use this command to build uWSGI with debug symbols, which is necessary for using `lldb` to debug C applications. ```bash CFLAGS="-g -O0" python uwsgiconfig.py --build ``` -------------------------------- ### Running populate_tox.py with uv Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Execute the populate_tox.py script using the uv package manager with a specific Python version and the toxgen dependency group. This command ensures the script runs within the correct environment. ```bash UV_PROJECT_ENVIRONMENT=toxgen.venv \ uv run --python 3.14t \ --group toxgen \ --with-editable . \ python scripts/populate_tox/populate_tox.py ``` -------------------------------- ### Run Common Tox Environment Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Use the 'common' environment to run tests against all supported libraries but skip those requiring uninstalled dependencies. This is useful for general testing. ```bash uv run tox -e py3.12-common ``` -------------------------------- ### Run Integration Tests with Tox Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Execute integration tests for specific Python versions and integration types using tox and uv. ```bash uv run tox -e py3.14-{integration}-v{version} ``` -------------------------------- ### Sentry SDK Profiling, Sessions, and Attachments Source: https://github.com/getsentry/sentry-python/blob/master/docs/apidocs.rst Documentation for advanced features like profiling, session management, and attaching custom data to events. ```APIDOC ## Sentry SDK Profiling, Sessions, and Attachments ### Description This section details features for performance profiling, session tracking, and managing attachments for Sentry events. ### Classes #### `sentry_sdk.profiler.transaction_profiler.Profile` **Description:** Represents a performance profile captured for a transaction. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.session.Session` **Description:** Manages the lifecycle and state of a user session for Sentry. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.attachments.Attachment` **Description:** Represents an attachment that can be added to a Sentry event, such as a log file or a screenshot. **Members:** (Details of members would be listed here if available in the source) ``` -------------------------------- ### Debug Django App with LLDB Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Run your Django application with `lldb` for debugging. Ensure paths are updated to match your environment. ```bash lldb -- ../../uwsgi/uwsgi --pythonpath "$PWD/.venv/lib/python3.14/site-packages" \ --http :8000 \ --module mysite.wsgi:application \ --home "$PWD/.venv" \ --need-app \ ``` -------------------------------- ### Run Common Tests with Tox Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Execute common tests for a specific Python version using tox and uv. ```bash uv run tox -e py3.14-common ``` -------------------------------- ### Format Code with Ruff Source: https://github.com/getsentry/sentry-python/blob/master/CLAUDE.md Use ruff to format the code in the tests and sentry_sdk directories. This ensures consistent code style across the project. ```bash uv run ruff format tests sentry_sdk ``` -------------------------------- ### Run Tests for a Specific File Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Specify a particular test file to run using the TESTPATH environment variable. This allows for focused testing on a single file. ```bash TESTPATH=tests/integrations/logging/test_logging.py uv run tox -e py3.12-common ``` -------------------------------- ### Run Specific Test File with Tox Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Specify a test file path to run specific tests within a tox environment using uv. ```bash TESTPATH=tests/integrations/logging/test_logging.py uv run tox -e py3.14-common ``` -------------------------------- ### Logging Integration API Source: https://github.com/getsentry/sentry-python/blob/master/docs/integrations.rst Documentation for the sentry_sdk.integrations.logging module components. ```APIDOC ## ignore_logger ### Description Function to ignore a specific logger, preventing it from sending events to Sentry. ## EventHandler ### Description Class responsible for handling logging events. ## BreadcrumbHandler ### Description Class responsible for capturing log records as breadcrumbs. ``` -------------------------------- ### Run Mypy Type Checking Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Perform static type checking on the sentry_sdk package using mypy. Ensure this passes with zero errors before committing. ```bash uv run --group typing mypy sentry_sdk ``` -------------------------------- ### Sentry SDK Core Classes Source: https://github.com/getsentry/sentry-python/blob/master/docs/apidocs.rst Documentation for the primary classes used in the sentry-python SDK for managing events, scopes, and client interactions. ```APIDOC ## Sentry SDK Core Classes ### Description This section details the core classes of the sentry-python SDK, including `Hub`, `Scope`, and various `Client` implementations. These classes are fundamental for capturing and managing errors, context, and client configurations. ### Classes #### `sentry_sdk.Hub` **Description:** Manages the current execution context, including scopes and clients. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.Scope` **Description:** Represents the context for an event, holding information like tags, extra data, user context, and breadcrumbs. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.Client` **Description:** The main interface for sending events to Sentry. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.client.BaseClient` **Description:** Abstract base class for Sentry clients. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.client.NonRecordingClient` **Description:** A client that does not record or send any events, useful for disabling Sentry. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.client._Client` **Description:** Internal client implementation. **Members:** (Details of members would be listed here if available in the source) ``` -------------------------------- ### Run Single Test with Tox Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Execute a single test case by name within a tox environment using uv and specifying the test path. ```bash TESTPATH=tests/path/to/test_file.py uv run tox -e py3.14-common -- -k "test_name" ``` -------------------------------- ### Sentry SDK Monitor Source: https://github.com/getsentry/sentry-python/blob/master/docs/apidocs.rst Documentation for the Monitor class, used for Sentry's check-in and uptime monitoring features. ```APIDOC ## Sentry SDK Monitor ### Description This section details the `Monitor` class, which is used for Sentry's uptime monitoring and check-in features. ### Classes #### `sentry_sdk.monitor.Monitor` **Description:** Provides functionality to create and manage Sentry monitors, including sending check-ins. **Members:** (Details of members would be listed here if available in the source) ``` -------------------------------- ### General Tox Test Execution Command Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md A general template for running tox tests, allowing specification of the test path, tox environment, and any pytest arguments. ```bash TESTPATH= uv run tox -e -- ``` -------------------------------- ### Sentry SDK Scrubber and Envelope Source: https://github.com/getsentry/sentry-python/blob/master/docs/apidocs.rst Documentation for data scrubbing and the envelope format used for packaging and sending events to Sentry. ```APIDOC ## Sentry SDK Scrubber and Envelope ### Description This section covers the data scrubbing capabilities and the envelope format used by the Sentry SDK. ### Classes #### `sentry_sdk.scrubber.EventScrubber` **Description:** Handles the scrubbing of sensitive data from events before they are sent to Sentry. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.envelope.Envelope` **Description:** Represents the Sentry envelope format, which is used to bundle one or more items (like events, attachments, or profiles) into a single payload. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.envelope.Item` **Description:** Represents an individual item within a Sentry envelope. **Members:** (Details of members would be listed here if available in the source) ``` -------------------------------- ### Sentry SDK Transport and Tracing Source: https://github.com/getsentry/sentry-python/blob/master/docs/apidocs.rst Documentation for Sentry's transport mechanisms and performance monitoring features, including HTTP transport, transactions, and spans. ```APIDOC ## Sentry SDK Transport and Tracing ### Description This section covers the transport layer for sending events to Sentry and the performance monitoring features, including transaction tracing. ### Classes #### `sentry_sdk.Transport` **Description:** Abstract base class for event transports. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.HttpTransport` **Description:** The default transport implementation that sends events over HTTP to the Sentry server. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.tracing.Transaction` **Description:** Represents a high-level operation or request that can be traced, such as a web request or a background job. **Members:** (Details of members would be listed here if available in the source) #### `sentry_sdk.tracing.Span` **Description:** Represents a segment of a `Transaction`, used to measure the duration of specific operations within a transaction. **Members:** (Details of members would be listed here if available in the source) ``` -------------------------------- ### Test Suite Configuration Structure Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Defines the structure for configuring integration test suites, including the main package, additional dependencies with conditional rules, and Python version specifications. ```python integration_name: { "package": name_of_main_package_on_pypi, "deps": { rule1: [package1, package2, ...], rule2: [package3, package4, ...], }, "python": python_version_specifier | dict[package_version_specifier, python_version_specifier], "include": package_version_specifier, "integration_name": integration_name, "num_versions": int, } ``` -------------------------------- ### Typecheck with mypy Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Executes mypy for type checking the sentry_sdk codebase within the development environment managed by uv. ```bash uv run --group typing mypy sentry_sdk ``` -------------------------------- ### Capture Events and Errors Source: https://github.com/getsentry/sentry-python/blob/master/README.md Demonstrates how to manually send messages to Sentry and how the SDK automatically captures unhandled exceptions. ```python import sentry_sdk sentry_sdk.init(...) sentry_sdk.capture_message("Hello Sentry!") raise ValueError("Oops, something went wrong!") ``` -------------------------------- ### Map Test Suite to Integration Name Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md Use the `integration_name` key when the test suite name differs from the actual integration name. This allows the script to access integration-specific configurations, such as the minimum supported version. ```python "openai-base": { "integration_name": "openai", ... } ``` -------------------------------- ### Control Number of Package Versions Tested Source: https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md The `num_versions` option allows specifying how many package versions to test, in addition to the oldest, latest, and recent prereleases. Setting it to `2` tests only the oldest and latest supported versions. ```python "package_name": { "num_versions": 2, ... } ``` -------------------------------- ### Run Specific Tox Environment for Celery Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Execute tests for a specific Python version (e.g., 3.12) and a particular library version (e.g., Celery v5.5.3). This ensures compatibility with targeted dependencies. ```bash uv run tox -e py3.12-celery-v5.5.3 ``` -------------------------------- ### Deploy Local Sentry Python Lambda Layer Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Deploys a local Sentry Python Lambda layer to your AWS account in the eu-central-1 region. Uses the AWS CLI to create and upload the layer named 'SentryPythonServerlessSDK-local-dev'. ```bash #!/bin/bash set -e # Default region REGION="eu-central-1" # Default layer name LAYER_NAME="SentryPythonServerlessSDK-local-dev" # Check if AWS CLI is installed if ! command -v aws &> /dev/null then echo "AWS CLI could not be found. Please install it and configure your credentials." exit 1 fi # Check if the layer already exists if aws lambda get-layer-version --layer-name "$LAYER_NAME" --region "$REGION" --output json &> /dev/null then echo "Layer '$LAYER_NAME' already exists in region '$REGION'." echo "To update it, please delete the existing layer first or use a different name." exit 1 fi # Package the code echo "Packaging code for Lambda layer..." rm -f sentry-python-serverless-sdk.zip zip -r sentry-python-serverless-sdk.zip . -x "*.git*" "*.venv*" "*.pytest_cache*" "*.mypy_cache*" "*.DS_Store" "*.zip" # Deploy the layer echo "Deploying Lambda layer '$LAYER_NAME' to region '$REGION'..." aws lambda publish-layer-version \ --layer-name "$LAYER_NAME" \ --description "Sentry Python Serverless SDK (local dev)" \ --zip-file "fileb://sentry-python-serverless-sdk.zip" \ --region "$REGION" # Clean up the zip file rm -f sentry-python-serverless-sdk.zip echo "Lambda layer '$LAYER_NAME' deployed successfully to region '$REGION'." ``` -------------------------------- ### Regenerate All Test Files Source: https://github.com/getsentry/sentry-python/blob/master/AGENTS.md Execute a shell script to regenerate all test-related files, including tox.ini and GitHub Actions workflow files. ```bash scripts/generate-test-files.sh ``` -------------------------------- ### Performance Monitoring API Source: https://github.com/getsentry/sentry-python/blob/master/docs/api.rst Functions for tracking performance, managing spans, and handling transactions. ```APIDOC ## start_transaction ### Description Starts a new transaction for performance monitoring. ## start_span ### Description Starts a new span within an existing transaction. ## get_current_span ### Description Retrieves the currently active span. ``` -------------------------------- ### Lint and Fix Code with Ruff Source: https://github.com/getsentry/sentry-python/blob/master/CLAUDE.md Use ruff to check for linting errors and automatically fix them in the tests and sentry_sdk directories. This command helps maintain code quality. ```bash uv run ruff check --fix tests sentry_sdk ``` -------------------------------- ### Select Specific Tests with Pytest Arguments Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Forward arguments to pytest to select specific tests within a tox environment. Use the '-k' flag to filter tests by name. ```bash uv run tox -e py3.12-celery-v5.5.3 -- -k test_transaction_events ``` -------------------------------- ### Scope Management API Source: https://github.com/getsentry/sentry-python/blob/master/docs/api.rst Advanced functions for managing the current scope, including tags, context, and user information. ```APIDOC ## set_tag ### Description Sets a tag on the current scope. ## set_user ### Description Sets user information on the current scope. ## configure_scope ### Description Allows modification of the current scope via a callback. ``` -------------------------------- ### Attach Local Sentry Python Lambda Layer to Function Source: https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md Attaches a previously deployed local Sentry Python Lambda layer to an existing AWS Lambda function. Requires the Lambda function name as an argument. ```bash #!/bin/bash set -e # Default region REGION="eu-central-1" # Default layer name LAYER_NAME="SentryPythonServerlessSDK-local-dev" # Check if AWS CLI is installed if ! command -v aws &> /dev/null then echo "AWS CLI could not be found. Please install it and configure your credentials." exit 1 fi # Check if a Lambda function name was provided if [ -z "$1" ] then echo "Usage: $0 " exit 1 fi LAMBDA_FUNCTION_NAME=$1 # Get the latest version of the layer LAYER_VERSION=$(aws lambda list-layer-versions --layer-name "$LAYER_NAME" --region "$REGION" --output json | jq '.LayerVersions[0].VersionNumber') if [ -z "$LAYER_VERSION" ] then echo "Layer '$LAYER_NAME' not found in region '$REGION'. Please deploy it first using aws-deploy-local-layer.sh." exit 1 fi # Get the current configuration of the Lambda function FUNCTION_CONFIG=$(aws lambda get-function-configuration --function-name "$LAMBDA_FUNCTION_NAME" --region "$REGION" --output json) # Get the current layers attached to the function CURRENT_LAYERS=$(echo "$FUNCTION_CONFIG" | jq -r '.Layers | map(.Arn) | .[]') # Construct the ARN for the layer version LAYER_ARN="arn:aws:lambda:$REGION:$(aws sts get-caller-identity --region "$REGION" --output json | jq -r '.Account')":layer:$LAYER_NAME:$LAYER_VERSION" # Check if the layer is already attached if echo "$CURRENT_LAYERS" | grep -q "$LAYER_ARN" then echo "Layer '$LAYER_NAME:$LAYER_VERSION' is already attached to function '$LAMBDA_FUNCTION_NAME'." exit 0 fi # Update the Lambda function configuration to attach the layer echo "Attaching layer '$LAYER_NAME:$LAYER_VERSION' to function '$LAMBDA_FUNCTION_NAME' in region '$REGION'..." aws lambda update-function-configuration \ --function-name "$LAMBDA_FUNCTION_NAME" \ --region "$REGION" \ --layers "$LAYER_ARN" \ $(echo "$FUNCTION_CONFIG" | jq -r '. | to_entries | map("\(.key)\=\(.value|tostring)") | .[] | select(. | startswith("Runtime=") or startswith("Handler=") or startswith("Role=") or startswith("Description=") or startswith("Timeout=") or startswith("MemorySize=") or startswith("VpcConfig=") or startswith("Environment=") or startswith("DeadLetterConfig=") or startswith("KMSKeyArn=") or startswith("TracingConfig=") or startswith("Layers=") or startswith("FileSystemConfigs=") or startswith("ImageConfig=") or startswith("CodeSigningConfigArn=") or startswith("EphemeralStorage=") or startswith("SnapStart=") or startswith("Architectures=") or startswith("PackageType=") or startswith("ImageUri=") or startswith("CodeUri=") or startswith("RuntimeVersionConfig=") or startswith("LoggingConfig=") | " --\(. | split("=")[0]) \(. | split("=")[1])') echo "Layer attached successfully." ``` -------------------------------- ### Capturing Data API Source: https://github.com/getsentry/sentry-python/blob/master/docs/api.rst Functions for reporting errors, messages, and custom events to Sentry. ```APIDOC ## capture_event ### Description Captures a manual event. ## capture_exception ### Description Captures an exception and sends it to Sentry. ## capture_message ### Description Captures a simple message string and sends it to Sentry. ``` -------------------------------- ### Fixing Circular Imports with Forward References Source: https://github.com/getsentry/sentry-python/wiki/Sphinx-circular-imports To resolve circular import errors during type checking, replace direct imports with forward references using the module path. This prevents the module from being partially initialized during the Sphinx autodoc process. ```python # Before: Direct import causing circularity from sentry_sdk.integrations import Integration def foo(integration): # type: (Integration) -> None pass # After: Using forward reference import sentry_sdk def foo(integration): # type: (sentry_sdk.integrations.Integration) -> None pass ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.