Skip to content

Commit

Permalink
Added prometheus_fastapi_instrumentator
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-gladkii committed Feb 29, 2024
1 parent e037ce4 commit 3708332
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ Usage example:
act push -j deploy --secret-file my.secrets
```

## Prometheus metrics
The application includes prometheus-fastapi-instrumentator for monitoring performance and analyzing its operation. It automatically adds an endpoint `/metrics` where you can access application metrics for Prometheus. These metrics include information about request counts, request execution times, and other important indicators of application performance.
More on that at (Prometheus FastAPI Instrumentator)[https://github.com/trallnag/prometheus-fastapi-instrumentator]

## Classy-FastAPI
Classy-FastAPI allows you to easily do dependency injection of
object instances that should persist between FastAPI routes invocations,
Expand Down
4 changes: 4 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from prometheus_fastapi_instrumentator import Instrumentator

from . import example, items

Expand Down Expand Up @@ -32,5 +33,8 @@ def openapi(self) -> Dict[str, Any]:
app = CustomFastAPI()


Instrumentator().instrument(app).expose(app)


app.include_router(example.router)
app.include_router(items.routes.router)
31 changes: 30 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ python = "^3.10"
fastapi = "^0.109"
uvicorn = "^0.26"
classy-fastapi = "^0.6.1"
prometheus-fastapi-instrumentator = "^6.1.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.6"
Expand Down

0 comments on commit 3708332

Please sign in to comment.