fixed a bug where number of seconds was truncated from the api call duration
parent
7fd4e2d908
commit
5aec4bf654
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from http import HTTPStatus
|
||||
|
||||
from flask import current_app, Blueprint, g as global_context
|
||||
|
@ -66,12 +67,13 @@ def add_api_metric(http_status):
|
|||
else:
|
||||
device_id = None
|
||||
|
||||
duration = (datetime.utcnow() - global_context.start_ts)
|
||||
api_metric = ApiMetric(
|
||||
access_ts=datetime.utcnow(),
|
||||
account_id=account_id,
|
||||
api=api,
|
||||
device_id=device_id,
|
||||
duration=(datetime.utcnow() - global_context.start_ts).microseconds,
|
||||
duration=Decimal(duration.total_seconds()),
|
||||
http_status=int(http_status),
|
||||
url=global_context.url
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -7,7 +8,7 @@ class ApiMetric(object):
|
|||
url: str
|
||||
access_ts: datetime
|
||||
api: str
|
||||
duration: int
|
||||
duration: Decimal
|
||||
http_status: int
|
||||
id: str = None
|
||||
account_id: str = None
|
||||
|
|
Loading…
Reference in New Issue