This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Sentry SDK testing repository using Docker Compose for containerized development. The project is configured to test and develop with the Sentry Python SDK.
The repository uses Docker Compose with a Python 3.12 environment. The Sentry DSN is loaded from environment variables (.env file or system environment).
Create a .env file in the project root with:
SENTRY_DSN=your_sentry_dsn_here
docker compose up -d
docker compose exec sentry-test bashDependencies from requirements.txt are automatically installed when the container starts via the entrypoint script.
docker compose exec sentry-test python <script_name>.pyThe test_sentry.py script sends telemetry data (errors, traces, profiling, logs) to Sentry every second:
docker compose exec sentry-test python test_sentry.pyPress Ctrl+C to stop the script.
- Base Image: Python 3.12 (slim-bookworm)
- Working Directory:
/app - Volume Mount: Current directory mounted at
/app(enables live code editing) - User: Runs as UID 1000:1000 (non-root)
- Entrypoint: Automatically runs
pip install -r requirements.txton container start - Pip Configuration:
- Packages installed to
/app/.pip_packages - Cache stored in
/app/.pip_cache - Both directories are volume-mounted for persistence
- Packages installed to
PYTHONPATH=/app:/app/.pip_packages:$PYTHONPATHPIP_TARGET=/app/.pip_packagesPIP_CACHE_DIR=/app/.pip_cacheSENTRY_DSN- Loaded from.envfile (required for test script)
compose.yaml- Docker Compose service definitionDockerfile- Python 3.12 environment with debugging tools (ping, ps, netstat)entrypoint.sh- Entrypoint script that auto-installs dependenciesrequirements.txt- Python dependencies (sentry-sdk)test_sentry.py- Comprehensive test script that sends errors, traces, profiling data, and logs to Sentry
The repository includes a comprehensive test script that demonstrates all Sentry features:
- Errors: Sends various exception types (ZeroDivisionError, ValueError, IndexError, KeyError)
- Tracing: Creates transactions with multiple spans (database, HTTP, processing)
- Profiling: Profiles function execution using continuous profiling
- Logs: Sends logs at different levels (info, warning, error) using both Sentry logger and Python logging
The script sends one sample of each telemetry type every second.
Note: The script reads the Sentry DSN from the SENTRY_DSN environment variable. Ensure this is set in your .env file.
The Sentry SDK is configured with:
send_default_pii=True- Includes user data like headers and IPenable_logs=True- Forwards logs to Sentrytraces_sample_rate=1.0- Captures 100% of transactionsprofile_session_sample_rate=1.0- Profiles 100% of sessions