File: glean_for_legacy_scalars.md

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (38 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download | duplicates (3)
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
# 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]
    * 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
[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