Host-Driven Metrics Collector

Host-driven metrics collectors run on the host and not on the device side. They interact with the device from the host side to collect the metrics they are targeting.

Metrics collector design

The base class that all collectors will extend is BaseDeviceMetricCollector, which helps provide the same shared basic functionalities:

  • Filtering
  • Disabling
  • Collection on test cases vs. test runs

Collectors follow a result reporter model since they synchronize with the test execution on the host. In other words, if tests are host-driven, collectors will be executed before the test proceeds to the next execution step.

For example, if the collector executes on testEnded, before the execution proceeds to the next test with testStart the collector(s) will execute.

Implement a host-driven metrics collector

When implementing on top of the base class BaseDeviceMetricCollector you may decide when you would like to collect your metrics during the lifecycle:

  • When a test run starts: onTestRunStart
  • When a test case starts: onTestStart
  • When a test case ends: onTestEnd
  • When a test run ends: onTestRunEnd

How to do asynchronous collection

In addition to the synchronous methods, TF provides a base class to implement that performs periodic asynchronous collection, ScheduledDeviceMetricCollector, which provides a collect method to be implemented that will be run periodically.

The period is customizable by options.

XML configuration

The object tag will be metrics_collector, for example:

<metrics_collector class="">
    <option name="categories" value="freq"/>


First take a look at the existing list of collectors to ensure you are not duplicating work. We try to ensure maximum reusability, so having each collector performing a single type of collection allows more mixing and matching of different collectors during test execution.