Skip to content

Commit

Permalink
Add logs for time tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
xDaile committed Mar 27, 2023
1 parent 9988474 commit bdd4344
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion iib/workers/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from iib.exceptions import IIBError
from iib.workers.tasks.iib_static_types import UpdateRequestPayload
import time

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -133,14 +134,17 @@ def update_request(
:raises IIBError: if the request to the IIB API fails
"""
# Prevent a circular import
start_time = time.time()
from iib.workers.config import get_worker_config

config = get_worker_config()
request_url = f'{config.iib_api_url.rstrip("/")}/builds/{request_id}'
log.info('Patching the request %d with %r', request_id, payload)

try:
patch_start_time = time.time()
rv = requests_auth_session.patch(request_url, json=payload, timeout=config.iib_api_timeout)
log.info(f"Update_request patch duration: {time.time() - patch_start_time}")
except requests.RequestException:
msg = f'The connection failed when updating the request {request_id}'
log.exception(msg)
Expand All @@ -158,7 +162,7 @@ def update_request(
else:
_exc_msg = f'The worker failed to update the request {request_id}'
raise IIBError(_exc_msg)

log.info(f"Update_request duration: {time.time() - start_time}")
return rv.json()


Expand Down

0 comments on commit bdd4344

Please sign in to comment.