adarshsanjeev commented on code in PR #18121:
URL: https://github.com/apache/druid/pull/18121#discussion_r2179864676
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java:
##########
@@ -553,11 +554,31 @@ private MSQTaskReportPayload runInternal(final
QueryListener queryListener, fina
countersSnapshot,
null
);
- // Emit summary metrics
+ // Emit metrics
+ emitQueryMetrics(queryDef, taskStateForReport.isSuccess());
emitSummaryMetrics(msqTaskReportPayload, querySpec);
return msqTaskReportPayload;
}
+ private void emitQueryMetrics(@Nullable final QueryDefinition queryDef,
final boolean success)
+ {
+ final Set<String> datasources = new HashSet<>();
+ final Set<Interval> intervals = new HashSet<>();
+ if (queryDef != null) {
+ for (StageDefinition stageDefinition : queryDef.getStageDefinitions()) {
+ datasources.addAll(MSQMetricUtils.getDatasources(stageDefinition));
+ intervals.addAll(MSQMetricUtils.getIntervals(stageDefinition));
+ }
+ }
+
+ long startTime =
DateTimeUtils.getInstantMillis(MultiStageQueryContext.getStartTime(querySpec.getContext()));
+ context.emitMetric(
+ "query/time",
+ MSQMetricUtils.createQueryMetricDimensions(datasources, intervals,
success),
+ startTime - System.currentTimeMillis()
Review Comment:
@kgyrtkirk Made these changes. The function now takes a service emitter.
There's an awkward bit in `TaskControllerContext`, where we have to check if
the dataSource has already been provided in the metricBuilder before setting
the default value, for backward compatibility. I wonder if it is worth adding
yet another function of `getDefaultMetricBuilder()` from the context instead,
so that the caller can decide what all to override instead of this weird code.
Please let me know your thoughts.
--
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]