From 211b0f9c3c2362eff215dac58583c62672dfb65b Mon Sep 17 00:00:00 2001 From: Steven Murray <steven.murray@cern.ch> Date: Mon, 27 Feb 2023 17:48:31 +0100 Subject: [PATCH] FTS-1887 Log how long in takes to store an FTS job into the database --- src/fts3rest/fts3rest/controllers/jobs.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/fts3rest/fts3rest/controllers/jobs.py b/src/fts3rest/fts3rest/controllers/jobs.py index 0845c0da..a28c7615 100644 --- a/src/fts3rest/fts3rest/controllers/jobs.py +++ b/src/fts3rest/fts3rest/controllers/jobs.py @@ -22,6 +22,7 @@ from sqlalchemy.orm import noload import logging import functools +import time from fts3rest.model import Job, File, JobActiveStates, FileActiveStates from fts3rest.model import DataManagement, DataManagementActiveStates @@ -767,11 +768,23 @@ def submit(): # Insert the job try: try: + start_insert_job = time.perf_counter() Session.execute(Job.__table__.insert(), [populated.job]) + log.info( + "Inserted job into database: job_id={} db_secs={}".format( + populated.job_id, str(time.perf_counter() - start_insert_job) + ) + ) except IntegrityError: raise Conflict("The sid provided by the user is duplicated") if len(populated.files): + start_insert_files = time.perf_counter() Session.execute(File.__table__.insert(), populated.files) + log.info( + "Inserted files into database: job_id={} db_secs={}".format( + populated.job_id, str(time.perf_counter() - start_insert_files) + ) + ) if len(populated.datamanagement): Session.execute(DataManagement.__table__.insert(), populated.datamanagement) Session.flush() -- GitLab