package io.vertx.ext.dropwizard.impl;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.core.net.SocketAddress;
import io.vertx.core.spi.metrics.HttpServerMetrics;
import io.vertx.ext.dropwizard.Match;
import java.util.List;
class HttpServerMetricsImpl extends HttpMetricsImpl implements HttpServerMetrics<RequestMetric, WebSocketMetric, Long> {
private final Matcher uriMatcher;
HttpServerMetricsImpl(MetricRegistry registry, String baseName, List<Match> monitoredUris, SocketAddress localAddress) {
super(registry, baseName, localAddress);
uriMatcher = new Matcher(monitoredUris);
}
@Override
public RequestMetric requestBegin(Long socketMetric, HttpServerRequest request) {
return new RequestMetric(request.method(), request.uri());
}
@Override
public WebSocketMetric connected(Long socketMetric, RequestMetric requestMetric, ServerWebSocket serverWebSocket) {
return createWebSocketMetric();
}
@Override
public void responseEnd(RequestMetric requestMetric, HttpServerResponse response) {
end(requestMetric, response.getStatusCode(), uriMatcher);
}
@Override
public void requestReset(RequestMetric requestMetric) {
}
@Override
public RequestMetric responsePushed(Long socketMetric, HttpMethod method, String uri, HttpServerResponse response) {
return new RequestMetric(method, uri);
}
@Override
public void disconnected(WebSocketMetric serverWebSocketMetric) {
disconnect(serverWebSocketMetric);
}
}