From 2a9ce209f1a60693b80d3d3815f59fa693fbc08e Mon Sep 17 00:00:00 2001 From: Bernard Szabo Date: Thu, 18 Aug 2022 14:23:51 -0400 Subject: [PATCH 1/3] feat: TNL-10051 blockstore API perf instrumentation Log before & after making blockstore (Django) API calls to get performance from timestamps --- openedx/core/lib/blockstore_api/methods.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openedx/core/lib/blockstore_api/methods.py b/openedx/core/lib/blockstore_api/methods.py index 7d7c65decd..76a5097df0 100644 --- a/openedx/core/lib/blockstore_api/methods.py +++ b/openedx/core/lib/blockstore_api/methods.py @@ -33,7 +33,9 @@ from blockstore.apps.api.exceptions import ( import blockstore.apps.api.methods as blockstore_api_methods from .config import use_blockstore_app +import logging +log = logging.getLogger(__name__) def toggle_blockstore_api(func): """ @@ -44,7 +46,11 @@ def toggle_blockstore_api(func): def wrapper(*args, **kwargs): if use_blockstore_app(): return getattr(blockstore_api_methods, func.__name__)(*args, **kwargs) - return func(*args, **kwargs) + joined_args = " " + log.Info('blockstore ' + func.__name__ + ' API call called with ' + joined_args.join(args) + ' arguments') + ret_object = func(*args, **kwargs) + log.Info('blockstore ' + func.__name__ + ' API call is done') + return ret_object return wrapper From e4d5de09da39eeae8714744668379be90ebc737f Mon Sep 17 00:00:00 2001 From: Bernard Szabo Date: Mon, 22 Aug 2022 12:55:50 -0400 Subject: [PATCH 2/3] feat: TNL-10051 fix whitespace violation Need two blank lines, not one --- openedx/core/lib/blockstore_api/methods.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openedx/core/lib/blockstore_api/methods.py b/openedx/core/lib/blockstore_api/methods.py index 76a5097df0..f48efd5830 100644 --- a/openedx/core/lib/blockstore_api/methods.py +++ b/openedx/core/lib/blockstore_api/methods.py @@ -37,6 +37,7 @@ import logging log = logging.getLogger(__name__) + def toggle_blockstore_api(func): """ Decorator function to toggle usage of the Blockstore service From d58607ea2d05c3b0fefe79b5894866d26fc15118 Mon Sep 17 00:00:00 2001 From: Bernard Szabo Date: Mon, 22 Aug 2022 13:19:53 -0400 Subject: [PATCH 3/3] feat: TNL-10051 reorder import statements import logging must come near top --- openedx/core/lib/blockstore_api/methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/lib/blockstore_api/methods.py b/openedx/core/lib/blockstore_api/methods.py index f48efd5830..1f930e5f32 100644 --- a/openedx/core/lib/blockstore_api/methods.py +++ b/openedx/core/lib/blockstore_api/methods.py @@ -3,6 +3,7 @@ API Client methods for working with Blockstore bundles and drafts """ import base64 +import logging from functools import wraps from urllib.parse import urlencode from uuid import UUID @@ -33,7 +34,6 @@ from blockstore.apps.api.exceptions import ( import blockstore.apps.api.methods as blockstore_api_methods from .config import use_blockstore_app -import logging log = logging.getLogger(__name__)