Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Relax type of get_route_name argument to HttpConnection #276

Merged
merged 4 commits into from
Mar 10, 2024
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0).

## Unreleased

### Added

- Relaxed type of `get_route_name` argument to `HTTPConnection`. This allows
developers to use the `get_route_name` function for getting the name of
websocket routes as well. Thanks to [@pajowu](https://github.com/pajowu) for
proposing and implementing this feature in
[#276](https://github.com/trallnag/prometheus-fastapi-instrumentator/pull/276).

### Removed

- **BREAKING:** Dropped support for Python 3.7 which is has reached end-of-life.
Expand Down
4 changes: 2 additions & 2 deletions src/prometheus_fastapi_instrumentator/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

from typing import List, Optional

from starlette.requests import Request
from starlette.requests import HTTPConnection
from starlette.routing import Match, Mount, Route
from starlette.types import Scope

Expand All @@ -66,7 +66,7 @@ def _get_route_name(
return None


def get_route_name(request: Request) -> Optional[str]:
def get_route_name(request: HTTPConnection) -> Optional[str]:
"""Gets route name for given request taking mounts into account."""

app = request.app
Expand Down
Loading