Skip to content

Commit

Permalink
Merge pull request #563 from edx/iahmad/ENT-1952-Monitoring-for-Enrol…
Browse files Browse the repository at this point in the history
…lment-Workflow

ENT-1952 Updated logs for splunk monitoring
  • Loading branch information
irfanuddinahmad authored Sep 4, 2019
2 parents d048550 + c9b0b77 commit af6ffca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Change Log
Unreleased
----------

[1.9.10] - 2019-09-04
---------------------

* Improved enterprise enrollment workflow logging.

[1.9.9] - 2019-08-29
--------------------

Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

from __future__ import absolute_import, unicode_literals

__version__ = "1.9.9"
__version__ = "1.9.10"

default_app_config = "enterprise.apps.EnterpriseConfig" # pylint: disable=invalid-name
82 changes: 49 additions & 33 deletions enterprise/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,11 @@ def get(self, request, enterprise_uuid, course_id):
context_data = get_global_context(request, enterprise_customer)
error_code = 'ENTHCE000'
log_message = (
'No course_modes for course_id {course_id} for enterprise_catalog_uuid '
'{enterprise_catalog_uuid}.'
'The following error was presented to '
'user {userid}: {error_code}'.format(
'[Enterprise Enrollment] Course_modes for course not found. '
'Course: {course_id}, '
'EnterpriseCatalog: {enterprise_catalog_uuid}, '
'ErrorCode: {error_code}, '
'User: {userid}'.format(
userid=request.user.id,
enterprise_catalog_uuid=enterprise_catalog_uuid,
course_id=course_id,
Expand Down Expand Up @@ -947,9 +948,8 @@ def get_available_course_modes(self, request, course_run_id, enterprise_catalog)
"""
modes = EnrollmentApiClient().get_course_modes(course_run_id)
if not modes:
LOGGER.warning('Unable to get course modes for course run id {course_run_id}.'.format(
course_run_id=course_run_id
))
LOGGER.warning('[Enterprise Enrollment] Unable to get course modes. '
'CourseRun: {course_run_id}'.format(course_run_id=course_run_id))
messages.add_generic_info_message_for_error(request)

if enterprise_catalog:
Expand All @@ -958,8 +958,9 @@ def get_available_course_modes(self, request, course_run_id, enterprise_catalog)
modes.sort(key=lambda course_mode: enterprise_catalog.enabled_course_modes.index(course_mode['slug']))
if not modes:
LOGGER.info(
'No matching course modes found for course run {course_run_id} in '
'EnterpriseCustomerCatalog [{enterprise_catalog_uuid}]'.format(
'[Enterprise Enrollment] Matching course modes were not found in EnterpriseCustomerCatalog. '
'CourseRun: {course_run_id}, '
'EnterpriseCatalog: {enterprise_catalog_uuid}'.format(
course_run_id=course_run_id,
enterprise_catalog_uuid=enterprise_catalog,
)
Expand Down Expand Up @@ -990,7 +991,8 @@ def get_base_details(self, request, enterprise_uuid, course_run_id):
)
except (ValueError, EnterpriseCustomerCatalog.DoesNotExist):
LOGGER.warning(
'EnterpriseCustomerCatalog [{enterprise_catalog_uuid}] does not exist'.format(
'[Enterprise Enrollment] EnterpriseCustomerCatalog does not exist. '
'EnterpriseCatalog: {enterprise_catalog_uuid}'.format(
enterprise_catalog_uuid=enterprise_catalog_uuid,
)
)
Expand All @@ -1007,7 +1009,9 @@ def get_base_details(self, request, enterprise_uuid, course_run_id):
enterprise_customer.site
).get_course_and_course_run(course_run_id)
except ImproperlyConfigured:
LOGGER.warning('CourseCatalogApiServiceClient is improperly configured.')
LOGGER.warning('[Enterprise Enrollment] CourseCatalogApiServiceClient is improperly configured. '
'Site: {enterprise_customer_site}'.format(
enterprise_customer_site=enterprise_customer.site.domain))
messages.add_generic_info_message_for_error(request)
return enterprise_customer, course, course_run, course_modes

Expand All @@ -1020,10 +1024,15 @@ def get_base_details(self, request, enterprise_uuid, course_run_id):
# EnterpriseCustomerCatalog, or does not exist at all in the
# discovery service.
LOGGER.warning(
'Failed to fetch details for course "{course_title}" [{course_id}] '
'or course run "{course_run_title}" [{course_run_id}] '
'for enterprise "{enterprise_name}" [{enterprise_uuid}] '
'with catalog "{enterprise_catalog_title}" [{enterprise_catalog_uuid}]'.format(
'[Enterprise Enrollment] Failed to fetch details for course or course run. '
'Course: {course_id}, '
'CourseRun: {course_run_id}, '
'CourseRunTitle: {course_run_title}, '
'CourseTitle: {course_title}, '
'EnterpriseCatalog: {enterprise_catalog_uuid}, '
'EnterpriseCatalogTitle: {enterprise_catalog_title}, '
'EnterpriseCustomer: {enterprise_uuid}, '
'EnterpriseName: {enterprise_name}'.format(
course_title=course_title,
course_id=course_id,
course_run_title=course_run_title,
Expand Down Expand Up @@ -1437,10 +1446,11 @@ def extend_course(course, enterprise_customer, request):
except ImproperlyConfigured:
error_code = 'ENTPEV000'
LOGGER.error(
'CourseCatalogApiServiceClient is improperly configured. '
'Returned error code {error_code} to user {userid} '
'and enterprise_customer {enterprise_customer} '
'for course_run_id {course_run_id}'.format(
'[Enterprise Enrollment] CourseCatalogApiServiceClient is improperly configured. '
'CourseRun: {course_run_id}, '
'EnterpriseCustomer: {enterprise_customer}, '
'ErrorCode: {error_code}, '
'User: {userid}'.format(
error_code=error_code,
userid=request.user.id,
enterprise_customer=enterprise_customer.uuid,
Expand All @@ -1454,10 +1464,11 @@ def extend_course(course, enterprise_customer, request):
if not course_details or not course_run_details:
error_code = 'ENTPEV001'
LOGGER.error(
'User {userid} of enterprise customer {enterprise_customer} encountered an error.'
'No course_details or course_run_details found for '
'course_run_id {course_run_id}. '
'The following error code reported to the user: {error_code}'.format(
'[Enterprise Enrollment] Course_details or course_run_details not found. '
'CourseRun: {course_run_id}, '
'EnterpriseCustomer: {enterprise_customer}, '
'ErrorCode: {error_code}, '
'User: {userid}'.format(
userid=request.user.id,
enterprise_customer=enterprise_customer.uuid,
course_run_id=course_run_id,
Expand Down Expand Up @@ -1507,10 +1518,11 @@ def get_program_details(self, request, program_uuid, enterprise_customer):
except ImproperlyConfigured:
error_code = 'ENTPEV002'
LOGGER.error(
'CourseCatalogApiServiceClient is improperly configured. '
'Returned error code {error_code} to user {userid} '
'and enterprise_customer {enterprise_customer} '
'for program {program_uuid}'.format(
'[Enterprise Enrollment] CourseCatalogApiServiceClient is improperly configured. '
'EnterpriseCustomer: {enterprise_customer}, '
'ErrorCode: {error_code}, '
'Program: {program_uuid}, '
'User: {userid}'.format(
error_code=error_code,
userid=request.user.id,
enterprise_customer=enterprise_customer.uuid,
Expand All @@ -1524,9 +1536,11 @@ def get_program_details(self, request, program_uuid, enterprise_customer):
if program_details is None:
error_code = 'ENTPEV003'
LOGGER.error(
'User {userid} of enterprise customer {enterprise_customer} encountered an error. '
'program_details is None for program_uuid {program_uuid}. '
'Returned error code {error_code} to user'.format(
'[Enterprise Enrollment] Program_details is None for program. '
'EnterpriseCustomer: {enterprise_customer}, '
'ErrorCode: {error_code}, '
'Program: {program_uuid}, '
'User: {userid}'.format(
userid=request.user.id,
enterprise_customer=enterprise_customer.uuid,
program_uuid=program_uuid,
Expand All @@ -1540,9 +1554,11 @@ def get_program_details(self, request, program_uuid, enterprise_customer):
if program_type is None:
error_code = 'ENTPEV004'
LOGGER.error(
'User {userid} of enterprise customer {enterprise_customer} encountered an error. '
'program_type is None for program_details of program_uuid {program_uuid}. '
'Returned error code {error_code} to user'.format(
'[Enterprise Enrollment] Program_type is None for program_details. '
'EnterpriseCustomer: {enterprise_customer}, '
'ErrorCode: {error_code}, '
'Program: {program_uuid}, '
'User: {userid}'.format(
userid=request.user.id,
enterprise_customer=enterprise_customer.uuid,
program_uuid=program_uuid,
Expand Down

0 comments on commit af6ffca

Please sign in to comment.