From 5f41569dcebe3cb1ca925d80b11eb9dd09658121 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 29 Apr 2026 07:44:23 -0400 Subject: [PATCH 1/2] feat: Add aiohttp test project Add a minimal aiohttp app wired up to the local sentry-python SDK with the AioHttpIntegration enabled. Includes routes for a successful response, an unhandled exception, and an HTTPInternalServerError to exercise error and trace capture. Also extend .gitignore to skip local Claude and Serena tooling files. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 3 +- test-aiohttp/main.py | 55 +++++++++++++++++++++++++++++++++++++ test-aiohttp/pyproject.toml | 13 +++++++++ test-aiohttp/run.sh | 12 ++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 test-aiohttp/main.py create mode 100644 test-aiohttp/pyproject.toml create mode 100755 test-aiohttp/run.sh diff --git a/.gitignore b/.gitignore index 4ce6f7c..19f3d57 100644 --- a/.gitignore +++ b/.gitignore @@ -166,4 +166,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ - +.claude/settings.local.json +.serena \ No newline at end of file diff --git a/test-aiohttp/main.py b/test-aiohttp/main.py new file mode 100644 index 0000000..9e6401a --- /dev/null +++ b/test-aiohttp/main.py @@ -0,0 +1,55 @@ +import os + +import sentry_sdk +from aiohttp import web +from sentry_sdk.integrations.aiohttp import AioHttpIntegration + + +sentry_sdk.init( + dsn="", + environment=os.environ.get("ENV", "test"), + _experiments={"trace_lifecycle": "stream"}, + traces_sample_rate=1.0, + profiles_sample_rate=1.0, + debug=True, + integrations=[ + AioHttpIntegration(), + ], +) + + +async def index(request): + return web.json_response( + { + "hello": "world!", + "error": "http://localhost:5000/error", + "http-error": "http://localhost:5000/http-error", + } + ) + + +async def error(request): + sentry_sdk.set_user({"id": "testuser"}) + raise ValueError("help! an error!") + + +async def http_error(request): + raise web.HTTPInternalServerError(reason="something went wrong") + + +@web.middleware +async def test_middleware(request, handler): + print("middleware") + return await handler(request) + + +def make_app(): + app = web.Application(middlewares=[test_middleware]) + app.router.add_get("/", index) + app.router.add_get("/error", error) + app.router.add_get("/http-error", http_error) + return app + + +if __name__ == "__main__": + web.run_app(make_app(), port=5000) diff --git a/test-aiohttp/pyproject.toml b/test-aiohttp/pyproject.toml new file mode 100644 index 0000000..eaae6ce --- /dev/null +++ b/test-aiohttp/pyproject.toml @@ -0,0 +1,13 @@ +[project] +name = "test-aiohttp" +version = "0" +requires-python = ">=3.12" + +dependencies = [ + "aiohttp>=3.9", + "ipdb>=0.13.13", + "sentry-sdk[aiohttp]", +] + +[tool.uv.sources] +sentry-sdk = { path = "../../sentry-python", editable = true } diff --git a/test-aiohttp/run.sh b/test-aiohttp/run.sh new file mode 100755 index 0000000..380bccb --- /dev/null +++ b/test-aiohttp/run.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# exit on first error +set -euo pipefail + +# Install uv if it's not installed +if ! command -v uv &> /dev/null; then + curl -LsSf https://astral.sh/uv/install.sh | sh +fi + +# Run the script +uv run python main.py From 44760e9807d64ab2db2e919bff00686e9d688577 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 29 Apr 2026 07:56:40 -0400 Subject: [PATCH 2/2] follow convention for DSN --- test-aiohttp/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-aiohttp/main.py b/test-aiohttp/main.py index 9e6401a..17a739a 100644 --- a/test-aiohttp/main.py +++ b/test-aiohttp/main.py @@ -6,7 +6,7 @@ sentry_sdk.init( - dsn="", + dsn=os.environ.get("SENTRY_DSN"), environment=os.environ.get("ENV", "test"), _experiments={"trace_lifecycle": "stream"}, traces_sample_rate=1.0,