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:
- 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
may decide when you would like to collect your metrics during the lifecycle:
- When a test run starts:
- When a test case starts:
- When a test case ends:
- When a test run ends:
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
The period is customizable by options.
The object tag will be
metrics_collector, for example:
<metrics_collector class="com.android.tradefed.device.metric.AtraceCollector"> <option name="categories" value="freq"/> </metrics_collector>
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.