From f1f34b5ddf8aa5c0a8b39c86eb702f9d65684ac9 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Fri, 8 May 2015 13:04:45 -0400 Subject: [PATCH] Customize the transaction name sent to New Relic for XBlock handlers. Currently, all XBlock/XModule handlers are lumped together in the same transaction (courseware.module_render:handle_xblock_callback). This makes it difficult to pinpoint problems with specific handlers. With this change, the transaction name will now look like: OpenAssessmentBlockWithMixins.save_submission CapaDescriptorWithMixins.xmodule_handler/problem_show --- lms/djangoapps/courseware/module_render.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index c25fe55dc9..74625f4dfe 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -26,6 +26,8 @@ from django.http import Http404, HttpResponse from django.test.client import RequestFactory from django.views.decorators.csrf import csrf_exempt +import newrelic.agent + from capa.xqueue_interface import XQueueInterface from courseware.access import has_access, get_user_role from courseware.masquerade import setup_masquerade @@ -889,6 +891,13 @@ def _invoke_xblock_handler(request, course_id, usage_id, handler, suffix): instance, tracking_context = get_module_by_usage_id(request, course_id, usage_id) + # Name the transaction so that we can view XBlock handlers separately in + # New Relic. The suffix is necessary for XModule handlers because the + # "handler" in those cases is always just "xmodule_handler". + nr_tx_name = "{}.{}".format(instance.__class__.__name__, handler) + nr_tx_name += "/{}".format(suffix) if suffix else "" + newrelic.agent.set_transaction_name(nr_tx_name, group="Python/XBlock/Handler") + tracking_context_name = 'module_callback_handler' req = django_to_webob_request(request) try: