Skip to content

Commit

Permalink
feat: add app version to metrics (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Sep 23, 2024
1 parent 2ca1786 commit b332d9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions projects/fal/src/fal/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,8 @@ class RouteSignature(NamedTuple):


class BaseServable:
version: ClassVar[str] = "unknown"

def collect_routes(self) -> dict[RouteSignature, Callable[..., Any]]:
raise NotImplementedError

Expand Down Expand Up @@ -1099,9 +1101,14 @@ def openapi(self) -> dict[str, Any]:
def serve(self) -> None:
import asyncio

from prometheus_client import Gauge
from starlette_exporter import handle_metrics
from uvicorn import Config

# NOTE: this uses the global prometheus registry
app_info = Gauge("fal_app_info", "Fal application information", ["version"])
app_info.labels(version=self.version).set(1)

app = self._build_app()
server = Server(
config=Config(app, host="0.0.0.0", port=8080, timeout_keep_alive=300)
Expand Down
1 change: 0 additions & 1 deletion projects/fal/src/fal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class App(fal.api.BaseServable):
}
app_name: ClassVar[str]
app_auth: ClassVar[Literal["private", "public", "shared"]] = "private"
version: ClassVar[str] = "unknown"
request_timeout: ClassVar[int | None] = None

def __init_subclass__(cls, **kwargs):
Expand Down

0 comments on commit b332d9a

Please sign in to comment.