From eef979831ba871b71b085ce0f344d5f619337f2e Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Thu, 26 Oct 2023 15:32:01 -0500 Subject: [PATCH] fix: only generate metadata --- eventtracking/backends/event_bus.py | 17 +++-------------- eventtracking/backends/tests/test_event_bus.py | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/eventtracking/backends/event_bus.py b/eventtracking/backends/event_bus.py index baba6e2..3c3b543 100644 --- a/eventtracking/backends/event_bus.py +++ b/eventtracking/backends/event_bus.py @@ -13,8 +13,6 @@ logger = logging.getLogger(__name__) -EVENT_BUS_SOURCE = "openedx/eventtracking" - class EventBusRoutingBackend(RoutingBackend): """ Event tracker backend that emits an Open edX public signal. @@ -38,22 +36,13 @@ def send(self, event): context=context, ) + metadata = TRACKING_EVENT_EMITTED.generate_signal_metadata() + logger.info(f"Sending tracking event emitted signal for event for {tracking_log.name}") get_producer().send( signal=TRACKING_EVENT_EMITTED, topic="analytics", event_key_field="tracking_log.name", event_data={"tracking_log": tracking_log}, - event_metadata=generate_signal_metadata() + event_metadata=metadata, ) - - -def generate_signal_metadata(): - """ - Generate the metadata for the signal with a custom source. - """ - metadata = TRACKING_EVENT_EMITTED.generate_signal_metadata() - medata_dict = asdict(metadata) - medata_dict["source"] = EVENT_BUS_SOURCE - metadata = EventsMetadata(**medata_dict) - return metadata diff --git a/eventtracking/backends/tests/test_event_bus.py b/eventtracking/backends/tests/test_event_bus.py index 2b33b0b..88820f4 100644 --- a/eventtracking/backends/tests/test_event_bus.py +++ b/eventtracking/backends/tests/test_event_bus.py @@ -46,7 +46,7 @@ def test_successful_send_event(self, mock_get_producer): data=json.dumps(self.sample_event['data']), context=json.dumps(self.sample_event['context']), ) - + ) @patch('eventtracking.backends.event_bus.SEND_TRACKING_EVENT_EMITTED_SIGNAL.is_enabled') @patch('eventtracking.backends.event_bus.get_producer')