Skip to content

Commit 881d8e9

Browse files
committed
feat(lilya): Add Lilya integration
Add first-class Lilya framework instrumentation for route transaction names, request data, handled HTTP exceptions, authenticated users, and middleware spans. Add end-to-end Lilya integration tests plus generated tox and CI matrix entries.
1 parent b9899f8 commit 881d8e9

15 files changed

Lines changed: 1690 additions & 0 deletions

File tree

.github/workflows/test-integrations-web-2.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ jobs:
5353
run: |
5454
set -x # print commands that are executed
5555
./scripts/runtox.sh "py${{ matrix.python-version }}-falcon"
56+
- name: Test lilya
57+
run: |
58+
set -x # print commands that are executed
59+
./scripts/runtox.sh "py${{ matrix.python-version }}-lilya"
5660
- name: Test litestar
5761
run: |
5862
set -x # print commands that are executed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The SDK now extracts all `gen_ai` spans out of a transaction and sends them as v
66

77
Self-hosted Sentry users should opt out with `stream_gen_ai_spans=False`, since streamed `gen_ai` spans may not be ingested by their Sentry instance.
88

9+
### Features
10+
11+
- Add first-class Lilya framework integration.
12+
913
### Bug Fixes 🐛
1014

1115
- (asyncpg) Use distinct span ops for cursor iteration and fetch to prevent N+1 false positives by @ericapisani in [#6609](https://github.com/getsentry/sentry-python/pull/6609)

docs/integrations.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Integrations
44

55
TBD
66

7+
Lilya
8+
=====
9+
10+
.. autoclass:: sentry_sdk.integrations.lilya.LilyaIntegration
11+
712
Logging
813
=======
914

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typing = [
7070
"mcp>=2.0.0b1",
7171
"starlette>=1.3.1",
7272
"python-multipart>=0.0.32",
73+
"lilya>=0.27.0",
7374
"pydantic>=2.13.4",
7475
]
7576
test = [
@@ -197,6 +198,10 @@ ignore_missing_imports = true
197198
module = "google.genai.*"
198199
ignore_missing_imports = true
199200

201+
[[tool.mypy.overrides]]
202+
module = "lilya.*"
203+
ignore_missing_imports = true
204+
200205
[[tool.mypy.overrides]]
201206
module = "executing.*"
202207
ignore_missing_imports = true

scripts/populate_tox/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@
276276
"package": "launchdarkly-server-sdk",
277277
"num_versions": 2,
278278
},
279+
"lilya": {
280+
"package": "lilya",
281+
"deps": {
282+
"*": [
283+
"httpx",
284+
"pytest-asyncio",
285+
"anyio>=3,<5",
286+
],
287+
},
288+
"python": ">=3.10",
289+
},
279290
"litellm": {
280291
"package": "litellm",
281292
"deps": {

scripts/split_tox_gh_actions/split_tox_gh_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
"asgi",
155155
"bottle",
156156
"falcon",
157+
"lilya",
157158
"litestar",
158159
"pyramid",
159160
"quart",

sentry_sdk/consts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,9 @@ class OP:
12221222
HTTP_CLIENT_STREAM = "http.client.stream"
12231223
HTTP_SERVER = "http.server"
12241224
MIDDLEWARE_DJANGO = "middleware.django"
1225+
MIDDLEWARE_LILYA = "middleware.lilya"
1226+
MIDDLEWARE_LILYA_RECEIVE = "middleware.lilya.receive"
1227+
MIDDLEWARE_LILYA_SEND = "middleware.lilya.send"
12251228
MIDDLEWARE_LITESTAR = "middleware.litestar"
12261229
MIDDLEWARE_LITESTAR_RECEIVE = "middleware.litestar.receive"
12271230
MIDDLEWARE_LITESTAR_SEND = "middleware.litestar.send"

sentry_sdk/integrations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def iter_default_integrations(
8989
"sentry_sdk.integrations.huggingface_hub.HuggingfaceHubIntegration",
9090
"sentry_sdk.integrations.langchain.LangchainIntegration",
9191
"sentry_sdk.integrations.langgraph.LanggraphIntegration",
92+
"sentry_sdk.integrations.lilya.LilyaIntegration",
9293
"sentry_sdk.integrations.litestar.LitestarIntegration",
9394
"sentry_sdk.integrations.loguru.LoguruIntegration",
9495
"sentry_sdk.integrations.mcp.MCPIntegration",
@@ -145,6 +146,7 @@ def iter_default_integrations(
145146
"langchain": (0, 1, 0),
146147
"langgraph": (0, 6, 6),
147148
"launchdarkly": (9, 8, 0),
149+
"lilya": (0, 27, 0),
148150
"litellm": (1, 77, 5),
149151
"loguru": (0, 7, 0),
150152
"mcp": (1, 15, 0),

sentry_sdk/integrations/asgi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ def _get_transaction_name_and_source(
474474
if path is not None:
475475
name = path
476476
else:
477+
route_path_template = asgi_scope.get("route_path_template")
478+
if route_path_template is not None:
479+
name = route_path_template
480+
if name is None:
477481
name = _get_url(
478482
asgi_scope,
479483
"http" if ty == "http" else "ws",
@@ -525,6 +529,10 @@ def _get_segment_name_and_source(
525529
if path is not None:
526530
name = path
527531
else:
532+
route_path_template = asgi_scope.get("route_path_template")
533+
if route_path_template is not None:
534+
name = route_path_template
535+
if name is None:
528536
name = _get_url(
529537
asgi_scope,
530538
"http" if ty == "http" else "ws",

0 commit comments

Comments
 (0)