DEV Community

Cover image for Integrating Open edX with AppSignal
AMIR TADRISI for AppSignal

Posted on • Originally published at blog.appsignal.com

Integrating Open edX with AppSignal

Imagine stepping into the role of a DevOps engineer at an online learning company that utilizes Open edX as its core Learning Management System (LMS). As the platform scales to accommodate more learners, a myriad of challenges begin to surface:

  • Frequent reports of sluggish platform responses
  • Issues with password reset emails
  • Discrepancies in grading reflected on progress pages

These are just the tip of the iceberg. It's pivotal that you provide timely reports on site performance and error tracking in real time, and fix any issues before they affect a significant user base.

In this article (part one of a two-part series), we will see how AppSignal can be harnessed to enhance the robustness of Open edX. Leveraging AppSignal's comprehensive suite of features, we aim to not only monitor — but also significantly improve — platform performance.

What is Open edX?

Open edX is at the forefront of the e-learning landscape, powering Learning Management Systems for millions worldwide. With a high demand for online education, maintaining a high-quality learning experience becomes increasingly crucial.

Why AppSignal for Open edX?

In such a dynamic environment, robust monitoring and error tracking are indispensable. This is where AppSignal shines, offering a powerful toolset for early issue detection, thereby mitigating potential impacts on your learners. By integrating AppSignal with Open edX, you unlock essential features for real-time performance monitoring, automated error tracking, and actionable insights that drive informed decisions for your platform’s evolution.

Throughout this article, we’ll explore practical strategies to leverage AppSignal to build a resilient, fail-safe learning platform that consistently delivers outstanding educational experiences.

Open edX Challenges

Over the last decade of working with Open edX, I've frequently heard the following:

  • "The site is slow."
  • "We expect a high spike in enrollments and need more server resources."
  • "Users apply for password resets but never receive the emails."
  • "Grading delays are affecting the student progress page."
  • "The site styling breaks intermittently."
  • "Students encounter 500 errors without any clear explanation."

These issues underscore the critical need for a robust monitoring platform. Without it, functions like course enrollments could malfunction, overwhelming the support team or deteriorating user experiences. This may potentially cause learners to abandon courses that educators have heavily invested in developing.

The Need for Dedicated Monitoring

Open edX lacks a default system for real-time error tracking, performance monitoring, and user behavior analysis. This gap necessitates a third-party solution that can integrate seamlessly and enhance platform reliability.

  • Concurrent Users and Performance Issues: Handling large numbers of concurrent users during busy periods is vital for ensuring a smooth, uninterrupted user experience.
  • Uptime Monitoring: Monitoring downtimes and uptimes is crucial to maintaining a consistent learning environment, and minimizing student frustration due to technical issues.
  • Anomaly Detection and Error Tracking: Effective monitoring includes identifying unusual behaviors or patterns in user interactions, and providing detailed insights that help to improve educational content and methodologies.

While tools like Sentry and DataDog offer valuable features, they may not fully meet the unique demands of an e-learning environment. This brings us to the distinct advantages of AppSignal.

You can visit Compare AppSignal to Datadog and Compare AppSignal to New Relic to learn about AppSignal's difference to these tools and why it is a better decision to pick AppSignal for Open edX.

How does AppSignal Benefit Open edX?

AppSignal stands out by catering specifically to the needs of platforms like Open edX, providing a robust set of tools designed to tackle the unique challenges of online learning environments:

  • All-Inclusive Features: AppSignal offers a comprehensive suite of monitoring tools, including error tracking, performance monitoring, and anomaly detection. This holistic approach eliminates the need to manage multiple services.
  • Real-Time Analytics and Dashboards: With customizable dashboards, AppSignal provides immediate insights into critical metrics such as error rates, uptime, and response times. You can also create custom metrics like enrollment count and visualize these metrics via a custom dashboard.
  • Ease of Integration: The AppSignal SDK makes integration straightforward, minimizing setup time and allowing for quick implementation of comprehensive monitoring capabilities.

Incorporating AppSignal not only addresses the immediate operational challenges but also enhances the strategic development of Open edX platforms by providing deep, actionable insights into system performance and user engagement.

