From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- python/mach/docs/telemetry.rst | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 python/mach/docs/telemetry.rst (limited to 'python/mach/docs/telemetry.rst') diff --git a/python/mach/docs/telemetry.rst b/python/mach/docs/telemetry.rst new file mode 100644 index 0000000000..b55881e89b --- /dev/null +++ b/python/mach/docs/telemetry.rst @@ -0,0 +1,39 @@ +.. _mach_telemetry: + +============== +Mach Telemetry +============== + +`Glean `_ is used to collect telemetry, and uses the metrics +defined in the ``metrics.yaml`` files in-tree. +These files are all documented in a single :ref:`generated file here`. + +.. toctree:: + :maxdepth: 1 + + metrics + +Adding Metrics to a new Command +=============================== + +If you would like to submit telemetry metrics from your mach ``@Command``, you should take two steps: + +#. Parameterize your class's ``@CommandProvider`` annotation with ``metrics_path``. +#. Use the ``self.metrics`` handle provided by ``MachCommandBase`` + +For example:: + + METRICS_PATH = os.path.abspath(os.path.join(__file__, '..', '..', 'metrics.yaml')) + + @CommandProvider(metrics_path=METRICS_PATH) + class CustomCommand(MachCommandBase): + @Command('custom-command') + def custom_command(self): + self.metrics.custom.foo.set('bar') + +Updating Generated Metrics Docs +=============================== + +When a ``metrics.yaml`` is added/changed/removed, :ref:`the metrics document` will need to be updated:: + + ./mach doc mach-telemetry -- cgit v1.2.3