Search in sources :

Example 1 with StageStatistics

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));
}
Also used : TaskInfo(com.facebook.presto.execution.TaskInfo) ResourceDistribution(com.facebook.presto.spi.eventlistener.ResourceDistribution) Distribution(com.facebook.airlift.stats.Distribution) StageExecutionInfo(com.facebook.presto.execution.StageExecutionInfo) StageStatistics(com.facebook.presto.spi.eventlistener.StageStatistics)

Example 2 with StageStatistics

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);
}
Also used : QueryStats(com.facebook.presto.execution.QueryStats) QueryCompletedEvent(com.facebook.presto.spi.eventlistener.QueryCompletedEvent) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) StageStatistics(com.facebook.presto.spi.eventlistener.StageStatistics)

Aggregations

StageStatistics (com.facebook.presto.spi.eventlistener.StageStatistics)2 Distribution (com.facebook.airlift.stats.Distribution)1 QueryStats (com.facebook.presto.execution.QueryStats)1 StageExecutionInfo (com.facebook.presto.execution.StageExecutionInfo)1 TaskInfo (com.facebook.presto.execution.TaskInfo)1 QueryCompletedEvent (com.facebook.presto.spi.eventlistener.QueryCompletedEvent)1 ResourceDistribution (com.facebook.presto.spi.eventlistener.ResourceDistribution)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1