AppSignal uses the OpenTelemetry protocol, which provides a robust foundation for observability. This integration brings a wealth of out-of-the-box tools and features, enhancing the monitoring capabilities of your Open edX platform.

Prerequisites

To integrate AppSignal with Open edX, we need the following requirements:

In this article, we will use Tutor to install and customize Open edX.

How to Install Open edX

In this section, we'll quickly review how to install the Open edX Dev instance on the Ubuntu 22.04 operating system.

To Install Tutor on other operating systems, please visit the official Tutor docs.

Open your terminal and run the following commands (before continuing, make sure you have the necessary libraries and applications mentioned in the Prerequisites section):

sudo apt update -y
sudo apt upgrade -y
sudo apt install python3 python3-pip libyaml-dev
pip install "tutor[full]"
tutor local launch
Enter fullscreen mode Exit fullscreen mode

Provide all the necessary information and a correct URL pointing to your server's IP address.

After finishing the deployment you should be able to visit the URL you provided to see your Open edX instance.

openedx

Integrate AppSignal

Let's integrate Open edX with AppSignal to start receiving data in our AppSignal Dashboard.

First, go to the AppSignal login page, create a new Python application, and grab your API KEY. We are going to need that in the next step.

Install Appsignal

Now let's go to where you installed Tutor. Open the file .local/share/tutor/config.yml and add the following libraries to the OPENEDX_EXTRA_PIP_REQUIREMENTS configuration to install all the necessary libraries for AppSignal:

OPENEDX_EXTRA_PIP_REQUIREMENTS:
  - appsignal==1.3.0
  - opentelemetry-instrumentation-django==0.45b0
Enter fullscreen mode Exit fullscreen mode

Next, run tutor config save and relaunch the platform by running tutor local launch. This should install all the necessary packages for you.

After the deployment completes, we'll initialize AppSignal in our Open edX code base and recreate the Open edX Docker images.

Clone the Quince branch of the edx-platform codebase: git clone https://github.com/openedx/edx-platform/tree/open-release/quince.master. Open edx-platform in your favorite editor and follow these instructions:

  • In the lms directory, create a new file called __appsignal__.py and add the following code:
import os
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration

# Get APPSIGNAL_PUSH_API_KEY from environment
site = SiteConfiguration.objects.get(site__domain="thelearningalgorithm.ai")
APPSIGNAL_PUSH_API_KEY = os.environ.get("APPSIGNAL_PUSH_API_KEY")
os.environ.setdefault("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python")

from appsignal import Appsignal
appsignal = Appsignal(
    active=True,
    name="openedx",
    push_api_key=APPSIGNAL_PUSH_API_KEY,
)
Enter fullscreen mode Exit fullscreen mode

In your tutor server, create a new environment variable called APPSIGNAL_PUSH_API_KEY and set the AppSignal API key there.

  • Next, let's start AppSignal in wsgi. Go to lms/wsgi.py and add the following code:
modulestore() # exiting line

# import appsignal
from lms.__appsignal__ import appsignal

# Start Appsignal
appsignal.start()
Enter fullscreen mode Exit fullscreen mode

You can look at this commit to see how I did it.

Learn more about integrating AppSignal with Django.

Now, create a new repo for your edx-platform on GitHub and push your changes there as a new branch. When you are done, run the following command to build a new image for the Open edX container based on your changes:

tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/[YOUR ORGANIZTION]/edx-platform.git --build-arg EDX_PLATFORM_VERSION=[YOUR BRANCH NAME] && tutor local stop && tutor local start -d
Enter fullscreen mode Exit fullscreen mode

If you want to build based on my branch, you can run the following command:

tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/amirtds/edx-platform.git --build-arg EDX_PLATFORM_VERSION=feat/appsignal-integration && tutor local stop && tutor local start -d
Enter fullscreen mode Exit fullscreen mode

That's it! Now go to your Open edX site and do some basic interactions like logging in and viewing course content. You should see that your AppSignal Dashboard starts populating with data from your instance.

In this section, we added AppSignal for the LMS part of Open edX. You can follow the same steps in the CMS directory to add monitoring for the studio.

Track Errors with AppSignal

