Using Firefox on Glean to Record Legacy Telemetry Events
To record Legacy Telemetry events using Glean APIs, you need these two things:
A Glean event definition to generate a Glean API
This will go in a
metrics.yaml
file likely in your componentIf you’re familiar with Telemetry events, you might like to read this short section about how Glean events are different.
The Glean
event
metric docs has an example definition you might find helpful.If you already know of a Legacy Telemetry event definition similar to what you want, you can use
./mach gifft <Legacy Telemetry event name like readermode.view>
to generate a Gleanevent
metric definition from that Legacy Telemetry event definition.
A Legacy Telemetry event definition, for the Glean Interface For Firefox Telemetry to mirror to
Use
./mach event-into-legacy <Glean event metric name like privacy.sanitize.dialog_open>
to generate this automatically.Place it in
toolkit/components/telemetry/Events.yaml
Be sure to add the
telemetry_mirror
property to the Gleanevent
definition from step 1. You can follow the instructions in the output from./mach event-into-legacy
, or this guide for determining the Legacy Telemetry event’s enum name manually.
Now build Firefox.
To record your new event, use the Glean record(...)
API.
To test your new event, use the Glean testGetValue()
API.
Your Legacy Telemetry event 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 event’s C++ enum,
which means that testing the Legacy Telemetry event or seeing its value in about:telemetry
requires a full, compiled build.