Skip to content

Commit b43fef0

Browse files
committed
feat: add prometheus metrics to /metrics
1 parent d42a6cf commit b43fef0

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.0.82
2+
3+
* Expose Prometheus metrics at /metrics
4+
15
## 0.0.81
26

37
* Update `strategy` parameter to allow `'` and `"` as input surrounding the value.

prepline_general/api/app.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from fastapi.datastructures import FormData
33
from fastapi.responses import JSONResponse
44
from fastapi.security import APIKeyHeader
5+
from prometheus_client import make_asgi_app
56
import logging
67
import os
78

@@ -13,7 +14,7 @@
1314
app = FastAPI(
1415
title="Unstructured Pipeline API",
1516
summary="Partition documents with the Unstructured library",
16-
version="0.0.81",
17+
version="0.0.82",
1718
docs_url="/general/docs",
1819
openapi_url="/general/openapi.json",
1920
servers=[
@@ -31,6 +32,9 @@
3132
openapi_tags=[{"name": "general"}],
3233
)
3334

35+
metrics_app = make_asgi_app()
36+
app.mount("/metrics", metrics_app)
37+
3438
# Note(austin) - This logger just dumps exceptions
3539
# We'd rather handle those below, so disable this in deployments
3640
uvicorn_logger = logging.getLogger("uvicorn.error")

prepline_general/api/general.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def return_content_type(filename: str):
653653

654654

655655
@router.get("/general/v0/general", include_in_schema=False)
656-
@router.get("/general/v0.0.81/general", include_in_schema=False)
656+
@router.get("/general/v0.0.82/general", include_in_schema=False)
657657
async def handle_invalid_get_request():
658658
raise HTTPException(
659659
status_code=status.HTTP_405_METHOD_NOT_ALLOWED, detail="Only POST requests are supported."
@@ -668,7 +668,7 @@ async def handle_invalid_get_request():
668668
description="Description",
669669
operation_id="partition_parameters",
670670
)
671-
@router.post("/general/v0.0.81/general", include_in_schema=False)
671+
@router.post("/general/v0.0.82/general", include_in_schema=False)
672672
def general_partition(
673673
request: Request,
674674
# cannot use annotated type here because of a bug described here:

preprocessing-pipeline-family.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name: general
2-
version: 0.0.81
2+
version: 0.0.82

requirements/base.in

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ backoff
1616
pypdf
1717
pycryptodome
1818
psutil
19+
prometheus_client

requirements/base.txt

+2
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ pillow==10.4.0
244244
# unstructured-pytesseract
245245
portalocker==2.10.1
246246
# via iopath
247+
prometheus-client==0.21.0
248+
# via -r requirements/base.in
247249
proto-plus==1.24.0
248250
# via
249251
# google-api-core

0 commit comments

Comments
 (0)