Skip to content

Commit aa0e7f6

Browse files
committed
[docs] Add documentation for OpenTelemetry
1 parent 2ce16d5 commit aa0e7f6

3 files changed

Lines changed: 81 additions & 0 deletions

File tree

docs/apis.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ The [Plagiarism API](./apis/subsystems/plagiarism.md) allows your activity modul
256256

257257
The [Question API](https://docs.moodle.org/dev/Question_API) (which can be divided into the Question bank API and the Question engine API), can be used by activities that want to use questions from the question bank.
258258

259+
### Open Telemetry {/* #otel */}
260+
261+
The [Open Telemetry integration](./apis/telemetry/index.mdx) allows administrators to observe the impact of various Moodle features and functionality.
262+
259263
## See also {/* #see-also */}
260264

261265
{/* <!-- cspell:ignore codingstyle --> */}

docs/apis/telemetry/index.mdx

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Open Telemetry
3+
tags:
4+
- telemetry
5+
---
6+
7+
<Since version="5.2" />
8+
9+
Moodle added support for Open Telemetry in version 5.2. This allows Moodle to collect telemetry data and send it to a telemetry backend for analysis and monitoring.
10+
11+
The Moodle Open Telemetry integration sits outside of Moodle core and follows the same pattern as other Open Telemetry integrations for PHP.
12+
13+
## Installation
14+
15+
To install the Open Telemetry integration for Moodle, you can use Composer to require the `moodlehq/moodle-package-otel` package.
16+
17+
In addition to the Moodle Open Telemetry integration, you will also need to set up the following components:
18+
19+
- The [PHP Open Telemetry Extension](https://github.com/open-telemetry/opentelemetry-php-instrumentation), which provides the necessary instrumentation for collecting telemetry data from Moodle.
20+
- An Open Telemetry Transport, such as HTTP (included) or [open-telemetry/transport-grpc](https://packagist.org/packages/open-telemetry/transport-grpc)
21+
- An Open Telemetry Exporter, such as [open-telemetry/exporter-otlp](https://packagist.org/packages/open-telemetry/exporter-otlp)
22+
- An Open Telemetry Collector, which is responsible for receiving telemetry data from Moodle and forwarding it to the telemetry backend. The Open Telemetry Collector can be deployed as a standalone service or as part of a larger monitoring infrastructure.
23+
- A telemetry backend that supports the Open Telemetry protocol, such as [SigNoz](https://signoz.io/), [Jaeger](https://www.jaegertracing.io/), [Zipkin](https://zipkin.io/), or [Prometheus](https://prometheus.io/), to receive and analyze the telemetry data collected from Moodle.
24+
25+
## What is included
26+
27+
The Moodle Open Telemetry integration includes the following features:
28+
29+
- The creation of a root span for all:
30+
- web requests
31+
- CLI commands
32+
- Specific instrumentation for:
33+
- the Moodle Tasks API (Scheduled and Adhoc tasks) (`moodlelms.cronlistener`);
34+
- Moodle events (`moodlelms.eventlistener`);
35+
- Web Service function calls (`moodlelms.externalapilistener`).
36+
37+
## Configuration
38+
39+
The Moodle Open Telemetry integration can be configured using the PHP configuration file (php.ini) or by setting environment variables (for example in your web server).
40+
41+
The current Moodle Open Telemetry integration can be disabled by setting the `OTEL_PHP_DISABLED_INSTRUMENTATIONS` setting to `moodlelms`, for example:
42+
43+
```ini
44+
OTEL_PHP_DISABLED_INSTRUMENTATIONS=moodlelms
45+
```
46+
47+
This will disable the Moodle Open Telemetry integration, whilst allowing other Open Telemetry integrations to continue collecting telemetry data and sending it to the telemetry backend.
48+
49+
Individual Moodle instrumentations can be disabled by setting the `OTEL_PHP_DISABLED_INSTRUMENTATIONS` setting to the specific instrumentation name, for example:
50+
51+
```ini
52+
OTEL_PHP_DISABLED_INSTRUMENTATIONS=moodlelms.cronlistener
53+
```
54+
55+
Multiple instrumentations can be disabled by separating the instrumentation names with a comma, for example:
56+
57+
```ini
58+
OTEL_PHP_DISABLED_INSTRUMENTATIONS=moodlelms.cronlistener,moodlelms.eventlistener
59+
```
60+
61+
## Writing additional instrumentation
62+
63+
When writing additional instrumentation for Moodle there are two options:
64+
65+
- write a standard Open Telemetry instrumentation package for PHP, which can be used in any PHP application, including Moodle. This would involve creating a new package that follows the Open Telemetry instrumentation guidelines and can be installed via Composer.
66+
- write a Moodle-specific instrumentation package that extends the base class provided by the Moodle Open Telemetry integration. This would involve creating a new package that extends the base class provided by the Moodle Open Telemetry integration and can be installed via Composer.
67+
68+
### Moodle-specific instrumentation
69+
70+
To create your own Moodle-specific instrumentation, you should:
71+
72+
- specify a package type of `moodle-package-otelhook`;
73+
- define your listeners with each listener implementing the `Moodlehq\MoodlePackageOtel\Instrumentation\MoodleListenerInterface` interface and optionally using the `Moodlehq\MoodlePackageOtel\Instrumentation\MoodleListenerTrait` trait
74+
- define a `\Namespace\Instrumentation\ListenersDescriber` class which implements `Moodlehq\MoodlePackageOtel\Instrumentation\ListenersDescriberInterface`
75+
- define your listeners in the `ListenersDescriber` class

project-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Quicklist
7272
Recaptcha
7373
RDBM
7474
RDBMS
75+
SigNoz
7576
SIGINT
7677
SIGTERM
7778
Soulier
@@ -86,6 +87,7 @@ WCAG
8687
Xdebug
8788
XMLDB
8889
XMPPHP
90+
Zipkin
8991
accessallgroups
9092
activeusers
9193
activitynames

0 commit comments

Comments
 (0)