Added RntbdMetrics.endpoints to sample the number of endpoints in use by an RntbdTransportClient. Also: optimized imports
This commit is contained in:
Родитель
188cd290ea
Коммит
80a83198cc
|
@ -28,12 +28,13 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
|||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import com.google.common.base.Strings;
|
||||
import com.microsoft.azure.cosmosdb.DocumentClientException;
|
||||
import com.microsoft.azure.cosmosdb.internal.UserAgentContainer;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdEndpoint;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdMetrics;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdObjectMapper;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdRequestArgs;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdMetrics;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdRequestRecord;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd.RntbdServiceEndpoint;
|
||||
import com.microsoft.azure.cosmosdb.rx.internal.Configs;
|
||||
|
@ -74,9 +75,13 @@ public final class RntbdTransportClient extends TransportClient implements AutoC
|
|||
// region Constructors
|
||||
|
||||
RntbdTransportClient(final RntbdEndpoint.Provider endpointProvider) {
|
||||
|
||||
this.endpointProvider = endpointProvider;
|
||||
this.id = instanceCount.incrementAndGet();
|
||||
this.tag = Tag.of(RntbdServiceEndpoint.class.getSimpleName(), Long.toHexString(this.id));
|
||||
|
||||
this.tag = Tag.of(RntbdTransportClient.class.getSimpleName(), Strings.padStart(
|
||||
Long.toHexString(this.id).toUpperCase(), 4, '0')
|
||||
);
|
||||
}
|
||||
|
||||
RntbdTransportClient(final Options options, final SslContext sslContext) {
|
||||
|
@ -91,6 +96,10 @@ public final class RntbdTransportClient extends TransportClient implements AutoC
|
|||
|
||||
// region Accessors
|
||||
|
||||
public int endpointCount() {
|
||||
return this.endpointProvider.count();
|
||||
}
|
||||
|
||||
public long id() {
|
||||
return this.id;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ package com.microsoft.azure.cosmosdb.internal.directconnectivity.rntbd;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.base.Strings;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.ServerProperties;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
|
|
@ -41,7 +41,6 @@ import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
|
|||
import io.micrometer.core.instrument.config.NamingConvention;
|
||||
import io.micrometer.core.instrument.dropwizard.DropwizardConfig;
|
||||
import io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry;
|
||||
import io.micrometer.core.instrument.search.Search;
|
||||
import io.micrometer.core.instrument.util.HierarchicalNameMapper;
|
||||
import io.micrometer.core.lang.Nullable;
|
||||
|
||||
|
@ -59,6 +58,7 @@ public final class RntbdMetrics {
|
|||
private static final String prefix = "cosmos.directTcp.";
|
||||
private static MeterRegistry consoleLoggingRegistry;
|
||||
|
||||
private final RntbdTransportClient transportClient;
|
||||
private final RntbdEndpoint endpoint;
|
||||
|
||||
private final Timer requests;
|
||||
|
@ -78,7 +78,9 @@ public final class RntbdMetrics {
|
|||
|
||||
public RntbdMetrics(RntbdTransportClient client, RntbdEndpoint endpoint) {
|
||||
|
||||
this.transportClient = client;
|
||||
this.endpoint = endpoint;
|
||||
|
||||
this.tags = Tags.of(client.tag(), endpoint.tag());
|
||||
|
||||
this.requests = registry.timer(nameOf("requests"), tags);
|
||||
|
@ -88,6 +90,11 @@ public final class RntbdMetrics {
|
|||
final Timer responseSuccesses = this.responseSuccesses;
|
||||
final Timer requests = this.requests;
|
||||
|
||||
Gauge.builder(nameOf("endpoints"), client, RntbdTransportClient::endpointCount)
|
||||
.description("endpoint count")
|
||||
.tag(client.tag().getKey(), client.tag().getValue())
|
||||
.register(registry);
|
||||
|
||||
Gauge.builder(nameOf("concurrentRequests"), endpoint, RntbdEndpoint::concurrentRequests)
|
||||
.description("executing or queued request count")
|
||||
.tags(this.tags)
|
||||
|
@ -98,18 +105,6 @@ public final class RntbdMetrics {
|
|||
.tags(this.tags)
|
||||
.register(registry);
|
||||
|
||||
Gauge.builder(nameOf("completionRate"), endpoint, x -> responseSuccesses.count() / (double)requests.count())
|
||||
.description("successful (non-error) responses / total responses")
|
||||
.baseUnit("%")
|
||||
.tags(this.tags)
|
||||
.register(registry);
|
||||
|
||||
Gauge.builder(nameOf("responseRate"), endpoint, x -> responseSuccesses.count() / (double)(requests.count() + x.concurrentRequests()))
|
||||
.description("successful (non-error) responses / total requests")
|
||||
.baseUnit("%")
|
||||
.tags(this.tags)
|
||||
.register(registry);
|
||||
|
||||
Gauge.builder(nameOf("channelsAcquired"), endpoint, RntbdEndpoint::channelsAcquired)
|
||||
.description("acquired channel count")
|
||||
.tags(this.tags)
|
||||
|
@ -137,30 +132,6 @@ public final class RntbdMetrics {
|
|||
|
||||
// region Accessors
|
||||
|
||||
@JsonProperty
|
||||
public int channelsAcquired() {
|
||||
return this.endpoint.channelsAcquired();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public int channelsAvailable() {
|
||||
return this.endpoint.channelsAvailable();
|
||||
}
|
||||
|
||||
/***
|
||||
* Computes the number of successful (non-error) responses received divided by the total number of completed
|
||||
* requests
|
||||
*/
|
||||
@JsonProperty
|
||||
public double completionRate() {
|
||||
return this.responseSuccesses.count() / (double)this.requests.count();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public long concurrentRequests() {
|
||||
return this.endpoint.concurrentRequests();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public static synchronized MeterRegistry consoleLoggingRegistry() {
|
||||
|
||||
|
@ -204,6 +175,35 @@ public final class RntbdMetrics {
|
|||
return consoleLoggingRegistry;
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public int channelsAcquired() {
|
||||
return this.endpoint.channelsAcquired();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public int channelsAvailable() {
|
||||
return this.endpoint.channelsAvailable();
|
||||
}
|
||||
|
||||
/***
|
||||
* Computes the number of successful (non-error) responses received divided by the total number of completed
|
||||
* requests
|
||||
*/
|
||||
@JsonProperty
|
||||
public double completionRate() {
|
||||
return this.responseSuccesses.count() / (double)this.requests.count();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public long concurrentRequests() {
|
||||
return this.endpoint.concurrentRequests();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public int endpoints() {
|
||||
return this.transportClient.endpointCount();
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
public int requestQueueLength() {
|
||||
return this.endpoint.requestQueueLength();
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
|||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import com.google.common.base.Strings;
|
||||
import com.microsoft.azure.cosmosdb.internal.directconnectivity.StoreResponse;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
|
|
Загрузка…
Ссылка в новой задаче