use of io.micrometer.api.instrument.Timer in project reactor-netty by reactor.
the class MicrometerHttpClientMetricsRecorder method recordResponseTime.
@Override
public void recordResponseTime(SocketAddress remoteAddress, String uri, String method, String status, Duration time) {
String address = Metrics.formatSocketAddress(remoteAddress);
MeterKey meterKey = new MeterKey(uri, address, method, status);
Timer responseTime = MapUtils.computeIfAbsent(responseTimeCache, meterKey, key -> filter(Timer.builder(name() + RESPONSE_TIME).description(RESPONSE_TIME_DESCRIPTION).tags(REMOTE_ADDRESS, address, URI, uri, METHOD, method, STATUS, status).register(REGISTRY)));
if (responseTime != null) {
responseTime.record(time);
}
}
use of io.micrometer.api.instrument.Timer in project reactor-netty by reactor.
the class AddressResolverGroupMetricsTest method getTimerValue.
private double getTimerValue(String address) {
MeterRegistryAssert.assertThat(registry).hasTimerWithNameAndTags("reactor.netty.http.client.address.resolver", Tags.of(REMOTE_ADDRESS, address, STATUS, SUCCESS));
Timer timer = registry.find("reactor.netty.http.client.address.resolver").tags(REMOTE_ADDRESS, address, STATUS, SUCCESS).timer();
double result = -1;
if (timer != null) {
result = timer.totalTime(TimeUnit.NANOSECONDS);
}
return result;
}
use of io.micrometer.api.instrument.Timer in project reactor-netty by reactor.
the class UdpMetricsTests method checkClientConnectTime.
private void checkClientConnectTime(String[] tags) {
MeterRegistryAssert.assertThat(registry).hasTimerWithNameAndTags(CLIENT_CONNECT_TIME, Tags.of(tags));
Timer timer = registry.find(CLIENT_CONNECT_TIME).tags(tags).timer();
assertThat(timer).isNotNull();
assertThat(timer.count()).isEqualTo(1);
assertThat(timer.totalTime(TimeUnit.NANOSECONDS) > 0).isTrue();
}
use of io.micrometer.api.instrument.Timer in project reactor-netty by reactor.
the class MicrometerChannelMetricsRecorder method recordTlsHandshakeTime.
@Override
public void recordTlsHandshakeTime(SocketAddress remoteAddress, Duration time, String status) {
String address = reactor.netty.Metrics.formatSocketAddress(remoteAddress);
MeterKey meterKey = new MeterKey(null, address, null, status);
Timer timer = MapUtils.computeIfAbsent(tlsHandshakeTimeCache, meterKey, key -> filter(Timer.builder(name + TLS_HANDSHAKE_TIME).description(TLS_HANDSHAKE_TIME_DESCRIPTION).tags(REMOTE_ADDRESS, address, STATUS, status).register(REGISTRY)));
if (timer != null) {
timer.record(time);
}
}
use of io.micrometer.api.instrument.Timer in project reactor-netty by reactor.
the class MicrometerHttpServerMetricsRecorder method recordDataSentTime.
@Override
public void recordDataSentTime(String uri, String method, String status, Duration time) {
MeterKey meterKey = new MeterKey(uri, null, method, status);
Timer dataSentTime = MapUtils.computeIfAbsent(dataSentTimeCache, meterKey, key -> filter(Timer.builder(name() + DATA_SENT_TIME).tags(HttpServerMeters.DataSentTimeTags.URI.getKey(), uri, HttpServerMeters.DataSentTimeTags.METHOD.getKey(), method, HttpServerMeters.DataSentTimeTags.STATUS.getKey(), status).register(REGISTRY)));
if (dataSentTime != null) {
dataSentTime.record(time);
}
}