Skip to content

Commit

Permalink
Fix t_test usage stats
Browse files Browse the repository at this point in the history
Adds missing t_test usage stats to XContent output.

Fixes elastic#54744
  • Loading branch information
imotov committed Apr 3, 2020
1 parent da531f4 commit 61e7d7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,22 @@ public TransportAnalyticsStatsAction action(AnalyticsUsage usage) {
new ActionFilters(Collections.emptySet()), usage);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/54744")
public void test() throws IOException {
AnalyticsUsage.Item item = randomFrom(AnalyticsUsage.Item.values());
AnalyticsUsage realUsage = new AnalyticsUsage();
AnalyticsUsage emptyUsage = new AnalyticsUsage();
ContextParser<Void, Void> parser = realUsage.track(item, (p, c) -> c);
ObjectPath unused = run(realUsage, emptyUsage);
assertThat(unused.evaluate("stats.0." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
assertThat(unused.evaluate("stats.1." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
int count = between(1, 10000);
for (int i = 0; i < count; i++) {
assertNull(parser.parse(null, null));
for (AnalyticsUsage.Item item : AnalyticsUsage.Item.values()) {
AnalyticsUsage realUsage = new AnalyticsUsage();
AnalyticsUsage emptyUsage = new AnalyticsUsage();
ContextParser<Void, Void> parser = realUsage.track(item, (p, c) -> c);
ObjectPath unused = run(realUsage, emptyUsage);
assertThat(unused.evaluate("stats.0." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
assertThat(unused.evaluate("stats.1." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
int count = between(1, 10000);
for (int i = 0; i < count; i++) {
assertNull(parser.parse(null, null));
}
ObjectPath used = run(realUsage, emptyUsage);
assertThat(item.name(), used.evaluate("stats.0." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(count));
assertThat(item.name(), used.evaluate("stats.1." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
}
ObjectPath used = run(realUsage, emptyUsage);
assertThat(used.evaluate("stats.0." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(count));
assertThat(used.evaluate("stats.1." + item.name().toLowerCase(Locale.ROOT) + "_usage"), equalTo(0));
}

private ObjectPath run(AnalyticsUsage... nodeUsages) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static class NodeResponse extends BaseNodeResponse implements ToXContentO
static final ParseField CUMULATIVE_CARDINALITY_USAGE = new ParseField("cumulative_cardinality_usage");
static final ParseField STRING_STATS_USAGE = new ParseField("string_stats_usage");
static final ParseField TOP_METRICS_USAGE = new ParseField("top_metrics_usage");
static final ParseField T_TEST_USAGE = new ParseField("t_test_usage");

private final long boxplotUsage;
private final long cumulativeCardinalityUsage;
Expand Down Expand Up @@ -176,6 +177,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field(CUMULATIVE_CARDINALITY_USAGE.getPreferredName(), cumulativeCardinalityUsage);
builder.field(STRING_STATS_USAGE.getPreferredName(), stringStatsUsage);
builder.field(TOP_METRICS_USAGE.getPreferredName(), topMetricsUsage);
builder.field(T_TEST_USAGE.getPreferredName(), ttestUsage);
builder.endObject();
return builder;
}
Expand Down

0 comments on commit 61e7d7c

Please sign in to comment.