From ea99719c344c007112a4abd020d051378a4c3302 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Thu, 12 Sep 2024 15:21:15 +0500 Subject: [PATCH] test --- .../comment_client/thread.py | 14 +------------ .../comment_client/user.py | 8 +------ .../comment_client/utils.py | 21 ++----------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/thread.py b/openedx/core/djangoapps/django_comment_common/comment_client/thread.py index 88efb81ec24..f3fe0facde6 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/thread.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/thread.py @@ -7,7 +7,7 @@ from . import models, settings, utils from forum import api as forum_api -from .utils import check_service_enabled, handle_metric_tags, handle_response +from .utils import check_service_enabled, handle_response log = logging.getLogger(__name__) @@ -198,12 +198,6 @@ def unFlagAbuse(self, user, voteable, removeAll): def pin(self, user, thread_id): check_service_enabled() response = forum_api.pin_thread(user.id, thread_id) - handle_metric_tags( - "put", - response["status_code"], - metric_action="thread.pin", - metric_tags=self._metric_tags, - ) response = handle_response( response, "put", @@ -215,12 +209,6 @@ def pin(self, user, thread_id): def un_pin(self, user, thread_id): check_service_enabled() response = forum_api.unpin_thread(user.id, thread_id) - handle_metric_tags( - "put", - response["status_code"], - metric_action="thread.unpin", - metric_tags=self._metric_tags, - ) response = handle_response( response, "put", diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/user.py b/openedx/core/djangoapps/django_comment_common/comment_client/user.py index 1a81b0afa76..d8a38730e53 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/user.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/user.py @@ -4,7 +4,7 @@ from . import models, settings, utils from forum import api as forum_api -from .utils import check_service_enabled, handle_metric_tags, handle_response +from .utils import check_service_enabled, handle_response class User(models.Model): @@ -152,12 +152,6 @@ def _retrieve(self, *args, **kwargs): try: check_service_enabled() response = forum_api.retrieve_user(self.attributes["id"], retrieve_params) - handle_metric_tags( - "get", - response["status_code"], - metric_action="model.retrieve", - metric_tags=self._metric_tags, - ) response = handle_response( response, "get", retrieve_params, metric_action="model.retrieve" ) diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/utils.py b/openedx/core/djangoapps/django_comment_common/comment_client/utils.py index 7c331a2b22e..5f4c28f3f97 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/utils.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/utils.py @@ -230,23 +230,6 @@ def check_service_enabled(): raise CommentClientMaintenanceError("service disabled") -def handle_metric_tags( - request_method, status_code, metric_action=None, metric_tags=None -): - if metric_tags is None: - metric_tags = [] - - metric_tags.append(f"method:{request_method}") - if metric_action: - metric_tags.append(f"action:{metric_action}") - - metric_tags.append(f"status_code:{status_code}") - if status_code > 200: - metric_tags.append("result:failure") - else: - metric_tags.append("result:success") - - def handle_response( response, request_method, @@ -273,8 +256,8 @@ def handle_response( data = response["data"] except ValueError: raise CommentClientError( # lint-amnesty, pylint: disable=raise-missing-from - "Invalid JSON response for request to forum v2 method named{forum_v2_method}; first 100 characters: '{content}'".format( - forum_v2_method=metric_action, content=response["text"][:100] + "Invalid JSON response for request to forum v2 method named{metric_action}; first 100 characters: '{content}'".format( + metric_action=metric_action, content=response["text"][:100] ) ) return data