Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reorder context assignment in producer code. #192

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Change Log
Unreleased
**********

* Changed ordering of certain context assignments in producer code.

[5.3.1] - 2023-08-10
********************
Fixed
Expand Down
8 changes: 6 additions & 2 deletions edx_event_bus_kafka/internal/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,17 @@ def send(
context = ProducingContext(signal=signal, initial_topic=topic, event_key_field=event_key_field,
event_data=event_data, event_metadata=event_metadata)
try:
context.event_data_as_json = json.dumps(get_signal_serializer(signal).to_dict(event_data))
context.event_metadata_as_json = event_metadata.to_json()
# Please keep these context assignments in order from least-likely-to-error to most-likely-to-error so that
# we have as much context as possible in error logging.
full_topic = get_full_topic(topic)
context.full_topic = full_topic

context.event_data_as_json = json.dumps(get_signal_serializer(signal).to_dict(event_data))
context.event_metadata_as_json = event_metadata.to_json()

event_key = extract_event_key(event_data, event_key_field)
context.event_key = event_key

headers = _get_headers_from_metadata(event_metadata=event_metadata)

key_serializer, value_serializer = get_serializers(signal, event_key_field)
Expand Down