SQL: Extend the ODBC metric by differentiating between 32 and 64bit platforms (#36753)
* The "overall" ODBC metric will now track a total of requests between 32bit and 64bit ODBC metrics, being calculated passively, upon request.
This commit is contained in:
parent
9087c98a5a
commit
4bc9bffb4d
|
@ -38,7 +38,7 @@ public abstract class RestSqlUsageTestCase extends ESRestTestCase {
|
||||||
);
|
);
|
||||||
|
|
||||||
private enum ClientType {
|
private enum ClientType {
|
||||||
CANVAS, CLI, JDBC, ODBC, REST;
|
CANVAS, CLI, JDBC, ODBC, ODBC32, ODBC64, REST;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -84,7 +84,7 @@ public abstract class RestSqlUsageTestCase extends ESRestTestCase {
|
||||||
baseMetrics.put(metric.toString(), (Integer) featuresMetrics.get(metric.toString()));
|
baseMetrics.put(metric.toString(), (Integer) featuresMetrics.get(metric.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the "base" metric values with whatever values are already recorder on ES
|
// initialize the "base" metric values with whatever values are already recorded on ES
|
||||||
baseClientTypeTotalQueries = ((Map<String,Integer>) queriesMetrics.get(clientType)).get("total");
|
baseClientTypeTotalQueries = ((Map<String,Integer>) queriesMetrics.get(clientType)).get("total");
|
||||||
baseClientTypeFailedQueries = ((Map<String,Integer>) queriesMetrics.get(clientType)).get("failed");
|
baseClientTypeFailedQueries = ((Map<String,Integer>) queriesMetrics.get(clientType)).get("failed");
|
||||||
baseAllTotalQueries = ((Map<String,Integer>) queriesMetrics.get("_all")).get("total");
|
baseAllTotalQueries = ((Map<String,Integer>) queriesMetrics.get("_all")).get("total");
|
||||||
|
@ -252,8 +252,14 @@ public abstract class RestSqlUsageTestCase extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runSql(String sql) throws IOException {
|
private void runSql(String sql) throws IOException {
|
||||||
String mode = (clientType.equals(ClientType.JDBC.toString()) || clientType.equals(ClientType.ODBC.toString())) ?
|
String mode = Mode.PLAIN.toString();
|
||||||
clientType.toString() : Mode.PLAIN.toString();
|
if (clientType.equals(ClientType.JDBC.toString())) {
|
||||||
|
mode = Mode.JDBC.toString();
|
||||||
|
}
|
||||||
|
if (clientType.startsWith(ClientType.ODBC.toString())) {
|
||||||
|
mode = Mode.ODBC.toString();
|
||||||
|
}
|
||||||
|
|
||||||
runSql(mode, clientType, sql);
|
runSql(mode, clientType, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,34 @@
|
||||||
|
|
||||||
package org.elasticsearch.xpack.sql.proto;
|
package org.elasticsearch.xpack.sql.proto;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class RequestInfo {
|
public class RequestInfo {
|
||||||
public static final String CLI = "cli";
|
public static final String CLI = "cli";
|
||||||
private static final String CANVAS = "canvas";
|
private static final String CANVAS = "canvas";
|
||||||
public static final List<String> CLIENT_IDS = Arrays.asList(CLI, CANVAS);
|
public static final String ODBC_32 = "odbc32";
|
||||||
|
private static final String ODBC_64 = "odbc64";
|
||||||
|
public static final Set<String> CLIENT_IDS;
|
||||||
|
public static final Set<String> ODBC_CLIENT_IDS;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Set<String> clientIds = new HashSet<>(4);
|
||||||
|
clientIds.add(CLI);
|
||||||
|
clientIds.add(CANVAS);
|
||||||
|
clientIds.add(ODBC_32);
|
||||||
|
clientIds.add(ODBC_64);
|
||||||
|
|
||||||
|
Set<String> odbcClientIds = new HashSet<>(2);
|
||||||
|
odbcClientIds.add(ODBC_32);
|
||||||
|
odbcClientIds.add(ODBC_64);
|
||||||
|
|
||||||
|
CLIENT_IDS = Collections.unmodifiableSet(clientIds);
|
||||||
|
ODBC_CLIENT_IDS = Collections.unmodifiableSet(odbcClientIds);
|
||||||
|
}
|
||||||
|
|
||||||
private Mode mode;
|
private Mode mode;
|
||||||
private String clientId;
|
private String clientId;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class RestSqlQueryAction extends BaseRestHandler {
|
||||||
SqlQueryRequest sqlRequest;
|
SqlQueryRequest sqlRequest;
|
||||||
try (XContentParser parser = request.contentOrSourceParamParser()) {
|
try (XContentParser parser = request.contentOrSourceParamParser()) {
|
||||||
sqlRequest = SqlQueryRequest.fromXContent(parser);
|
sqlRequest = SqlQueryRequest.fromXContent(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we support {@link TextFormat} <strong>and</strong>
|
* Since we support {@link TextFormat} <strong>and</strong>
|
||||||
|
|
|
@ -15,6 +15,9 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import static org.elasticsearch.xpack.sql.proto.RequestInfo.ODBC_CLIENT_IDS;
|
||||||
|
import static org.elasticsearch.xpack.sql.stats.QueryMetric.ODBC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class encapsulating the metrics collected for ES SQL
|
* Class encapsulating the metrics collected for ES SQL
|
||||||
*/
|
*/
|
||||||
|
@ -101,9 +104,18 @@ public class Metrics {
|
||||||
|
|
||||||
// queries metrics
|
// queries metrics
|
||||||
for (Entry<QueryMetric, Map<OperationType, CounterMetric>> entry : opsByTypeMetrics.entrySet()) {
|
for (Entry<QueryMetric, Map<OperationType, CounterMetric>> entry : opsByTypeMetrics.entrySet()) {
|
||||||
|
String metricName = entry.getKey().toString();
|
||||||
|
|
||||||
for (OperationType type : OperationType.values()) {
|
for (OperationType type : OperationType.values()) {
|
||||||
counters.inc(QPREFIX + entry.getKey().toString() + "." + type.toString(), entry.getValue().get(type).count());
|
long metricCounter = entry.getValue().get(type).count();
|
||||||
counters.inc(QPREFIX + "_all." + type.toString(), entry.getValue().get(type).count());
|
String operationTypeName = type.toString();
|
||||||
|
|
||||||
|
counters.inc(QPREFIX + metricName + "." + operationTypeName, metricCounter);
|
||||||
|
counters.inc(QPREFIX + "_all." + operationTypeName, metricCounter);
|
||||||
|
// compute the ODBC total metric
|
||||||
|
if (ODBC_CLIENT_IDS.contains(metricName)) {
|
||||||
|
counters.inc(QPREFIX + ODBC.toString() + "." + operationTypeName, metricCounter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
package org.elasticsearch.xpack.sql.stats;
|
package org.elasticsearch.xpack.sql.stats;
|
||||||
|
|
||||||
import org.elasticsearch.xpack.sql.proto.Mode;
|
import org.elasticsearch.xpack.sql.proto.Mode;
|
||||||
|
import org.elasticsearch.xpack.sql.proto.RequestInfo;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import static org.elasticsearch.xpack.sql.proto.RequestInfo.ODBC_CLIENT_IDS;
|
||||||
|
|
||||||
public enum QueryMetric {
|
public enum QueryMetric {
|
||||||
CANVAS, CLI, JDBC, ODBC, REST;
|
CANVAS, CLI, JDBC, ODBC, ODBC32, ODBC64, REST;
|
||||||
|
|
||||||
public static QueryMetric fromString(String metric) {
|
public static QueryMetric fromString(String metric) {
|
||||||
try {
|
try {
|
||||||
|
@ -27,6 +29,14 @@ public enum QueryMetric {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QueryMetric from(Mode mode, String clientId) {
|
public static QueryMetric from(Mode mode, String clientId) {
|
||||||
|
if (mode == Mode.ODBC) {
|
||||||
|
// default to "odbc_32" if the client_id is not provided or it has a wrong value
|
||||||
|
if (clientId == null || false == ODBC_CLIENT_IDS.contains(clientId)) {
|
||||||
|
return fromString(RequestInfo.ODBC_32);
|
||||||
|
} else {
|
||||||
|
return fromString(clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
return fromString(mode == Mode.PLAIN ? clientId : mode.toString());
|
return fromString(mode == Mode.PLAIN ? clientId : mode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue