Skip to content

Commit 150843f

Browse files
[8.x] ES|QL: make telemetry more strict (#126940) (#126981)
* ES|QL: make telemetry more strict (#126940) * Fix compile * Fix tests * Fix test
1 parent 04cb4e7 commit 150843f

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

docs/reference/rest-api/usage.asciidoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ GET /_xpack/usage
243243
"keep" : 0,
244244
"enrich" : 0,
245245
"from" : 0,
246-
"row" : 0
246+
"row" : 0,
247+
"lookup" : 0,
248+
"inlinestats" : 0,
249+
"lookup_join" : 0,
250+
"change_point" : 0
247251
},
248252
"queries" : {
249253
"rest" : {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/telemetry/FeatureMetric.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,33 @@
77

88
package org.elasticsearch.xpack.esql.telemetry;
99

10+
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
1011
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
12+
import org.elasticsearch.xpack.esql.plan.logical.ChangePoint;
1113
import org.elasticsearch.xpack.esql.plan.logical.Dissect;
1214
import org.elasticsearch.xpack.esql.plan.logical.Drop;
1315
import org.elasticsearch.xpack.esql.plan.logical.Enrich;
1416
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
1517
import org.elasticsearch.xpack.esql.plan.logical.Eval;
1618
import org.elasticsearch.xpack.esql.plan.logical.Filter;
1719
import org.elasticsearch.xpack.esql.plan.logical.Grok;
20+
import org.elasticsearch.xpack.esql.plan.logical.InlineStats;
1821
import org.elasticsearch.xpack.esql.plan.logical.Keep;
22+
import org.elasticsearch.xpack.esql.plan.logical.Limit;
1923
import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan;
24+
import org.elasticsearch.xpack.esql.plan.logical.Lookup;
2025
import org.elasticsearch.xpack.esql.plan.logical.MvExpand;
2126
import org.elasticsearch.xpack.esql.plan.logical.OrderBy;
27+
import org.elasticsearch.xpack.esql.plan.logical.Project;
2228
import org.elasticsearch.xpack.esql.plan.logical.Rename;
2329
import org.elasticsearch.xpack.esql.plan.logical.Row;
30+
import org.elasticsearch.xpack.esql.plan.logical.UnresolvedRelation;
31+
import org.elasticsearch.xpack.esql.plan.logical.join.LookupJoin;
32+
import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject;
2433
import org.elasticsearch.xpack.esql.plan.logical.show.ShowInfo;
2534

2635
import java.util.BitSet;
36+
import java.util.List;
2737
import java.util.Locale;
2838
import java.util.function.Predicate;
2939

@@ -42,7 +52,21 @@ public enum FeatureMetric {
4252
FROM(EsRelation.class::isInstance),
4353
DROP(Drop.class::isInstance),
4454
KEEP(Keep.class::isInstance),
45-
RENAME(Rename.class::isInstance);
55+
RENAME(Rename.class::isInstance),
56+
LOOKUP_JOIN(LookupJoin.class::isInstance),
57+
LOOKUP(Lookup.class::isInstance),
58+
CHANGE_POINT(ChangePoint.class::isInstance),
59+
INLINESTATS(InlineStats.class::isInstance);
60+
61+
/**
62+
* List here plans we want to exclude from telemetry
63+
*/
64+
private static final List<Class<? extends LogicalPlan>> excluded = List.of(
65+
UnresolvedRelation.class,
66+
EsqlProject.class,
67+
Project.class,
68+
Limit.class // LIMIT is managed in another way, see above
69+
);
4670

4771
private Predicate<LogicalPlan> planCheck;
4872

@@ -61,6 +85,13 @@ public static void set(LogicalPlan plan, BitSet bitset) {
6185
return;
6286
}
6387
}
88+
if (explicitlyExcluded(plan) == false) {
89+
throw new EsqlIllegalArgumentException("Command not mapped for telemetry [{}]", plan.getClass().getSimpleName());
90+
}
91+
}
92+
93+
private static boolean explicitlyExcluded(LogicalPlan plan) {
94+
return excluded.stream().anyMatch(x -> x.isInstance(plan));
6495
}
6596

6697
public static boolean set(LogicalPlan plan, BitSet bitset, FeatureMetric metric) {

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ setup:
3737
- do: {xpack.usage: {}}
3838
- match: { esql.available: true }
3939
- match: { esql.enabled: true }
40-
- length: { esql.features: 15 }
40+
- length: { esql.features: 19 }
4141
- set: {esql.features.dissect: dissect_counter}
4242
- set: {esql.features.drop: drop_counter}
4343
- set: {esql.features.eval: eval_counter}
@@ -53,6 +53,10 @@ setup:
5353
- set: {esql.features.sort: sort_counter}
5454
- set: {esql.features.stats: stats_counter}
5555
- set: {esql.features.where: where_counter}
56+
- set: {esql.features.lookup_join: lookup_join_counter}
57+
- set: {esql.features.lookup: lookup_counter}
58+
- set: {esql.features.change_point: change_point_counter}
59+
- set: {esql.features.inlinestats: inlinestats_counter}
5660
- length: { esql.queries: 3 }
5761
- set: {esql.queries.rest.total: rest_total_counter}
5862
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -81,6 +85,10 @@ setup:
8185
- gt: {esql.features.sort: $sort_counter}
8286
- gt: {esql.features.stats: $stats_counter}
8387
- gt: {esql.features.where: $where_counter}
88+
- match: {esql.features.lookup_join: $lookup_join_counter}
89+
- match: {esql.features.lookup: $lookup_counter}
90+
- match: {esql.features.change_point: $change_point_counter}
91+
- match: {esql.features.inlinestats: $inlinestats_counter}
8492
- gt: {esql.queries.rest.total: $rest_total_counter}
8593
- match: {esql.queries.rest.failed: $rest_failed_counter}
8694
- match: {esql.queries.kibana.total: $kibana_total_counter}
@@ -109,7 +117,7 @@ setup:
109117
- do: {xpack.usage: {}}
110118
- match: { esql.available: true }
111119
- match: { esql.enabled: true }
112-
- length: { esql.features: 15 }
120+
- length: { esql.features: 19 }
113121
- set: {esql.features.dissect: dissect_counter}
114122
- set: {esql.features.drop: drop_counter}
115123
- set: {esql.features.eval: eval_counter}
@@ -125,6 +133,10 @@ setup:
125133
- set: {esql.features.sort: sort_counter}
126134
- set: {esql.features.stats: stats_counter}
127135
- set: {esql.features.where: where_counter}
136+
- set: {esql.features.lookup_join: lookup_join_counter}
137+
- set: {esql.features.lookup: lookup_counter}
138+
- set: {esql.features.change_point: change_point_counter}
139+
- set: {esql.features.inlinestats: inlinestats_counter}
128140
- length: { esql.queries: 3 }
129141
- set: {esql.queries.rest.total: rest_total_counter}
130142
- set: {esql.queries.rest.failed: rest_failed_counter}
@@ -153,6 +165,10 @@ setup:
153165
- gt: {esql.features.sort: $sort_counter}
154166
- gt: {esql.features.stats: $stats_counter}
155167
- gt: {esql.features.where: $where_counter}
168+
- match: {esql.features.lookup_join: $lookup_join_counter}
169+
- match: {esql.features.lookup: $lookup_counter}
170+
- match: {esql.features.change_point: $change_point_counter}
171+
- match: {esql.features.inlinestats: $inlinestats_counter}
156172
- gt: {esql.queries.rest.total: $rest_total_counter}
157173
- match: {esql.queries.rest.failed: $rest_failed_counter}
158174
- match: {esql.queries.kibana.total: $kibana_total_counter}

0 commit comments

Comments
 (0)