Skip to content

Commit b4663ac

Browse files
author
Paultagoras
committed
Removing as this metric should be done at the application layer
1 parent 605d506 commit b4663ac

File tree

4 files changed

+1
-50
lines changed

4 files changed

+1
-50
lines changed

client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ public class HttpAPIClientHelper {
115115

116116
private final Set<ClientFaultCause> defaultRetryCauses;
117117

118-
private AtomicLong requestCount = new AtomicLong(0);
119-
private AtomicLong failureCount = new AtomicLong(0);
120-
121118
private String defaultUserAgent;
122119
private Object metricsRegistry;
123120
public HttpAPIClientHelper(Map<String, String> configuration, Object metricsRegistry, boolean initSslContext) {
@@ -420,7 +417,6 @@ public ClassicHttpResponse executeRequest(ClickHouseNode server, Map<String, Obj
420417
HttpClientContext context = HttpClientContext.create();
421418

422419
try {
423-
requestCount.incrementAndGet();
424420
ClassicHttpResponse httpResponse = httpClient.executeOpen(null, req, context);
425421
boolean serverCompression = MapUtils.getFlag(requestConfig, chConfiguration, ClientConfigProperties.COMPRESS_SERVER_RESPONSE.getKey());
426422
httpResponse.setEntity(wrapResponseEntity(httpResponse.getEntity(), httpResponse.getCode(), serverCompression, useHttpCompression));
@@ -446,10 +442,6 @@ public ClassicHttpResponse executeRequest(ClickHouseNode server, Map<String, Obj
446442
LOG.warn("Failed to connect to '{}': {}", server.getHost(), e.getMessage());
447443
throw new ClientException("Failed to connect", e);
448444
} catch (ConnectionRequestTimeoutException | ServerException | NoHttpResponseException | ClientException | SocketTimeoutException e) {
449-
failureCount.incrementAndGet();
450-
if (e instanceof ConnectionRequestTimeoutException || e instanceof SocketTimeoutException) {
451-
LOG.warn("Request failed with timeout: {}", req.getConfig().getConnectionRequestTimeout()); // record timeout value
452-
}
453445
throw e;
454446
} catch (Exception e) {
455447
throw new ClientException("Failed to execute request", e);
@@ -783,11 +775,6 @@ public void close() {
783775
httpClient.close(CloseMode.IMMEDIATE);
784776
}
785777

786-
787-
public long getRequestRatio() {//Metrics
788-
return requestCount.get() == 0 ? 0 : Math.round(((float) failureCount.get() / requestCount.get()) * 100);
789-
}
790-
791778
/**
792779
* This factory is used only when no ssl connections are required (no https endpoints).
793780
* Internally http client would create factory and spend time if no supplied.

client-v2/src/main/java/com/clickhouse/client/api/metrics/MicrometerLoader.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,4 @@ public static void applyConnectionMetricsBinder(Object registry, String metricsG
2828
throw new ClientMisconfigurationException("Unsupported registry type." + registry.getClass());
2929
}
3030
}
31-
32-
public static void applyFailureRatioMetricsBinder(Object registry, String metricsGroupName, HttpAPIClientHelper httpAPIClientHelper) {
33-
if (registry instanceof MeterRegistry) {
34-
Gauge.builder("httpcomponents.httpclient.request.ratio", httpAPIClientHelper, HttpAPIClientHelper::getRequestRatio)
35-
.description("The ratio of total requests to failures via timeout.")
36-
.tag("httpclient", metricsGroupName)
37-
.register((MeterRegistry) registry);
38-
} else {
39-
throw new ClientMisconfigurationException("Unsupported registry type." + registry.getClass());
40-
}
41-
}
4231
}

client-v2/src/test/java/com/clickhouse/client/metrics/MetricsTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,4 @@ public void testConnectionTime() throws Exception {
102102
assertEquals(times.value(), 0);//Second time should be 0
103103
}
104104
}
105-
106-
@Test(groups = { "integration" }, enabled = true)
107-
public void testConnectionRatio() throws Exception {
108-
ClickHouseNode node = getServer(ClickHouseProtocol.HTTP);
109-
boolean isSecure = isCloud();
110-
111-
try (Client client = new Client.Builder()
112-
.addEndpoint(Protocol.HTTP, "192.168.1.1", node.getPort(), isSecure)
113-
.setUsername("default")
114-
.setPassword(ClickHouseServerForTest.getPassword())
115-
.setDefaultDatabase(ClickHouseServerForTest.getDatabase())
116-
.setConnectTimeout(5, ChronoUnit.SECONDS)
117-
.registerClientMetrics(meterRegistry, "pool-test")
118-
.build()) {
119-
120-
client.ping();
121-
Gauge ratio = meterRegistry.get("httpcomponents.httpclient.request.ratio").gauge();
122-
123-
System.out.println("Ratio: " + ratio.value());
124-
Assert.assertTrue(ratio.value() > 99.0);
125-
}
126-
}
127105
}

client-v2/src/test/java/com/clickhouse/client/query/QueryTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,10 +2056,7 @@ public void testGettingRowsBeforeLimit() throws Exception {
20562056
Assert.assertEquals(response.getTotalRowsToRead(), expectedTotalRowsToRead);
20572057
}
20582058
}
2059-
2060-
static {
2061-
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "DEBUG");
2062-
}
2059+
20632060
@Test(groups = {"integration"})
20642061
public void testEmptyResponse() throws Exception {
20652062
try (QueryResponse response = client.query("SELECT number FROM system.numbers LIMIT 0", new QuerySettings().setFormat(ClickHouseFormat.RowBinary)).get()) {

0 commit comments

Comments
 (0)