moodlehq/moodle-package-otel

OpenTelemetry integration for Moodle LMS

Maintainers

Package info

github.com/moodlehq/moodle-package-otel

pkg:composer/moodlehq/moodle-package-otel

Statistics

Installs: 10

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-02-24 07:46 UTC

This package is auto-updated.

Last update: 2026-03-19 22:03:09 UTC


README

This is the OpenTelemetry integration for Moodle. It must be installed using composer, and requires the OpenTelemetry PHP Extension.

Installation

Open Telemetry requires the installation of the Open Telemetry PHP Extension.

After the installation of Moodle, and the Open Telemetry extension, this plugin can be installed using composer:

composer require moodlehq/moodle-package-otel

Exporters and Protocols must also be installed per your requirements, for example:

composer require open-telemetry/exporter-otlp

PHP Configuration will be required as described by your preferred exporter.

Overview

Auto-instrumentation hooks are registered via composer, and spans will be automatically created for (moodlelms):

  • Every access (root span), including for:
    • Web Requests
    • CLI Usage
  • When a web request is made using the Moodle Routing engine:
    • App::handle() - update the root span with Routing-specific information
    • InvocationStrategyInterface - controller/action
    • RoutingMiddleware::performRouting - update the root span's name with either route name or pattern

Spans are also created for:

  • Tasks (moodlelms.cronlistener) - for the processing of each
    • scheduled task; and
    • adhoc task.
  • Moodle Events (moodlelms.eventlistener) - for the processing of Logging Events at:
    • time of event dispatch; and
    • time of bulk processing.
  • Web Service Requests (moodlelms.externalapilistener) - one span per external function call.

Configuration

The extension can be disabled via runtime configuration:

The core functionality and all child listeners can be disabled using:

OTEL_PHP_DISABLED_INSTRUMENTATIONS=moodlelms

To disable instrumentation for one of the groups of child listeners:

OTEL_PHP_DISABLED_INSTRUMENTATIONS=moodlelms.cronlistener

Adding additional instrumentation

You can add other auto-instrumentation using composer.

If you wish to create Moodle-specific instrumentation you can either do so as a standard Open Telemetry instrumentation, or you can create a Moodle Package.

Creating Moodle Open Telemetry Auto Instrumentation packages

To create your own page, you should:

  • specify a package type of moodle-package-otelhook
  • define your listeners with each listener implementing the Moodlehq\MoodlePackageOtel\Instrumentation\MoodleListenerInterface interface and optionally using the Moodlehq\MoodlePackageOtel\Instrumentation\MoodleListenerTrait trait
  • define a \Namespace\Instrumentation\ListenersDescriber class which implements \Moodlehq\MoodlePackageOtel\Instrumentation\ListenersDescriberInterface
  • define your listeners in the ListenersDescriber class