Debian Codegraph @

python/mach/docs/telemetry.rst

raw
1 .. _mach_telemetry:
2
3 ==============
4 Mach Telemetry
5 ==============
6
7 `Glean <https://mozilla.github.io/glean/>`_ is used to collect telemetry, and uses the metrics
8 defined in the ``metrics.yaml`` files in-tree.
9 These files are all documented in a single :ref:`generated file here<metrics>`.
10
11 .. toctree::
12 :maxdepth: 1
13
14 metrics
15
16 Adding Metrics to a new Command
17 ===============================
18
19 If you would like to submit telemetry metrics from your mach ``@Command``, you should take two steps:
20
21 #. Parameterize your ``@Command`` annotation with ``metrics_path``.
22 #. Use the ``command_context.metrics`` handle provided by ``MachCommandBase``
23
24 For example::
25
26 METRICS_PATH = os.path.abspath(os.path.join(__file__, '..', '..', 'metrics.yaml'))
27
28 @Command('custom-command', metrics_path=METRICS_PATH)
29 def custom_command(command_context):
30 command_context.metrics.custom.foo.set('bar')
31
32 Updating Generated Metrics Docs
33 ===============================
34
35 When a ``metrics.yaml`` is added/changed/removed, :ref:`the metrics document<metrics>` will need to be updated::
36
37 ./mach doc mach-telemetry