Skip to content

Commit

Permalink
Merge pull request #1911 from openedx/hamza/ENT-7725
Browse files Browse the repository at this point in the history
feat: ENT-7725 add logs to debug
  • Loading branch information
hamzawaleed01 authored Oct 17, 2023
2 parents 214aad4 + 63fe8ce commit 7f668f8
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Change Log
Unreleased
----------
[4.6.5]
-------
feat: Added logs for Degreed2 client

[4.6.4]
-------
chore: updating sso orchestrator self service api endpoints
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.6.4"
__version__ = "4.6.5"
44 changes: 42 additions & 2 deletions integrated_channels/degreed2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ def create_course_completion(self, user_id, payload):
Returns: status_code, response_text
"""
json_payload = json.loads(payload)
LOGGER.error(
generate_formatted_log(
self.enterprise_configuration.channel_code(),
self.enterprise_configuration.enterprise_customer.uuid,
user_id,
None,
'[Degreed2Client] - Attempting degreed2 create_course_completion,'
f'payload:{json_payload}'
)
)
LOGGER.info(self.make_log_msg(
json_payload.get('data').get('attributes').get('content-id'),
f'Attempting find course via url: {self.get_completions_url()}'),
Expand Down Expand Up @@ -345,12 +355,22 @@ def _get(self, url, scope):
self.enterprise_configuration.enterprise_customer.uuid,
None,
None,
f'429 detected from {url}, backing-off before retrying, '
f'[Degreed2Client]._get 429 detected from {url}, backing-off before retrying, '
f'sleeping {sleep_seconds} seconds...'
)
)
time.sleep(sleep_seconds)
else:
LOGGER.error(
generate_formatted_log(
self.enterprise_configuration.channel_code(),
self.enterprise_configuration.enterprise_customer.uuid,
None,
None,
'[Degreed2Client]._get - Exceeded retry attempts in:'
f'URL:{url}'
)
)
break
return response.status_code, response.text

Expand Down Expand Up @@ -378,13 +398,33 @@ def _post(self, url, data, scope):
self.enterprise_configuration.enterprise_customer.uuid,
None,
None,
f'429 detected from {url}, backing-off before retrying, '
f'[Degreed2Client]._post 429 detected from {url}, backing-off before retrying, '
f'sleeping {sleep_seconds} seconds...'
)
)
time.sleep(sleep_seconds)
else:
LOGGER.error(
generate_formatted_log(
self.enterprise_configuration.channel_code(),
self.enterprise_configuration.enterprise_customer.uuid,
None,
None,
'[Degreed2Client]._post - Exceeded retry attempts in:'
f'URL:{url}, DATA:{data}'
)
)
break
LOGGER.error(
generate_formatted_log(
self.enterprise_configuration.channel_code(),
self.enterprise_configuration.enterprise_customer.uuid,
None,
None,
'[Degreed2Client] - Successfuly called:'
f'RESPONSE:{response}'
)
)
return response.status_code, response.text

def _patch(self, url, data, scope):
Expand Down
19 changes: 19 additions & 0 deletions integrated_channels/degreed2/exporters/learner_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,28 @@ def get_learner_data_records(
degreed_completed_timestamp = completed_date.strftime('%Y-%m-%dT%H:%M:%S') if isinstance(
completed_date, datetime
) else None
LOGGER.info(generate_formatted_log(
self.enterprise_configuration.channel_code(),
enterprise_enrollment.enterprise_customer_user.enterprise_customer.uuid,
enterprise_enrollment.enterprise_customer_user.user_id,
enterprise_enrollment.course_id,
'[Degreed2Client] - Attempting get_learner_data_records:'
f'percent_grade={percent_grade}, degreed_completed_timestamp={degreed_completed_timestamp}'
f'completed_date={completed_date}, course_completed={course_completed}'
))
if enterprise_enrollment.enterprise_customer_user.get_remote_id(
self.enterprise_configuration.idp_id
) is not None:
LOGGER.info(generate_formatted_log(
self.enterprise_configuration.channel_code(),
enterprise_enrollment.enterprise_customer_user.enterprise_customer.uuid,
enterprise_enrollment.enterprise_customer_user.user_id,
enterprise_enrollment.course_id,
'[Degreed2Client] - Found remote id:'
f'percent_grade={percent_grade}, degreed_completed_timestamp={degreed_completed_timestamp}'
f'completed_date={completed_date}, course_completed={course_completed}'
f'course_id={get_course_id_for_enrollment(enterprise_enrollment)}'
))
Degreed2LearnerDataTransmissionAudit = apps.get_model(
'degreed2',
'Degreed2LearnerDataTransmissionAudit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ def transmit(self, payload, **kwargs): # pylint: disable=arguments-differ
# one by course key and one by course run id.
# If the transmission with the course key succeeds, the next one will get skipped.
# If it fails, the one with the course run id will be attempted and (presumably) succeed.
LOGGER.info(generate_formatted_log(
self.enterprise_configuration.channel_code(),
enterprise_customer_uuid,
None,
None,
f"Looping through learner data = {payload.export(**kwargs)}"
))

for learner_data in payload.export(**kwargs):
serialized_payload = learner_data.serialize(enterprise_configuration=self.enterprise_configuration)

Expand Down

0 comments on commit 7f668f8

Please sign in to comment.