Skip to content

Commit 0ac116e

Browse files
committed
Pull feedback
1 parent 8ea56da commit 0ac116e

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

docs/reference/cluster/stats.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ This may include requests where partial results were returned, but not requests
15241524

15251525
======
15261526
`_esql`:::
1527-
(object) Contains the information about the ES|QL <<esql-cross-clusters,cross-cluster queries>> usage in the cluster.
1527+
(object) Contains the information about the ES|QL <<esql-cross-clusters,{ccs}>> usage in the cluster.
15281528
The structure of the object is the same as the `_search` object above.
15291529
15301530
=====

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static TransportVersion def(int id) {
146146
public static final TransportVersion ERROR_TRACE_IN_TRANSPORT_HEADER = def(8_811_00_0);
147147
public static final TransportVersion FAILURE_STORE_ENABLED_BY_CLUSTER_SETTING = def(8_812_00_0);
148148
public static final TransportVersion SIMULATE_IGNORED_FIELDS = def(8_813_00_0);
149-
public static final TransportVersion ESQL_TELEMETRY_STATS = def(8_814_00_0);
149+
public static final TransportVersion ESQL_CCS_TELEMETRY_STATS = def(8_814_00_0);
150150

151151
/*
152152
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/CCSTelemetrySnapshot.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public final class CCSTelemetrySnapshot implements Writeable, ToXContentFragment
6565

6666
private final Map<String, Long> clientCounts;
6767
private final Map<String, PerClusterCCSTelemetry> byRemoteCluster;
68+
// Whether we should use per-MRT (minimize roundtrips) metrics.
69+
// ES|QL does not have "minimize_roundtrips" option, so we don't collect those metrics for ES|QL usage.
6870
private boolean useMRT = true;
6971

7072
/**

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/CCSUsage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public static Result getFailureType(Exception e) {
144144
if (ExceptionsHelper.unwrapCorruption(e) != null) {
145145
return Result.CORRUPTION;
146146
}
147-
if (ExceptionsHelper.unwrap(e, ElasticsearchStatusException.class) != null) {
147+
ElasticsearchStatusException se = (ElasticsearchStatusException) ExceptionsHelper.unwrap(e, ElasticsearchStatusException.class);
148+
if (se != null && se.getDetailedMessage().contains("license")) {
148149
return Result.LICENSE;
149150
}
150151
// This is kind of last resort check - if we still don't know the reason but all shard failures are remote,

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsNodeResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public ClusterStatsNodeResponse(StreamInput in) throws IOException {
5252
repositoryUsageStats = RepositoryUsageStats.EMPTY;
5353
ccsMetrics = new CCSTelemetrySnapshot();
5454
}
55-
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_TELEMETRY_STATS)) {
55+
if (in.getTransportVersion().onOrAfter(TransportVersions.ESQL_CCS_TELEMETRY_STATS)) {
5656
esqlMetrics = new CCSTelemetrySnapshot(in);
5757
} else {
5858
esqlMetrics = new CCSTelemetrySnapshot();
@@ -131,7 +131,7 @@ public void writeTo(StreamOutput out) throws IOException {
131131
repositoryUsageStats.writeTo(out);
132132
ccsMetrics.writeTo(out);
133133
} // else just drop these stats, ok for bwc
134-
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_TELEMETRY_STATS)) {
134+
if (out.getTransportVersion().onOrAfter(TransportVersions.ESQL_CCS_TELEMETRY_STATS)) {
135135
esqlMetrics.writeTo(out);
136136
}
137137
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ private void recordCCSTelemetry(Task task, EsqlExecutionInfo executionInfo, Esql
225225
CCSUsage.Builder usageBuilder = new CCSUsage.Builder();
226226
usageBuilder.setClientFromTask(task);
227227
if (exception != null) {
228-
if (exception instanceof VerificationException) {
229-
CCSUsageTelemetry.Result failureType = classifyVerificationException((VerificationException) exception);
228+
if (exception instanceof VerificationException ve) {
229+
CCSUsageTelemetry.Result failureType = classifyVerificationException(ve);
230230
if (failureType != CCSUsageTelemetry.Result.UNKNOWN) {
231231
usageBuilder.setFailure(failureType);
232232
} else {
@@ -244,19 +244,19 @@ private void recordCCSTelemetry(Task task, EsqlExecutionInfo executionInfo, Esql
244244
usageBuilder.setFeature(CCSUsageTelemetry.ASYNC_FEATURE);
245245
}
246246

247-
AtomicInteger count = new AtomicInteger();
247+
AtomicInteger remotesCount = new AtomicInteger();
248248
executionInfo.getClusters().forEach((clusterAlias, cluster) -> {
249249
if (cluster.getStatus() == EsqlExecutionInfo.Cluster.Status.SKIPPED) {
250250
usageBuilder.skippedRemote(clusterAlias);
251251
} else {
252252
usageBuilder.perClusterUsage(clusterAlias, cluster.getTook());
253253
}
254254
if (clusterAlias.equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY) == false) {
255-
count.getAndIncrement();
255+
remotesCount.getAndIncrement();
256256
}
257257
});
258-
assert count.get() > 0 : "Got cross-cluster search telemetry without any remote clusters";
259-
usageBuilder.setRemotesCount(count.get());
258+
assert remotesCount.get() > 0 : "Got cross-cluster search telemetry without any remote clusters";
259+
usageBuilder.setRemotesCount(remotesCount.get());
260260
usageService.getEsqlUsageHolder().updateUsage(usageBuilder.build());
261261
}
262262

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSessionCCSUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public static void checkForCcsLicense(
328328
if (groupedIndices.size() > 1 || groupedIndices.containsKey(RemoteClusterService.LOCAL_CLUSTER_GROUP_KEY) == false) {
329329
if (EsqlLicenseChecker.isCcsAllowed(licenseState) == false) {
330330
// initialize the cluster entries in EsqlExecutionInfo before throwing the invalid license error
331-
// so that the CCS telemetry handler can recognize that this error is a CCS-related
331+
// so that the CCS telemetry handler can recognize that this error is CCS-related
332332
for (Map.Entry<String, OriginalIndices> entry : groupedIndices.entrySet()) {
333333
executionInfo.swapCluster(
334334
entry.getKey(),

0 commit comments

Comments
 (0)