rohangarg commented on code in PR #12867:
URL: https://github.com/apache/druid/pull/12867#discussion_r938618047
##########
services/src/main/java/org/apache/druid/server/AsyncQueryForwardingServlet.java:
##########
@@ -751,14 +791,32 @@ public void onFailure(Response response, Throwable
failure)
super.onFailure(response, failure);
}
- private void emitQueryTime(long requestTimeNs, boolean success)
+ private void emitQueryTime(long requestTimeNs, boolean success, @Nullable
String sqlQueryId)
{
- QueryMetrics queryMetrics = DruidMetrics.makeRequestMetrics(
- queryMetricsFactory,
- warehouse.getToolChest(query),
- query,
- req.getRemoteAddr()
- );
+ QueryMetrics queryMetrics;
+ if (sqlQueryId != null) {
+ queryMetrics = queryMetricsFactory.makeMetrics();
+ if (queryMetrics == null) {
+ return;
+ }
+ queryMetrics.remoteAddress(req.getRemoteAddr());
+ // Setting sqlQueryId dimension to the metric. Using a dummy query
since SQL is translated to a native query
+ // only at a broker.
+ queryMetrics.sqlQueryId(
Review Comment:
Yes, we can augment the `QueryMetrics` interface itself since it is allowed
in a major version release. I have added a `sqlQueryId(String)` method.
Further, I've also cleaned up `GenericQueryMetricsFactory` wrt default
implementation of the new `makeMetrics` method.
Thanks for the suggestion!
##########
services/src/test/java/org/apache/druid/server/AsyncQueryForwardingServletTest.java:
##########
@@ -568,6 +595,18 @@ protected void doService(
servlet.service(requestMock, null);
+ // NPE is expected since the listener's onComplete calls the parent class'
onComplete which fails due to
Review Comment:
1. It is in partial state since the `init` method is not called on the
servlet. Initializing the servlet would require multiple things like
`ServletConfig` and `HttpClientProvider`
2. So far I've seen NPE only due to uncreated objects in the servlet
3. Currently, it occurs while doing operations on the logger
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]