From 67a31ac5776ad9b2ce3d1a28965a7dce9722a2dc Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Fri, 4 Dec 2015 19:51:11 -0500 Subject: [PATCH] Add course/org info to New Relic in courseware and XBlock rendering. This will make it much easier for us to slice courseware requests by organization and course in Insights performance analysis. --- lms/djangoapps/courseware/module_render.py | 4 ++++ lms/djangoapps/courseware/views.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 24000b4b5b..3d3aaa6701 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -1024,6 +1024,10 @@ def _invoke_xblock_handler(request, course_id, usage_id, handler, suffix, course except InvalidKeyError: raise Http404 + # Gather metrics for New Relic so we can slice data in New Relic Insights + newrelic.agent.add_custom_parameter('course_id', unicode(course_key)) + newrelic.agent.add_custom_parameter('org', unicode(course_key.org)) + with modulestore().bulk_operations(course_key): instance, tracking_context = get_module_by_usage_id(request, course_id, usage_id, course=course) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 6c2ecf1ce3..5a4f43d9c3 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -29,6 +29,7 @@ from django.views.decorators.cache import cache_control from ipware.ip import get_ip from markupsafe import escape from rest_framework import status +import newrelic.agent from courseware import grades from courseware.access import has_access, _adjust_start_date_for_beta_testers @@ -318,6 +319,10 @@ def index(request, course_id, chapter=None, section=None, course_key = CourseKey.from_string(course_id) + # Gather metrics for New Relic so we can slice data in New Relic Insights + newrelic.agent.add_custom_parameter('course_id', unicode(course_key)) + newrelic.agent.add_custom_parameter('org', unicode(course_key.org)) + user = User.objects.prefetch_related("groups").get(id=request.user.id) redeemed_registration_codes = CourseRegistrationCode.objects.filter(