The code_owner custom attribute can be used to create custom dashboards and alerts for monitoring the things that you own. It was originally introduced for the LMS, as is described in this ADR on monitoring by code owner.
You can now easily add this same attribute to any IDA so that your dashboards and alerts can work across multiple IDAs at once.
If you want to know about custom attributes in general, see: using_custom_attributes.rst.
You simply need to add edx_django_utils.monitoring.CodeOwnerMonitoringMiddleware
as described in the README to make this functionality available. Then it is ready to be configured.
Celery tasks require use of a special decorator to set the code_owner
custom attribute because no middleware will be run.
Here is an example:
@task()
@set_code_owner_attribute
def example_task():
...
If the task is not compatible with additional decorators, you can use the following alternative:
@task()
def example_task():
set_code_owner_attribute_from_module(__name__)
...
An untested potential alternative to the @set_code_owner_attribute
decorator is to try celery's task_prerun signal in an IDA, which would also ensure all future celery tasks are automatically handled.
Once the Middleware is made available, simply set the Django Setting CODE_OWNER_MAPPINGS
appropriately.
The following example shows how you can include an optional config for a catch-all using '*'
. Although you might expect this example to use Python, it is intentionally illustrated in YAML because the catch-all requires special care in YAML.
# YAML format of example CODE_OWNER_MAPPINGS
CODE_OWNER_MAPPINGS:
team-red:
- xblock_django
- openedx.core.djangoapps.xblock
team-blue:
- '*' # IMPORTANT: you must surround * with quotes in yml
If you are missing the code_owner custom attribute on a particular Transaction or Error, or if code_owner is matching the catch-all, but you want to add a more specific mapping, you can use the other code_owner supporting attributes to determine what the appropriate mappings should be.