feat(model): add usage_log_doc

This commit is contained in:
YuehuCao 2025-10-11 09:42:40 +08:00
parent 53381d22be
commit 5f18212343
2 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,7 @@ from .models import (
UserEmailDoc,
UserMobileDoc,
AuthCodeDoc,
UsageLogDoc,
)
user_models = [
@ -12,4 +13,5 @@ user_models = [
UserEmailDoc,
UserMobileDoc,
AuthCodeDoc,
UsageLogDoc,
]

View File

@ -57,3 +57,24 @@ class AuthCodeDoc(Document):
class Settings:
name = "user_auth_code"
class UsageLogDoc(Document):
timestamp: datetime = datetime.utcnow() # timestamp
tenant_id: str # tenant id
operation: str # operation type
request_id: str # request id # TODO: use true one
units: int # units
status: str # operation status
latency_ms: int # latency time(milliseconds)
bytes_in: int # input bytes
bytes_out: int # output bytes
key_id: Optional[str] = None # API Key ID
extra: dict = {} # extra information
class Settings:
name = "usage_log_doc"
indexes = [
"tenant_id",
"request_id",
"key_id"
]