Skip to content

Commit

Permalink
Update starlette to 0.35+
Browse files Browse the repository at this point in the history
  • Loading branch information
dolfinus committed Jan 15, 2024
1 parent e1c1938 commit 86804fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prometheus-client==0.15.0
starlette==0.27.0
starlette==0.35.1
requests==2.31.0
aiofiles==22.1.0
pytest==6.2.4
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
description="Prometheus metrics exporter for Starlette applications.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
install_requires=["prometheus_client>=0.12", "starlette"],
install_requires=["prometheus_client>=0.12", "starlette>=0.35"],
)
15 changes: 4 additions & 11 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest
from prometheus_client import REGISTRY
from starlette import __version__ as starlette_version
from starlette.applications import Starlette
from starlette.background import BackgroundTask
from starlette.exceptions import HTTPException
Expand Down Expand Up @@ -218,19 +217,19 @@ def test_custom_root_path(self, testapp):
metrics = client.get("/metrics").content.decode()

assert (
"""starlette_requests_total{app_name="starlette",method="GET",path="/api/200",status_code="200"} 1.0"""
"""starlette_requests_total{app_name="starlette",method="GET",path="/200",status_code="200"} 1.0"""
in metrics
)
assert (
"""starlette_requests_total{app_name="starlette",method="GET",path="/api/500",status_code="500"} 1.0"""
"""starlette_requests_total{app_name="starlette",method="GET",path="/500",status_code="500"} 1.0"""
in metrics
)
assert (
"""starlette_requests_total{app_name="starlette",method="GET",path="/api/404",status_code="404"} 1.0"""
"""starlette_requests_total{app_name="starlette",method="GET",path="/404",status_code="404"} 1.0"""
in metrics
)
assert (
"""starlette_requests_total{app_name="starlette",method="GET",path="/api/unhandled",status_code="500"} 1.0"""
"""starlette_requests_total{app_name="starlette",method="GET",path="/unhandled",status_code="500"} 1.0"""
in metrics
)

Expand Down Expand Up @@ -509,12 +508,6 @@ def test_custom_root_path(self, testapp):

metrics = client.get("/metrics").content.decode()

starlette_version_tuple = tuple(map(int, starlette_version.split(".")))
if starlette_version_tuple < (0, 33):
# These asserts are valid only on Starlette 0.33+
# See https://github.com/encode/starlette/pull/2352"
return

assert (
"""starlette_requests_total{app_name="starlette",method="GET",path="/200/{test_param}",status_code="200"} 1.0"""
in metrics
Expand Down

0 comments on commit 86804fb

Please sign in to comment.