Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Plugin Status (*Experimental*, *Production*, or *D
=================================== ======================================================
tutor-contrib-learner-dashboard-mfe Deprecated
tutor-contrib-test-legacy-js "Production" (Supported For Developers)
tutor-contrib-scout-apm Experimental
=================================== ======================================================

Getting Started
Expand Down
7 changes: 7 additions & 0 deletions plugins/tutor-contrib-scout-apm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.*.swp
!.gitignore
TODO
__pycache__
*.egg-info/
/build/
/dist/
1 change: 1 addition & 0 deletions plugins/tutor-contrib-scout-apm/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include tutor_scout_apm/patches *
35 changes: 35 additions & 0 deletions plugins/tutor-contrib-scout-apm/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Scout APM plugin for `Tutor <https://docs.tutor.overhang.io>`_
==============================================================

This plugin allows Open edX LMS and Studio site operators add support for Scout APM monitoring.

Installation
------------

This will install the `Scout APM <https://scoutapm.com/>`_ plugin directly from Github::

pip install git+https://github.com/openedx/openedx-tutor-plugins.git#subdirectory=plugins/tutor-contrib-scout-apm

Alternatively, you can clone the parent repository locally and install it from the checkout::

git clone https://github.com/openedx/openedx-tutor-plugins.git
cd openedx-tutor-plugins/plugins/tutor-contrib-scout-apm
pip install -e .

Usage
-----

Once installed, run the following commands to enable it::

tutor plugins enable scout-apm
tutor images build openedx-dev

Add the following entries to your Tutor ``config.yml`` file:

* ``SCOUT_KEY``: Get this from your Scout APM account.
* ``SCOUT_NAME``: A user friendly name for your application. It will have "| LMS" or "| Studio" appended to it. So if you put "Sumac Test Server", the two Scout apps being reported will be "Sumac Test Server | LMS" and "Sumac Test Server | Studio".

License
-------

This software is licensed under the terms of the AGPLv3.
60 changes: 60 additions & 0 deletions plugins/tutor-contrib-scout-apm/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import io
import os
from setuptools import setup, find_packages

HERE = os.path.abspath(os.path.dirname(__file__))


def load_readme():
with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f:
return f.read()


def load_about():
about = {}
with io.open(
os.path.join(HERE, "tutor_scout_apm", "__about__.py"),
"rt",
encoding="utf-8",
) as f:
exec(f.read(), about) # pylint: disable=exec-used
return about


ABOUT = load_about()


setup(
name="tutor-scout-apm",
version=ABOUT["__version__"],
url="https://github.com/openedx/openedx-tutor-plugins",
project_urls={
"Code": "https://github.com/openedx/openedx-tutor-plugins",
"Issue tracker": "https://github.com/openedx/openedx-tutor-plugins/issues",
},
license="AGPLv3",
author="David Ormsbee",
description="Scout APM plugin for Tutor",
long_description=load_readme(),
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.8",
install_requires=["tutor"],
extras_require={"dev": ["tutor[dev]>=16.0.0,<19.0.0"]},
entry_points={
"tutor.plugin.v1": [
"scout-apm = tutor_scout_apm.plugin"
]
},
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SCOUT_MONITOR = True
SCOUT_KEY = "{{ SCOUT_KEY }}"
SCOUT_NAME = "{{ SCOUT_NAME }} | Studio"

# Prepend the Scout APM before everything else so that it can inject its
# monitoring.
INSTALLED_APPS.insert(0, "scout_apm.django")

SCOUT_MIDDLEWARE = [
"scout_apm.django.middleware.MiddlewareTimingMiddleware",
"scout_apm.django.middleware.ViewTimingMiddleware",
]
MIDDLEWARE = SCOUT_MIDDLEWARE + MIDDLEWARE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared \
pip install "scout-apm>=3.2.1,<4.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SCOUT_MONITOR = True
SCOUT_KEY = "{{ SCOUT_KEY }}"
SCOUT_NAME = "{{ SCOUT_NAME }} | LMS"

# Prepend the Scout APM before everything else so that it can inject its
# monitoring.
INSTALLED_APPS.insert(0, "scout_apm.django")

SCOUT_MIDDLEWARE = [
"scout_apm.django.middleware.MiddlewareTimingMiddleware",
"scout_apm.django.middleware.ViewTimingMiddleware",
]
MIDDLEWARE = SCOUT_MIDDLEWARE + MIDDLEWARE
46 changes: 46 additions & 0 deletions plugins/tutor-contrib-scout-apm/tutor_scout_apm/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from __future__ import annotations
from glob import glob
import os
import pkg_resources
import uuid

from tutor import hooks as tutor_hooks

from .__about__ import __version__

########################################
# CONFIGURATION
########################################

tutor_hooks.Filters.CONFIG_DEFAULTS.add_item(
("SCOUT_KEY", "")
)
tutor_hooks.Filters.CONFIG_DEFAULTS.add_item(
("SCOUT_NAME", "")
)

########################################
# INITIALIZATION TASKS
########################################


########################################
# TEMPLATE RENDERING
########################################


########################################
# PATCH LOADING
########################################

# For each file in tutor_media/patches,
# apply a patch based on the file's name and contents.
patch_files = glob(
os.path.join(
pkg_resources.resource_filename("tutor_scout_apm", "patches"),
"*",
)
)
for path in patch_files:
with open(path, encoding="utf-8") as patch_file:
tutor_hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read()))
Loading