Closed Bug 1654074 Opened 6 months ago Closed 4 months ago

Expose Glean telemetry to mach subcommands

Categories

(Firefox Build System :: General, enhancement)

enhancement

Tracking

(firefox81 fixed, firefox82 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed
firefox82 --- fixed

People

(Reporter: mhentges, Assigned: mhentges)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

  • Add ability for subcommands to define and report custom metrics
  • Add docs for how to setup and use telemetry as a subcommand
  • Update Glean docs generation to use all registered metrics files

Fortunately, it appears like Glean allows us to pick and choose which set of metrics we want to report at runtime.
So, this allows us to expose a correctly-scoped set of metrics to each subcommand. For example:

| mach (top-level)
| ================
| mach_metrics = glean.load_metrics("<mach's metrics.yaml>")
| report_mach_metrics(mach_metrics)
|-------------------------------------------------------------------
|>>| mach python-test (subcommand)
|>>| =============================
|>>| pt_metrics = glean.load_metrics("<python-test's metrics.yaml>")
|>>| report_python_test_metrics(pt_metrics)
|>>| ...
|-------------------------------------------------------------------
| mach_metrics.command.duration.stop()
| mach_metrics.command.success.set(<True|False>)
| pings.usage.submit() # Submits both mach_metrics and pt_metrics
Blocks: buildmetrics
Component: Mach Core → General
Assignee: nobody → mhentges

@CommandProvider does parameter validation and collects information (such
as "pass_context") that will be needed by Registrar.

However, rather than just checking parameter length, we can make it more
specific and assert that the specific expected parameter ("context") exists.

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4eaef350187e
Make @CommandProvider validation more specific r=firefox-build-system-reviewers,rstewart
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Status: RESOLVED → UNCONFIRMED
Ever confirmed: false
Resolution: FIXED → ---

Allows mach commands to define their own glean metrics with the metrics_path @CommandProvider parameter.
When metrics_path is defined:

  • A metrics kwarg is provided to the decorated class. This metrics handle is a Glean instance,
    so Glean documentation should be consulted for usage
  • When mach doc telemetry is run, metrics docs will be generated from all the registered metrics files.

Note: there was some consideration between making metrics_path a @CommandProvider or @Command parameter.
In the end, @CommandProvider seemed like a better fit because:

  • Metrics seem to be more associated with the entire class than a specific command/method. This is because
    a class represents a "domain", and that domain may have different commands that have overlapping metrics.
    Accordingly, all the metrics should be defined once as available to the entire class.
  • Currently, @Command methods only take parameters that map one-to-one with CLI arguments. It could seem
    inconsistent to have one exception: the metrics handle

Depends on D83572

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/92cacd2f7294
Publish glean handle to mach commands r=firefox-build-system-reviewers,rstewart
Status: UNCONFIRMED → RESOLVED
Closed: 6 months ago4 months ago
Resolution: --- → FIXED
Regressions: 1666873
You need to log in before you can comment on or make changes to this bug.