StatsdBeforeAfterGaugeMetricPostProcessor

public class StatsdBeforeAfterGaugeMetricPostProcessor
extends StatsdGenericPostProcessor

java.lang.Object
   ↳ com.android.tradefed.postprocessor.BasePostProcessor
     ↳ com.android.tradefed.postprocessor.StatsdGenericPostProcessor
       ↳ com.android.tradefed.postprocessor.StatsdBeforeAfterGaugeMetricPostProcessor


A post processor that processes gauge metrics collected in a "before/after" approach, i.e. one snapshot before a test/run and one after, pulling out metrics according to a supplied list of metric formatters and reporting their deltas.

Metrics collected this way look like the following: (metrics reside in the atoms)

 reports {
   metrics {
     gauge_metrics {
       data {
         # Bucket for the "before" snapshot
         bucket_info {
           atom {...}
           atom {...}
           ...
         }
         # Bucket for the "after" snapshot
         bucket_info {
           atom {...}
           atom {...}
           ...
         }
       }
     }
     ...
   }
   ...
 }
 

As an example, if the supplied metric formatter is on_device_power_measurement for key and [subsystem_name]-[rail_name]=[energy_microwatt_secs] for value, the metric for an atom where subsystem_name is display, rail_name is RAIL_NAME and energy_microwatt_secs is 10 will look like statsd-<config name>-gauge-on_device_power_measurement-delta-display-RAIL_NAME=10.

The before/after metrics are matched for delta calculation by their name, so it is assumed that the formatters will ensure that each snapshot generates unique metric sets within them. The processor will generate warnings in these scenarios:

  • There are duplicate metric keys generated by the formatters within each snapshot
  • An atom or metric key is present in one snapshot but not the other

Summary

Public constructors

StatsdBeforeAfterGaugeMetricPostProcessor()

Protected methods

void logFormattedWarning(String message)

Wrapper around CLog.w() that enables tests to observe the formatted warning.

parseMetricsFromReportList(StatsLog.ConfigMetricsReportList reportList)

Parse the gauge metrics from the ConfigMetricsReportList using the atom formatters.

Public constructors

StatsdBeforeAfterGaugeMetricPostProcessor

public StatsdBeforeAfterGaugeMetricPostProcessor ()

Protected methods

logFormattedWarning

protected void logFormattedWarning (String message)

Wrapper around CLog.w() that enables tests to observe the formatted warning.

Parameters
message String

parseMetricsFromReportList

protected  parseMetricsFromReportList (StatsLog.ConfigMetricsReportList reportList)

Parse the gauge metrics from the ConfigMetricsReportList using the atom formatters.

Event metrics resulting in duplicate keys will be stored as comma separated values.

Parameters
reportList StatsLog.ConfigMetricsReportList

Returns