Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test-integrations-web-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-falcon"
- name: Test lilya
run: |
set -x # print commands that are executed
./scripts/runtox.sh "py${{ matrix.python-version }}-lilya"
- name: Test litestar
run: |
set -x # print commands that are executed
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The SDK now extracts all `gen_ai` spans out of a transaction and sends them as v

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.

### Features

- Add first-class Lilya framework integration.

### Bug Fixes 🐛

- (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)
Expand Down
5 changes: 5 additions & 0 deletions docs/integrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Integrations

TBD

Lilya
=====

.. autoclass:: sentry_sdk.integrations.lilya.LilyaIntegration

Logging
=======

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typing = [
"mcp>=2.0.0b1",
"starlette>=1.3.1",
"python-multipart>=0.0.32",
"lilya>=0.27.0",
"pydantic>=2.13.4",
]
test = [
Expand Down Expand Up @@ -197,6 +198,10 @@ ignore_missing_imports = true
module = "google.genai.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "lilya.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "executing.*"
ignore_missing_imports = true
Expand Down
11 changes: 11 additions & 0 deletions scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@
"package": "launchdarkly-server-sdk",
"num_versions": 2,
},
"lilya": {
"package": "lilya",
"deps": {
"*": [
"httpx",
"pytest-asyncio",
"anyio>=3,<5",
],
},
"python": ">=3.10",
},
"litellm": {
"package": "litellm",
"deps": {
Expand Down
1 change: 1 addition & 0 deletions scripts/split_tox_gh_actions/split_tox_gh_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"asgi",
"bottle",
"falcon",
"lilya",
"litestar",
"pyramid",
"quart",
Expand Down
3 changes: 3 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,9 @@ class OP:
HTTP_CLIENT_STREAM = "http.client.stream"
HTTP_SERVER = "http.server"
MIDDLEWARE_DJANGO = "middleware.django"
MIDDLEWARE_LILYA = "middleware.lilya"
MIDDLEWARE_LILYA_RECEIVE = "middleware.lilya.receive"
MIDDLEWARE_LILYA_SEND = "middleware.lilya.send"
MIDDLEWARE_LITESTAR = "middleware.litestar"
MIDDLEWARE_LITESTAR_RECEIVE = "middleware.litestar.receive"
MIDDLEWARE_LITESTAR_SEND = "middleware.litestar.send"
Expand Down
2 changes: 2 additions & 0 deletions sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def iter_default_integrations(
"sentry_sdk.integrations.huggingface_hub.HuggingfaceHubIntegration",
"sentry_sdk.integrations.langchain.LangchainIntegration",
"sentry_sdk.integrations.langgraph.LanggraphIntegration",
"sentry_sdk.integrations.lilya.LilyaIntegration",
"sentry_sdk.integrations.litestar.LitestarIntegration",
"sentry_sdk.integrations.loguru.LoguruIntegration",
"sentry_sdk.integrations.mcp.MCPIntegration",
Expand Down Expand Up @@ -145,6 +146,7 @@ def iter_default_integrations(
"langchain": (0, 1, 0),
"langgraph": (0, 6, 6),
"launchdarkly": (9, 8, 0),
"lilya": (0, 27, 0),
"litellm": (1, 77, 5),
"loguru": (0, 7, 0),
"mcp": (1, 15, 0),
Expand Down
74 changes: 42 additions & 32 deletions sentry_sdk/integrations/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,23 +466,28 @@ def _get_transaction_name_and_source(
source = TransactionSource.URL

elif transaction_style == "url":
# FastAPI includes the route object in the scope to let Sentry extract the
# path from it for the transaction name
route = asgi_scope.get("route")
if route:
path = getattr(route, "path", None)
if path is not None:
name = path
route_path_template = asgi_scope.get("route_path_template")
if route_path_template is not None:
name = route_path_template
else:
name = _get_url(
asgi_scope,
"http" if ty == "http" else "ws",
host=None,
path=_get_path(
asgi_scope=asgi_scope, root_path_in_path=self.root_path_in_path
),
)
source = TransactionSource.URL
# FastAPI includes the route object in the scope to let Sentry extract the
# path from it for the transaction name
route = asgi_scope.get("route")
if route:
path = getattr(route, "path", None)
if path is not None:
name = path
else:
name = _get_url(
asgi_scope,
"http" if ty == "http" else "ws",
host=None,
path=_get_path(
asgi_scope=asgi_scope,
root_path_in_path=self.root_path_in_path,
),
)
source = TransactionSource.URL

if name is None:
name = _DEFAULT_TRANSACTION_NAME
Expand Down Expand Up @@ -517,23 +522,28 @@ def _get_segment_name_and_source(
source = SegmentSource.URL.value

elif segment_style == "url":
# FastAPI includes the route object in the scope to let Sentry extract the
# path from it for the transaction name
route = asgi_scope.get("route")
if route:
path = getattr(route, "path", None)
if path is not None:
name = path
route_path_template = asgi_scope.get("route_path_template")
if route_path_template is not None:
name = route_path_template
else:
name = _get_url(
asgi_scope,
"http" if ty == "http" else "ws",
host=None,
path=_get_path(
asgi_scope=asgi_scope, root_path_in_path=self.root_path_in_path
),
)
source = SegmentSource.URL.value
# FastAPI includes the route object in the scope to let Sentry extract the
# path from it for the transaction name
route = asgi_scope.get("route")
if route:
path = getattr(route, "path", None)
if path is not None:
name = path
else:
name = _get_url(
asgi_scope,
"http" if ty == "http" else "ws",
host=None,
path=_get_path(
asgi_scope=asgi_scope,
root_path_in_path=self.root_path_in_path,
),
)
source = SegmentSource.URL.value

if name is None:
name = _DEFAULT_TRANSACTION_NAME
Expand Down
Loading