Now head to the AppSignal Dashboard and click on Errors -> Issue List on the left sidebar. Here, you should see all the errors that occur when users visit specific URLs. By clicking on each issue, you should see more detailed information.

Integrate AppSignal with your GitHub repo so that an issue is created in the repo automatically when an error occurs. This way, you won't lose track of errors.

Errors list

In the Graphs, we can see the error rate, count, and throughput:

errors graph

Monitor Performance

In the Performance section, click on the Issues list. Here, you should see a breakdown of all the visited URLs and important metrics, including:

  • Mean: The average response time for all the requests made to a particular endpoint. It provides a general idea of how long it takes for the server to respond. In our context, any mean response time greater than 1 second could be considered a red flag, indicating that our application's performance might not meet user expectations for speed.
  • Throughput: This is the number of requests that are being handled per second.
  • Impact: An action's impact on our application, based on its usage compared to other actions.

performance list

We can also see graphs showing our application's performance:

performance graphs

This information is highly important for us since it shows the user experience when loading each page.
When numbers are high, we should look for ways to improve the user experience and reduce the mean response time. For example, in our case, we have multiple requests that take longer than 1 second. That means there is room to improve our application's performance.

performance long requests

In the Performance section, we can also monitor background tasks and queries like Celery tasks. We'll look at this in more depth in part two of this series.

Anomaly Detection and Alerts

Here, we can define triggers when there is unusual resource usage on our platform. It is highly important to monitor resource usage and take action so our site doesn't go down when there's a spike in users. Additionally, an important function on the platform might fail, resulting in a high number of errors. By using anomaly detection, we get a notification before it impacts more users.

Let's create 2 triggers: one for high memory usage when it's above 70% and one for % of error rates when they are higher than 20%.

In the Anomaly Detection section on the left sidebar, click on Triggers and follow these steps:

anomaly trigger 1

anomaly trigger 2

anomaly trigger all

Check the Email notification to receive an email notification when an anomaly happens.

In the Issues list, you can see all anomalies based on defined conditions:

anomaly trigger happened

Uptime Monitoring

In my experience with Open edX over the past few years, two scenarios have consistently highlighted the need for robust uptime monitoring:

  1. Post-Deployment Styling Issues: After deployments, CSS links can sometimes change, leading to a 404 error on the CSS resource URL and a broken appearance due to missing styles. This not only impacts the aesthetic appeal of Open edX, but can also confuse and frustrate users.
  2. System Downtimes: Various factors can bring an entire site down, such as database outages or failures in the third-party systems that we've integrated. These downtimes disrupt the learning process and can damage our platform's reputation.

Uptime monitoring is invaluable as it not only confirms our site's operational status, but also alerts us the moment it goes down, allowing us to take quick action to restore functionality.

Regional Response Times: An interesting feature of AppSignal's uptime check is its ability to display response times from different regions. This data provides critical insights into how a site's performance varies globally, which is particularly useful for international educational platforms looking to deliver a consistent user experience across diverse geographical locations.

Public Status Page: You can set up a public status page to communicate real-time site status. This page serves as a reliable source for students to verify whether a site is operational, and can reduce the number of support tickets you get.
For instance, you can view an example here.

uptimecheck public page

Simply add a new URL by clicking on Add Uptime Monitor. In this case, I created one for the CSS resource and one for the main LMS URL.

uptimecheck

uptimecheck

Host Monitoring

Here, we see how our VM resources are being used by our application through visuals and graphs.

host_metric_1
host_metric_2
host_metric_3

Wrapping Up

In this article, we've explored how AppSignal can be integrated with Open edX to bring robust monitoring capabilities to your learning platform. Without requiring extensive configuration beyond an initial setup, AppSignal provides a rich array of features right out of the box. These features enable real-time insights into application performance, error tracking, and uptime monitoring — all essential tools for any DevOps team dedicated to creating a fail-safe learning environment.

In part two of this two-part series, we will dive deeper into the capabilities of AppSignal by demonstrating how to stream logs from Open edX to AppSignal, monitor background tasks with Celery, track Redis queries, and more.

Until then, happy coding!

P.S. If you'd like to read Python posts as soon as they get off the press, subscribe to our Python Wizardry newsletter and never miss a single post!

Top comments (0)