android:text="@integer/duration_default"
android:textSize="30dp"/>
</LinearLayout>
- <CheckBox
+ <CheckBox
android:id="@+id/placebo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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"/>
<string name="duration_label">test duration (mins): </string>
<string name="start">  Start  </string>
<string name="stop">  Stop  </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>
* @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) {
int numMetrics = 0;
for (int i = 0; i < replication; i++) {
// metrics
- for (EventMetric metric : mTemplate.getEventMetricList()) {
- addEventMetric(metric, i, config);
- numMetrics++;
+ if (includeEvent) {
+ for (EventMetric metric : mTemplate.getEventMetricList()) {
+ addEventMetric(metric, i, config);
+ numMetrics++;
+ }
}
- for (CountMetric metric : mTemplate.getCountMetricList()) {
- addCountMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeCount) {
+ for (CountMetric metric : mTemplate.getCountMetricList()) {
+ addCountMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (DurationMetric metric : mTemplate.getDurationMetricList()) {
- addDurationMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeDuration) {
+ for (DurationMetric metric : mTemplate.getDurationMetricList()) {
+ addDurationMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (GaugeMetric metric : mTemplate.getGaugeMetricList()) {
- addGaugeMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeGauge) {
+ for (GaugeMetric metric : mTemplate.getGaugeMetricList()) {
+ addGaugeMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (ValueMetric metric : mTemplate.getValueMetricList()) {
- addValueMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeValue) {
+ for (ValueMetric metric : mTemplate.getValueMetricList()) {
+ addValueMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
// predicates
for (Predicate predicate : mTemplate.getPredicateList()) {
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;
*/
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;
initPeriod();
initDuration();
initPlacebo();
+ initMetricWhitelist();
// Hide the keyboard outside edit texts.
findViewById(R.id.outside).setOnTouchListener(new View.OnTouchListener() {
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;
}
}
});
}
+
+ 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();
+ }
}