Skip to content

Commit 63bac7d

Browse files
Merge pull request #18 from basedosdados/chore/log-token-verification-elapsed-time
chore: log elapsed time for token verification requests
2 parents 096c468 + ed0d876 commit 63bac7d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

app/api/dependencies/auth.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
from typing import Annotated
23

34
import httpx
@@ -19,7 +20,7 @@ async def _verify_token(token: str) -> bool:
1920
}
2021
}
2122
"""
22-
23+
start = time.perf_counter()
2324
try:
2425
async with httpx.AsyncClient() as client:
2526
response = await client.post(
@@ -32,6 +33,9 @@ async def _verify_token(token: str) -> bool:
3233
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
3334
detail="Unable to verify user access",
3435
)
36+
finally:
37+
elapsed = time.perf_counter() - start
38+
logger.info(f"Token verification elapsed time: {elapsed:.4f}s")
3539

3640
payload = response.json()["data"]["verifyToken"]["payload"]
3741
return payload["has_chatbot_access"]

0 commit comments

Comments
 (0)