File: glean_for_legacy_scalars.md

package info (click to toggle)
firefox 142.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,591,884 kB
  • sloc: cpp: 7,451,570; javascript: 6,392,463; ansic: 3,712,584; python: 1,388,569; xml: 629,223; asm: 426,919; java: 184,857; sh: 63,439; makefile: 19,150; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (41 lines) | stat: -rw-r--r-- 2,200 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Using Firefox on Glean to Record Legacy Telemetry Scalars

To record Legacy Telemetry scalars using Glean APIs, you need these two things:

1. A Glean metric definition to generate a Glean API
    * This will go in a `metrics.yaml` file [likely in your component][new-metrics-yaml]
    * The specific Glean metric you will use depends on how you record your data.
      We have prepared [this guide][migrate-scalars] to help you out.
    * If you already know of a Legacy Telemetry scalar definition similar to what you want,
      you can use `./mach gifft <Legacy Telemetry scalar name like browser.backup.enabled>`
      to generate a Glean metric definition from that Legacy Telemetry scalar definition.
2. A Legacy Telemetry scalar definition, for the [Glean Interface For Firefox Telemetry][gifft] to mirror to
    * Place it in `toolkit/components/telemetry/Scalars.yaml`
    * Be sure to add the `telemetry_mirror` property to the Glean metric
      definition from step 1. The value to use for `telemetry_mirror` is
      [a straightforward conjugation of the scalar's category and name][legacy-enum-name].

Now build Firefox.

To record data to your new scalar,
use [the Glean API for the Glean metric you defined in Step 1][glean-metrics-docs].

To test your new scalar, use the Glean `testGetValue()` API.

Your Legacy Telemetry scalar will appear in `about:telemetry`
when your code is triggered as confirmation this is all working as you expect.

## Artifact Build Support

Firefox on Glean supports artifact builds,
so you can instrument and test your Glean instrumentation with an artifact build.
However, mirroring requires use of the Legacy Telemetry's C++ enums,
which means that testing the Legacy Telemetry scalar or seeing its value in `about:telemetry`
[requires a full, compiled build][artifact-support-gifft].

[new-metrics-yaml]: ./new_definitions_file.md#where-do-i-define-new-metrics-and-pings
[migrate-scalars]: ./migration.md#scalars
[gifft]: ./gifft.md
[legacy-enum-name]: ./gifft.md#the-telemetry_mirror-property-in-metricsyaml
[glean-metrics-docs]: https://mozilla.github.io/glean/book/reference/metrics/
[artifact-support-gifft]: ./gifft.md#artifact-build-support