From a5ce3a6ae6f5cf67180a06c1938a54dc55a2acc4 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Fri, 9 Feb 2024 15:20:43 -0500 Subject: [PATCH] docs: add event bus routing documentation --- README.rst | 55 +++++++++++++++++++ doc/user_guide/api/eventtracking.backends.rst | 8 +++ .../backends/tests/test_event_bus.py | 3 +- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5ada9141..6d80a2b4 100644 --- a/README.rst +++ b/README.rst @@ -149,6 +149,61 @@ An example configuration for ``AsyncRoutingBackend`` is provided below:: } +Event Bus Routing +----------------- + +``event-tracking`` provides a solution for routing events to the Event Bus +using the ``EventBusBackend``. It extends ``RoutingBackend`` but sends events +to the Event Bus. + +It can: + +* Process event through the configured processors. +* If the event is allowed via `EVENT_BUS_TRACKING_LOGS`, send it to the Event Bus. + +Make sure to enable the setting: ``SEND_TRACKING_EVENT_EMITTED_SIGNAL`` to allow the +``EventBusBackend`` to send events to the Event Bus. + +An example configuration for ``EventBusBackend`` is provided below:: + + EVENT_TRACKING_BACKENDS = { + 'xapi': { + 'ENGINE': 'eventtracking.backends.event_bus.EventBusBackend', + 'OPTIONS': { + 'backend_name': 'xapi', + 'processors': [ + { + 'ENGINE': 'eventtracking.processors.regex_filter.RegexFilter', + 'OPTIONS':{ + 'filter_type': 'allowlist', + 'regular_expressions': [ + 'edx.course.enrollment.activated', + 'edx.course.enrollment.deactivated', + ] + } + } + ], + 'backends': { + 'xapi': { + 'ENGINE': 'dummy.backend.engine', + 'OPTIONS': { + ... + } + } + }, + }, + }, + 'tracking_logs': { + ... + } + ... + } + + EVENT_BUS_TRACKING_LOGS = [ + 'edx.course.enrollment.activated', + 'edx.course.enrollment.deactivated', + ] + Roadmap ------- diff --git a/doc/user_guide/api/eventtracking.backends.rst b/doc/user_guide/api/eventtracking.backends.rst index 51a037ae..f2f17fce 100644 --- a/doc/user_guide/api/eventtracking.backends.rst +++ b/doc/user_guide/api/eventtracking.backends.rst @@ -42,3 +42,11 @@ eventtracking.backends.segment :undoc-members: :show-inheritance: + +eventtracking.backends.event_bus +------------------------------ + +.. automodule:: eventtracking.backends.event_bus + :members: + :undoc-members: + :show-inheritance: diff --git a/eventtracking/backends/tests/test_event_bus.py b/eventtracking/backends/tests/test_event_bus.py index 104357dc..bd170f2f 100644 --- a/eventtracking/backends/tests/test_event_bus.py +++ b/eventtracking/backends/tests/test_event_bus.py @@ -5,11 +5,10 @@ import json from datetime import datetime from unittest import TestCase -from unittest.mock import Mock, patch +from unittest.mock import patch from django.test import override_settings from openedx_events.analytics.data import TrackingLogData -from openedx_events.analytics.signals import TRACKING_EVENT_EMITTED from eventtracking.backends.event_bus import EventBusRoutingBackend