mirror of https://github.com/apache/druid.git
actually use the metrics emitting listener
This commit is contained in:
parent
2ad1bd3f44
commit
41db4b1063
|
@ -107,10 +107,11 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet
|
||||||
String host = hostFinder.getDefaultHost();
|
String host = hostFinder.getDefaultHost();
|
||||||
Query inputQuery = null;
|
Query inputQuery = null;
|
||||||
boolean hasContent = request.getContentLength() > 0 || request.getContentType() != null;
|
boolean hasContent = request.getContentLength() > 0 || request.getContentType() != null;
|
||||||
|
boolean isQuery = request.getMethod().equalsIgnoreCase(HttpMethod.POST.asString());
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// queries only exist for POST
|
// queries only exist for POST
|
||||||
if (request.getMethod().equalsIgnoreCase(HttpMethod.POST.asString())) {
|
if (isQuery) {
|
||||||
try {
|
try {
|
||||||
inputQuery = objectMapper.readValue(request.getInputStream(), Query.class);
|
inputQuery = objectMapper.readValue(request.getInputStream(), Query.class);
|
||||||
if (inputQuery != null) {
|
if (inputQuery != null) {
|
||||||
|
@ -235,7 +236,11 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyRequest.send(newProxyResponseListener(request, response));
|
if (isQuery) {
|
||||||
|
proxyRequest.send(newMetricsEmittingProxyResponseListener(request, response, inputQuery, startTime));
|
||||||
|
} else {
|
||||||
|
proxyRequest.send(newProxyResponseListener(request, response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,6 +262,17 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet
|
||||||
return URI.create(uri.toString());
|
return URI.create(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response.Listener newMetricsEmittingProxyResponseListener(
|
||||||
|
HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
Query query,
|
||||||
|
long start
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return new MetricsEmittingProxyResponseListener(request, response, query, start);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MetricsEmittingProxyResponseListener extends ProxyResponseListener
|
private class MetricsEmittingProxyResponseListener extends ProxyResponseListener
|
||||||
{
|
{
|
||||||
private final HttpServletRequest req;
|
private final HttpServletRequest req;
|
||||||
|
|
Loading…
Reference in New Issue