diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29684e8..386b9c8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,12 @@ Change Log Unreleased ********** +[5.3.0] - 2023-08-08 +******************** +Changed +======= +* Added event_metadata_as_dict to ProducingContext for easier replay from logs + [5.2.0] - 2023-08-03 ******************** Changed diff --git a/edx_event_bus_kafka/__init__.py b/edx_event_bus_kafka/__init__.py index 3a20118..45c3c46 100644 --- a/edx_event_bus_kafka/__init__.py +++ b/edx_event_bus_kafka/__init__.py @@ -9,4 +9,4 @@ from edx_event_bus_kafka.internal.consumer import KafkaEventConsumer from edx_event_bus_kafka.internal.producer import KafkaEventProducer, create_producer -__version__ = '5.2.0' +__version__ = '5.3.0' diff --git a/edx_event_bus_kafka/internal/producer.py b/edx_event_bus_kafka/internal/producer.py index 7469f6c..08a216f 100644 --- a/edx_event_bus_kafka/internal/producer.py +++ b/edx_event_bus_kafka/internal/producer.py @@ -208,6 +208,7 @@ class ProducingContext: event_data = attr.ib(type=dict, default=None) event_metadata = attr.ib(type=EventsMetadata, default=None) event_data_as_json = attr.ib(type=str, default=None) + event_metadata_as_json = attr.ib(type=str, default=None) def __repr__(self): """Create a logging-friendly string""" @@ -284,6 +285,7 @@ def send( 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() full_topic = get_full_topic(topic) context.full_topic = full_topic diff --git a/edx_event_bus_kafka/internal/tests/test_producer.py b/edx_event_bus_kafka/internal/tests/test_producer.py index d9f84d6..ca90136 100644 --- a/edx_event_bus_kafka/internal/tests/test_producer.py +++ b/edx_event_bus_kafka/internal/tests/test_producer.py @@ -247,6 +247,7 @@ def test_full_event_data_present_in_key_extraction_error(self, mock_logger, *arg assert f"sourcehost='{metadata.sourcehost}'" in error_string assert "event_data_as_json='{\"test_data\": {\"course_id\": \"id\", \"sub_name\": \"name\"}}'"\ in error_string + assert f"event_metadata_as_json='{metadata.to_json()}'" in error_string @patch( 'edx_event_bus_kafka.internal.producer.get_serializers', autospec=True, @@ -287,6 +288,7 @@ def test_full_event_data_present_in_kafka_error(self, mock_logger, *args): assert "error=bad!" in error_string assert "event_data_as_json='{\"test_data\": {\"course_id\": \"ABCx\", \"sub_name\": \"name\"}}'"\ in error_string + assert f"event_metadata_as_json='{metadata.to_json()}'" in error_string @override_settings(EVENT_BUS_KAFKA_POLL_INTERVAL_SEC=0.05) def test_polling_loop_terminates(self): diff --git a/requirements/base.txt b/requirements/base.txt index 0b9f65b..0cb8aa2 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -48,7 +48,7 @@ markupsafe==2.1.3 # via jinja2 newrelic==8.8.1 # via edx-django-utils -openedx-events==8.3.0 +openedx-events==8.5.0 # via -r requirements/base.in pbr==5.11.1 # via stevedore diff --git a/requirements/dev.txt b/requirements/dev.txt index fc3dfd0..33dd6fb 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -202,7 +202,7 @@ newrelic==8.8.1 # via # -r requirements/quality.txt # edx-django-utils -openedx-events==8.3.0 +openedx-events==8.5.0 # via -r requirements/quality.txt packaging==23.1 # via diff --git a/requirements/doc.txt b/requirements/doc.txt index c0b4587..29b7e39 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -152,7 +152,7 @@ newrelic==8.8.1 # via # -r requirements/test.txt # edx-django-utils -openedx-events==8.3.0 +openedx-events==8.5.0 # via -r requirements/test.txt packaging==23.1 # via diff --git a/requirements/quality.txt b/requirements/quality.txt index a079ec0..21e60b1 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -150,7 +150,7 @@ newrelic==8.8.1 # via # -r requirements/test.txt # edx-django-utils -openedx-events==8.3.0 +openedx-events==8.5.0 # via -r requirements/test.txt packaging==23.1 # via diff --git a/requirements/test.txt b/requirements/test.txt index b660fa2..2fca457 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -88,7 +88,7 @@ newrelic==8.8.1 # via # -r requirements/base.txt # edx-django-utils -openedx-events==8.3.0 +openedx-events==8.5.0 # via -r requirements/base.txt packaging==23.1 # via pytest