Skip to main content

Sentry Integration with OpenedX / Django application.

Open-edX/Django Application: Monitoring


 Hi, Once again welcome to blog, If you want to provide a reliable service, it’s extremely important to be aware of when things are going wrong on the website.

Sentry is a wonderful free system to catch Python exceptions. For Django, we use raven to catch and report the errors back to Sentry.

 1. To Integrate Sentry with your Django application, all you need to do is :
    1. Sign-up with Sentry  & go to dashboard/ Page.
    2.  Create a Sentry project for your application. 
    3. Then go to settings -> error tracking -> Django -> you should see dsn value already filled for you for that project.
    4.  Do changes in your settings file:
      1.  
        RAVEN_CONFIG = {
                                          'dsn':        'https://********@sentry.io/<project>',
                                           # If you are using git, you can also  automatically configure the
                                          # release based on the git info.
                                          # 'release': raven.fetch_git_sha(os.path. abspath(os.pardir)),
                                     }
    5.  Add line :  # Sentry Integration'raven.contrib.django.raven_compat', in INSTALLED_A   

      6. Set in wsgi file:  application = Sentry(get_wsgi_application())

2. To Integrate Sentry with your Open-edX , all you need to do is :
  1. Set up a Sentry server
    This is left as an exercise to the reader. Commercial hosting is available if you don’t want to administer another service (or email me and I’ll do it for a fixed fee).
  2. Set up two new services (LMS and Studio) in Sentry and get their DSN strings(This specific to OpenedX)
    The DSN strings are inside your Sentry instance under the Settings->Python->Django page.
  3. Modify /edx/app/edxapp/edx-platform/lms/envs/common.py
    Add to the end of the file:
    # Sentry integration
    INSTALLED_APPS += ('raven.contrib.django.raven_compat',)
    
    RAVEN_CONFIG = {
        'dsn': '<your-DSN-string>',
    }
    
  4. Install the raven module
    Ensure that you’re using the edxapp virtualenv. One easy way to do this is by typing which python. If you get back /usr/bin/python, you’re NOT in the virtualenv. If you get back /edx/app/edxapp/venvs/edxapp/bin/python, you are.
    Then,
    pip install raven
    
    If you’re using an edx-platform fork, you might want to add raven to edx-platform/requirements/edx/base.txt so it gets installed automatically (e.g. when you bring up Devstack).
  5. Repeat for Studio
    This time, modify /edx/app/edxapp/edx-platform/cms/envs/common.py and use the DSN string for Studio.
  6. Restart everything
    /edx/bin/supervisorctl restart edxapp:
    
  7. Test
    Hopefully, your Open edX instance doesn’t regularly give 500 errors. If you want to verify that things are working, we need to induce some.
    TODO: describe how to modify some edx-platform code to break.

Server/uptime monitoring

I strongly recommend setting up something for server monitoring; it will alert you when the server goes down, and it’ll warn you if you’re running out of memory.
I’m using Observium, primarily because it has a TurnKey Linux image and modern web interface.
Go to RamNode, set up their cheapest VM (right now, $5/quarter) and load the Observium image.
Cheap, reliable and will help you sleep at night.

Popular posts from this blog

How to read or extract text data from passport using python utility.

Hi ,  Lets get start with some utility which can be really helpful in extracting the text data from passport documents which can be images, pdf.  So instead of jumping to code directly lets understand the MRZ, & how it works basically. MRZ Parser :                 A machine-readable passport (MRP) is a machine-readable travel document (MRTD) with the data on the identity page encoded in optical character recognition format Most travel passports worldwide are MRPs.  It can have 2 lines or 3 lines of machine-readable data. This method allows to process MRZ written in accordance with ICAO Document 9303 (endorsed by the International Organization for Standardization and the International Electrotechnical Commission as ISO/IEC 7501-1)). Some applications will need to be able to scan such data of someway, so one of the easiest methods is to recognize it from an image file. I 'll show you how to retrieve the MRZ infor...

How to generate class diagrams pictures in a Django/Open-edX project from console

A class diagram in the Unified Modeling Language ( UML ) is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects. https://github.com/django-extensions/django-extensions Step 1:   Install django extensions Command:  pip install django-extensions Step 2:  Add to installed apps INSTALLED_APPS = ( ... 'django_extensions' , ... ) Step 3:  Install diagrams generators You have to choose between two diagram generators: Graphviz or Dotplus before using the command or you will get: python manage.py graph_models -a -o myapp_models.png Note:  I prefer to use   pydotplus   as it easier to install than Graphviz and its dependencies so we use   pip install pydotplus . Command:  pip install pydotplus Step 4:  Generate diagrams Now we have everything installed...

How to Remove course from Open-edX

Go to vagrant  => 1. In the edx-platform directory:  - cd /edx/app/edxapp/edx-platform 2. Run the following Django management command:   - sudo -u www-data /edx/bin/python.edxapp /edx/bin/manage.edxapp lms dump_course_ids --settings aws    - sudo -u www-data /edx/bin/python.edxapp /edx/bin/manage.edxapp lms dump_course_ids --settings=devstack 3. Find the course ID which you'd like to delete in the resulting list of course IDs. 4. Copy the course ID into the following command and run it:  - sudo -u www-data /edx/bin/python.edxapp /edx/bin/manage.edxapp cms delete_course <COURSE_ID> --settings aws  -   sudo -u www-data /edx/bin/python.edxapp /edx/bin/manage.edxapp cms delete_course <COURSE_ID> --settings=devstack  - You'll be asked to verify the deletion . To verify the deletion, run the command from step 2 above and ensure that the course ID is not in the list. Help reference : ...