Search in sources :

Example 1 with QueryStatistics

use of io.prestosql.spi.eventlistener.QueryStatistics in project hetu-core by openlookeng.

the class QueryMonitor method queryImmediateFailureEvent.

public void queryImmediateFailureEvent(BasicQueryInfo queryInfo, ExecutionFailureInfo failure) {
    eventListenerManager.queryCompleted(new QueryCompletedEvent(new QueryMetadata(queryInfo.getQueryId().toString(), queryInfo.getSession().getTransactionId().map(TransactionId::toString), queryInfo.getQuery(), queryInfo.getPreparedQuery(), queryInfo.getState().toString(), queryInfo.getSelf(), Optional.empty(), Optional.empty()), new QueryStatistics(ofMillis(0), ofMillis(0), ofMillis(queryInfo.getQueryStats().getQueuedTime().toMillis()), Optional.empty(), Optional.empty(), Optional.empty(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ImmutableList.of(), 0, true, ImmutableList.of(), ImmutableList.of(), Optional.empty()), createQueryContext(queryInfo.getSession(), queryInfo.getResourceGroupId()), new QueryIOMetadata(ImmutableList.of(), Optional.empty()), createQueryFailureInfo(failure, Optional.empty()), ImmutableList.of(), ofEpochMilli(queryInfo.getQueryStats().getCreateTime().getMillis()), ofEpochMilli(queryInfo.getQueryStats().getEndTime().getMillis()), ofEpochMilli(queryInfo.getQueryStats().getEndTime().getMillis())));
    logQueryTimeline(queryInfo);
}
Also used : QueryMetadata(io.prestosql.spi.eventlistener.QueryMetadata) QueryCompletedEvent(io.prestosql.spi.eventlistener.QueryCompletedEvent) QueryStatistics(io.prestosql.spi.eventlistener.QueryStatistics) QueryIOMetadata(io.prestosql.spi.eventlistener.QueryIOMetadata)

Example 2 with QueryStatistics

use of io.prestosql.spi.eventlistener.QueryStatistics in project hetu-core by openlookeng.

the class QueryMonitor method createQueryStatistics.

private QueryStatistics createQueryStatistics(QueryInfo queryInfo) {
    ImmutableList.Builder<String> operatorSummaries = ImmutableList.builder();
    for (OperatorStats summary : queryInfo.getQueryStats().getOperatorSummaries()) {
        operatorSummaries.add(operatorStatsCodec.toJson(summary));
    }
    Optional<StatsAndCosts> planNodeStatsAndCosts = queryInfo.getOutputStage().map(StatsAndCosts::create);
    Optional<String> serializedPlanNodeStatsAndCosts = planNodeStatsAndCosts.map(statsAndCostsCodec::toJson);
    QueryStats queryStats = queryInfo.getQueryStats();
    return new QueryStatistics(ofMillis(queryStats.getTotalCpuTime().toMillis()), ofMillis(queryStats.getTotalScheduledTime().toMillis()), ofMillis(queryStats.getQueuedTime().toMillis()), Optional.of(ofMillis(queryStats.getResourceWaitingTime().toMillis())), Optional.of(ofMillis(queryStats.getAnalysisTime().toMillis())), Optional.of(ofMillis(queryStats.getDistributedPlanningTime().toMillis())), queryStats.getPeakUserMemoryReservation().toBytes(), queryStats.getPeakTotalMemoryReservation().toBytes(), queryStats.getPeakTaskUserMemory().toBytes(), queryStats.getPeakTaskTotalMemory().toBytes(), queryStats.getPhysicalInputDataSize().toBytes(), queryStats.getPhysicalInputPositions(), queryStats.getInternalNetworkInputDataSize().toBytes(), queryStats.getInternalNetworkInputPositions(), queryStats.getRawInputDataSize().toBytes(), queryStats.getRawInputPositions(), queryStats.getOutputDataSize().toBytes(), queryStats.getOutputPositions(), queryStats.getLogicalWrittenDataSize().toBytes(), queryStats.getWrittenPositions(), queryStats.getCumulativeUserMemory(), queryStats.getStageGcStatistics(), queryStats.getCompletedDrivers(), queryInfo.isCompleteInfo(), getCpuDistributions(queryInfo), operatorSummaries.build(), serializedPlanNodeStatsAndCosts);
}
Also used : QueryStats(io.prestosql.execution.QueryStats) QueryStatistics(io.prestosql.spi.eventlistener.QueryStatistics) ImmutableList(com.google.common.collect.ImmutableList) StatsAndCosts(io.prestosql.cost.StatsAndCosts) OperatorStats(io.prestosql.operator.OperatorStats)

Example 3 with QueryStatistics

use of io.prestosql.spi.eventlistener.QueryStatistics in project hetu-core by openlookeng.

the class EventUtility method visit.

private static void visit(QueryCompletedEvent event, BiConsumer<String, Object> consumer) {
    QueryMetadata metadata = event.getMetadata();
    QueryContext context = event.getContext();
    QueryStatistics statistics = event.getStatistics();
    consumer.accept(QUERY_ID, metadata.getQueryId());
    consumer.accept("Query", metadata.getQuery());
    consumer.accept(CREATE_TIME, event.getCreateTime());
    consumer.accept("Execution Start Time", event.getExecutionStartTime());
    consumer.accept("End Time", event.getEndTime());
    consumer.accept("Wall Time", statistics.getWallTime().toMillis());
    consumer.accept("User", context.getUser());
    consumer.accept("Complete", statistics.isComplete());
    context.getRemoteClientAddress().ifPresent(address -> consumer.accept("Remote Client Address", address));
    context.getCatalog().ifPresent(catalog -> consumer.accept("Catalog", catalog));
    context.getSchema().ifPresent(schema -> consumer.accept("Schema", schema));
    event.getFailureInfo().ifPresent(failureInfo -> {
        consumer.accept("Query Failure Error", failureInfo.getErrorCode());
        failureInfo.getFailureType().ifPresent(type -> consumer.accept(QUERY_FAILURE_TYPE, type));
        failureInfo.getFailureMessage().ifPresent(message -> consumer.accept(QUERY_FAILURE_TYPE, message));
        failureInfo.getFailureTask().ifPresent(task -> consumer.accept(QUERY_FAILURE_TYPE, task));
        failureInfo.getFailureHost().ifPresent(host -> consumer.accept(QUERY_FAILURE_TYPE, host));
    });
}
Also used : QueryMetadata(io.prestosql.spi.eventlistener.QueryMetadata) QueryStatistics(io.prestosql.spi.eventlistener.QueryStatistics) QueryContext(io.prestosql.spi.eventlistener.QueryContext)

Aggregations

QueryStatistics (io.prestosql.spi.eventlistener.QueryStatistics)3 QueryMetadata (io.prestosql.spi.eventlistener.QueryMetadata)2 ImmutableList (com.google.common.collect.ImmutableList)1 StatsAndCosts (io.prestosql.cost.StatsAndCosts)1 QueryStats (io.prestosql.execution.QueryStats)1 OperatorStats (io.prestosql.operator.OperatorStats)1 QueryCompletedEvent (io.prestosql.spi.eventlistener.QueryCompletedEvent)1 QueryContext (io.prestosql.spi.eventlistener.QueryContext)1 QueryIOMetadata (io.prestosql.spi.eventlistener.QueryIOMetadata)1