Skip to content

Commit 5f41569

Browse files
ericapisaniclaude
andcommitted
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) <noreply@anthropic.com>
1 parent d1aa600 commit 5f41569

4 files changed

Lines changed: 82 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,5 @@ cython_debug/
166166
# and can be added to the global gitignore or merged into this file. For a more nuclear
167167
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168168
#.idea/
169-
169+
.claude/settings.local.json
170+
.serena

test-aiohttp/main.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import os
2+
3+
import sentry_sdk
4+
from aiohttp import web
5+
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
6+
7+
8+
sentry_sdk.init(
9+
dsn="",
10+
environment=os.environ.get("ENV", "test"),
11+
_experiments={"trace_lifecycle": "stream"},
12+
traces_sample_rate=1.0,
13+
profiles_sample_rate=1.0,
14+
debug=True,
15+
integrations=[
16+
AioHttpIntegration(),
17+
],
18+
)
19+
20+
21+
async def index(request):
22+
return web.json_response(
23+
{
24+
"hello": "world!",
25+
"error": "http://localhost:5000/error",
26+
"http-error": "http://localhost:5000/http-error",
27+
}
28+
)
29+
30+
31+
async def error(request):
32+
sentry_sdk.set_user({"id": "testuser"})
33+
raise ValueError("help! an error!")
34+
35+
36+
async def http_error(request):
37+
raise web.HTTPInternalServerError(reason="something went wrong")
38+
39+
40+
@web.middleware
41+
async def test_middleware(request, handler):
42+
print("middleware")
43+
return await handler(request)
44+
45+
46+
def make_app():
47+
app = web.Application(middlewares=[test_middleware])
48+
app.router.add_get("/", index)
49+
app.router.add_get("/error", error)
50+
app.router.add_get("/http-error", http_error)
51+
return app
52+
53+
54+
if __name__ == "__main__":
55+
web.run_app(make_app(), port=5000)

test-aiohttp/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[project]
2+
name = "test-aiohttp"
3+
version = "0"
4+
requires-python = ">=3.12"
5+
6+
dependencies = [
7+
"aiohttp>=3.9",
8+
"ipdb>=0.13.13",
9+
"sentry-sdk[aiohttp]",
10+
]
11+
12+
[tool.uv.sources]
13+
sentry-sdk = { path = "../../sentry-python", editable = true }

test-aiohttp/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
# exit on first error
4+
set -euo pipefail
5+
6+
# Install uv if it's not installed
7+
if ! command -v uv &> /dev/null; then
8+
curl -LsSf https://astral.sh/uv/install.sh | sh
9+
fi
10+
11+
# Run the script
12+
uv run python main.py

0 commit comments

Comments
 (0)