Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25f5d017 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Modify Loadtest app to be able to exclude certain metric types."

parents bd8d1a53 0d7d4d4f
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -144,6 +144,47 @@
            android:text="@string/placebo"
            android:checked="false" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <CheckBox
                android:id="@+id/include_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/count"
                android:checked="true"/>
            <CheckBox
                android:id="@+id/include_duration"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/duration"
                android:checked="true"/>
            <CheckBox
                android:id="@+id/include_event"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/event"
                android:checked="true"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <CheckBox
                android:id="@+id/include_value"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/value"
                android:checked="true"/>
            <CheckBox
                android:id="@+id/include_gauge"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/gauge"
                android:checked="true"/>
        </LinearLayout>

        <Space
            android:layout_width="1dp"
            android:layout_height="30dp"/>
+5 −0
Original line number Diff line number Diff line
@@ -26,5 +26,10 @@
    <string name="duration_label">test duration (mins):&#160;</string>
    <string name="start"> &#160;Start&#160; </string>
    <string name="stop"> &#160;Stop&#160; </string>
    <string name="count"> count </string>
    <string name="duration"> duration </string>
    <string name="event"> event </string>
    <string name="value"> value </string>
    <string name="gauge"> gauge </string>

</resources>
+28 −16
Original line number Diff line number Diff line
@@ -83,7 +83,9 @@ public class ConfigFactory {
     * @param placebo If true, only return an empty config
     * @return The serialized config
     */
  public byte[] getConfig(int replication, long bucketMillis, boolean placebo) {
  public byte[] getConfig(int replication, long bucketMillis, boolean placebo, boolean includeCount,
                          boolean includeDuration, boolean includeEvent, boolean includeValue,
                          boolean includeGauge) {
        StatsdConfig.Builder config = StatsdConfig.newBuilder()
            .setName(CONFIG_NAME);
        if (placebo) {
@@ -92,26 +94,36 @@ public class ConfigFactory {
        int numMetrics = 0;
        for (int i = 0; i < replication; i++) {
            // metrics
            if (includeEvent) {
                for (EventMetric metric : mTemplate.getEventMetricList()) {
                    addEventMetric(metric, i, config);
                    numMetrics++;
                }
            }
            if (includeCount) {
                for (CountMetric metric : mTemplate.getCountMetricList()) {
                    addCountMetric(metric, i, bucketMillis, config);
                    numMetrics++;
                }
            }
            if (includeDuration) {
                for (DurationMetric metric : mTemplate.getDurationMetricList()) {
                    addDurationMetric(metric, i, bucketMillis, config);
                    numMetrics++;
                }
            }
            if (includeGauge) {
                for (GaugeMetric metric : mTemplate.getGaugeMetricList()) {
                    addGaugeMetric(metric, i, bucketMillis, config);
                    numMetrics++;
                }
            }
            if (includeValue) {
                for (ValueMetric metric : mTemplate.getValueMetricList()) {
                    addValueMetric(metric, i, bucketMillis, config);
                    numMetrics++;
                }
            }
            // predicates
            for (Predicate predicate : mTemplate.getPredicateList()) {
              addPredicate(predicate, i, config);
+78 −1
Original line number Diff line number Diff line
@@ -110,6 +110,11 @@ public class LoadtestActivity extends Activity {
    private EditText mDurationText;
    private TextView mReportText;
    private CheckBox mPlaceboCheckBox;
    private CheckBox mCountMetricCheckBox;
    private CheckBox mDurationMetricCheckBox;
    private CheckBox mEventMetricCheckBox;
    private CheckBox mValueMetricCheckBox;
    private CheckBox mGaugeMetricCheckBox;

    /** When the load test started. */
    private long mStartedTimeMillis;
@@ -129,6 +134,31 @@ public class LoadtestActivity extends Activity {
     */
    private boolean mPlacebo;

    /**
     * Whether to include CountMetric in the config.
     */
    private boolean mIncludeCountMetric;

    /**
     * Whether to include DurationMetric in the config.
     */
    private boolean mIncludeDurationMetric;

    /**
     * Whether to include EventMetric in the config.
     */
    private boolean mIncludeEventMetric;

    /**
     * Whether to include ValueMetric in the config.
     */
    private boolean mIncludeValueMetric;

    /**
     * Whether to include GaugeMetric in the config.
     */
    private boolean mIncludeGaugeMetric;

    /** The burst size. */
    private int mBurst;

@@ -170,6 +200,7 @@ public class LoadtestActivity extends Activity {
        initPeriod();
        initDuration();
        initPlacebo();
        initMetricWhitelist();

        // Hide the keyboard outside edit texts.
        findViewById(R.id.outside).setOnTouchListener(new View.OnTouchListener() {
@@ -329,7 +360,9 @@ public class LoadtestActivity extends Activity {
        getData();

        // Create a config and push it to statsd.
        if (!setConfig(mFactory.getConfig(mReplication, mBucketMins * 60 * 1000, mPlacebo))) {
        if (!setConfig(mFactory.getConfig(mReplication, mBucketMins * 60 * 1000, mPlacebo,
                mIncludeCountMetric, mIncludeDurationMetric, mIncludeEventMetric,
                mIncludeValueMetric, mIncludeGaugeMetric))) {
            return;
        }

@@ -548,4 +581,48 @@ public class LoadtestActivity extends Activity {
            }
        });
    }

    private void initMetricWhitelist() {
        mCountMetricCheckBox = findViewById(R.id.include_count);
        mCountMetricCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mIncludeCountMetric = mCountMetricCheckBox.isChecked();
            }
        });
        mDurationMetricCheckBox = findViewById(R.id.include_duration);
        mDurationMetricCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mIncludeDurationMetric = mDurationMetricCheckBox.isChecked();
            }
        });
        mEventMetricCheckBox = findViewById(R.id.include_event);
        mEventMetricCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mIncludeEventMetric = mEventMetricCheckBox.isChecked();
            }
        });
        mValueMetricCheckBox = findViewById(R.id.include_value);
        mValueMetricCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mIncludeValueMetric = mValueMetricCheckBox.isChecked();
            }
        });
        mGaugeMetricCheckBox = findViewById(R.id.include_gauge);
        mGaugeMetricCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mIncludeGaugeMetric = mGaugeMetricCheckBox.isChecked();
            }
        });

        mIncludeCountMetric = mCountMetricCheckBox.isChecked();
        mIncludeDurationMetric = mDurationMetricCheckBox.isChecked();
        mIncludeEventMetric = mEventMetricCheckBox.isChecked();
        mIncludeValueMetric = mValueMetricCheckBox.isChecked();
        mIncludeGaugeMetric = mGaugeMetricCheckBox.isChecked();
    }
}