use of com.facebook.presto.spi.eventlistener.StageStatistics in project presto by prestodb.
the class QueryMonitor method computeStageStatistics.
private static void computeStageStatistics(StageInfo stageInfo, ImmutableList.Builder<StageStatistics> stageStatisticsBuilder) {
Distribution cpuDistribution = new Distribution();
Distribution memoryDistribution = new Distribution();
StageExecutionInfo executionInfo = stageInfo.getLatestAttemptExecutionInfo();
for (TaskInfo taskInfo : executionInfo.getTasks()) {
cpuDistribution.add(NANOSECONDS.toMillis(taskInfo.getStats().getTotalCpuTimeInNanos()));
memoryDistribution.add(taskInfo.getStats().getPeakTotalMemoryInBytes());
}
stageStatisticsBuilder.add(new StageStatistics(stageInfo.getStageId().getId(), executionInfo.getStats().getGcInfo().getStageExecutionId(), executionInfo.getTasks().size(), executionInfo.getStats().getTotalScheduledTime(), executionInfo.getStats().getTotalCpuTime(), executionInfo.getStats().getRetriedCpuTime(), executionInfo.getStats().getTotalBlockedTime(), executionInfo.getStats().getRawInputDataSize(), executionInfo.getStats().getProcessedInputDataSize(), executionInfo.getStats().getPhysicalWrittenDataSize(), executionInfo.getStats().getGcInfo(), createResourceDistribution(cpuDistribution.snapshot()), createResourceDistribution(memoryDistribution.snapshot())));
stageInfo.getSubStages().forEach(subStage -> computeStageStatistics(subStage, stageStatisticsBuilder));
}
use of com.facebook.presto.spi.eventlistener.StageStatistics in project presto by prestodb.
the class QueryMonitor method queryCompletedEvent.
public void queryCompletedEvent(QueryInfo queryInfo) {
QueryStats queryStats = queryInfo.getQueryStats();
ImmutableList.Builder<StageStatistics> stageStatisticsBuilder = ImmutableList.builder();
if (queryInfo.getOutputStage().isPresent()) {
computeStageStatistics(queryInfo.getOutputStage().get(), stageStatisticsBuilder);
}
eventListenerManager.queryCompleted(new QueryCompletedEvent(createQueryMetadata(queryInfo), createQueryStatistics(queryInfo), createQueryContext(queryInfo.getSession(), queryInfo.getResourceGroupId()), getQueryIOMetadata(queryInfo), createQueryFailureInfo(queryInfo.getFailureInfo(), queryInfo.getOutputStage()), queryInfo.getWarnings(), queryInfo.getQueryType(), queryInfo.getFailedTasks().orElse(ImmutableList.of()).stream().map(TaskId::toString).collect(toImmutableList()), ofEpochMilli(queryStats.getCreateTime().getMillis()), ofEpochMilli(queryStats.getExecutionStartTime().getMillis()), ofEpochMilli(queryStats.getEndTime() != null ? queryStats.getEndTime().getMillis() : 0), stageStatisticsBuilder.build(), createOperatorStatistics(queryInfo), queryInfo.getExpandedQuery()));
logQueryTimeline(queryInfo);
}
Aggregations