feat: add json-formatted event data to error logs #186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds event_data_as_json to the error log when an event is not published. This will make it easier to recreate the event from the logs using an AvroSignalDeserializer.
Added the field instead of replacing the event data field so we will still get the event that was passed to the send method even if something in the serializer throws an error on creation. Also left everything else in the
=
format because Splunk is actually parsing them correctly as fields, it was just the nested event data it had trouble with.To test, set up your event bus to point to the dev cluster but with an incorrect schema registry password. When trying to fire an event, you should see an error like
Error delivering message to Kafka event bus. error=Unauthorized (HTTP status code 401, SR code 401) full_topic='dev-graber-course-catalog-info-changed' event_key=CourseLocator('edX', 'DemoX', 'Demo_Course', None, None) signal=<OpenEdxPublicSignal: org.openedx.content_authoring.course.catalog_info.changed.v1> initial_topic='course-catalog-info-changed' event_key_field='catalog_info.course_key' event_data={'catalog_info': CourseCatalogData(course_key=CourseLocator('edX', 'DemoX', 'Demo_Course', None, None), name='Demonstration Course', schedule_data=CourseScheduleData(start=datetime.datetime(2013, 2, 5, 5, 0, tzinfo=<bson.tz_util.FixedOffset object at 0xffff58196b80>), pacing='instructor', end=None, enrollment_start=datetime.datetime(2013, 2, 5, 0, 0, tzinfo=<bson.tz_util.FixedOffset object at 0xffff58196b80>), enrollment_end=None), hidden=False, invitation_only=False)} event_metadata=EventsMetadata(event_type='org.openedx.content_authoring.course.catalog_info.changed.v1', id=UUID('065c50fe-3218-11ee-bfb5-0242ac15000c'), minorversion=0, source='openedx/cms/web', sourcehost='cms.devstack.edx', time=datetime.datetime(2023, 8, 3, 16, 8, 44, 784693, tzinfo=datetime.timezone.utc), sourcelib=(8, 3, 0)) event_data_as_json='{"catalog_info": {"course_key": "course-v1:edX+DemoX+Demo_Course", "hidden": false, "invitation_only": false, "name": "Demonstration Course", "schedule_data": {"end": null, "enrollment_end": null, "enrollment_start": "2013-02-05T00:00:00+00:00", "pacing": "instructor", "start": "2013-02-05T05:00:00+00:00"}}}'
(note the event_data_as_json field).
Merge checklist:
Check off if complete or not applicable: