Search in sources :

Example 6 with QueryCompletedEvent

use of com.facebook.presto.spi.eventlistener.QueryCompletedEvent in project presto-audit by yahoojapan.

the class TestHelper method createQueryWithSource.

public QueryCompletedEvent createQueryWithSource(Optional<String> source) {
    setUp();
    QueryMetadata metadata = new QueryMetadata("20170606_044544_00024_nfhe3", Optional.of("4c52973c-14c6-4534-837f-238e21d9b061"), "select * from airdelays_s3_csv WHERE kw = 'presto-kw-example' limit 5", "FINISHED", uri, Optional.empty(), Optional.empty());
    QueryContext context = new QueryContext("test-user", Optional.of("principal"), Optional.of("example.com"), Optional.of("StatementClient 0.167"), Optional.of("clientInfo"), new HashSet<>(), source, Optional.of("catalog"), Optional.of("schema"), Optional.of(""), new HashMap<>(), "127.0.0.1", "0.175", "environment");
    return new QueryCompletedEvent(metadata, statistics, context, ioMetadata, Optional.empty(), createTime, executionStartTime, endTime);
}
Also used : QueryMetadata(com.facebook.presto.spi.eventlistener.QueryMetadata) QueryCompletedEvent(com.facebook.presto.spi.eventlistener.QueryCompletedEvent) QueryContext(com.facebook.presto.spi.eventlistener.QueryContext)

Example 7 with QueryCompletedEvent

use of com.facebook.presto.spi.eventlistener.QueryCompletedEvent in project presto-audit by yahoojapan.

the class TestHelper method createFailureEvent.

public QueryCompletedEvent createFailureEvent() {
    setUp();
    QueryMetadata metadata = new QueryMetadata("20170606_044544_00024_nfhe3", Optional.of("4c52973c-14c6-4534-837f-238e21d9b061"), "select 2a", "FAILED", uri, Optional.empty(), Optional.empty());
    ErrorCode errorCode = new ErrorCode(1, "SYNTAX_ERROR", ErrorType.USER_ERROR);
    QueryFailureInfo failureInfo = new QueryFailureInfo(errorCode, Optional.of("com.facebook.presto.sql.parser.ParsingException"), Optional.of("line 1:15: mismatched input '0' expecting ')'"), Optional.empty(), Optional.empty(), "{json-error}");
    return new QueryCompletedEvent(metadata, statistics, context, ioMetadata, Optional.of(failureInfo), createTime, executionStartTime, endTime);
}
Also used : QueryFailureInfo(com.facebook.presto.spi.eventlistener.QueryFailureInfo) QueryMetadata(com.facebook.presto.spi.eventlistener.QueryMetadata) QueryCompletedEvent(com.facebook.presto.spi.eventlistener.QueryCompletedEvent) ErrorCode(com.facebook.presto.spi.ErrorCode)

Example 8 with QueryCompletedEvent

use of com.facebook.presto.spi.eventlistener.QueryCompletedEvent in project presto-audit by yahoojapan.

the class TestFullLogSerializer method testShouldOutput.

@Test(dataProvider = "filter-provider")
public void testShouldOutput(Optional<String> filter, Optional<String> source, boolean result) {
    FullLogSerializer serializer = new FullLogSerializer(filter);
    QueryCompletedEvent event = testHelper.createQueryWithSource(source);
    boolean shouldOutput = serializer.shouldOutput(event);
    assertEquals(shouldOutput, result);
}
Also used : QueryCompletedEvent(com.facebook.presto.spi.eventlistener.QueryCompletedEvent) Test(org.testng.annotations.Test)

Example 9 with QueryCompletedEvent

use of com.facebook.presto.spi.eventlistener.QueryCompletedEvent in project presto by prestodb.

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(), Optional.empty(), ImmutableList.of(), queryInfo.getSession().getTraceToken()), new QueryStatistics(ofMillis(0), ofMillis(0), ofMillis(0), ofMillis(queryInfo.getQueryStats().getWaitingForPrerequisitesTime().toMillis()), ofMillis(queryInfo.getQueryStats().getQueuedTime().toMillis()), ofMillis(0), ofMillis(0), ofMillis(0), ofMillis(0), ofMillis(0), Optional.empty(), ofMillis(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, new RuntimeStats()), createQueryContext(queryInfo.getSession(), queryInfo.getResourceGroupId()), new QueryIOMetadata(ImmutableList.of(), Optional.empty()), createQueryFailureInfo(failure, Optional.empty()), ImmutableList.of(), queryInfo.getQueryType(), ImmutableList.of(), ofEpochMilli(queryInfo.getQueryStats().getCreateTime().getMillis()), ofEpochMilli(queryInfo.getQueryStats().getEndTime().getMillis()), ofEpochMilli(queryInfo.getQueryStats().getEndTime().getMillis()), ImmutableList.of(), ImmutableList.of(), Optional.empty()));
    logQueryTimeline(queryInfo);
}
Also used : QueryMetadata(com.facebook.presto.spi.eventlistener.QueryMetadata) QueryCompletedEvent(com.facebook.presto.spi.eventlistener.QueryCompletedEvent) QueryStatistics(com.facebook.presto.spi.eventlistener.QueryStatistics) RuntimeStats(com.facebook.presto.common.RuntimeStats) QueryIOMetadata(com.facebook.presto.spi.eventlistener.QueryIOMetadata)

Example 10 with QueryCompletedEvent

use of com.facebook.presto.spi.eventlistener.QueryCompletedEvent 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

QueryCompletedEvent (com.facebook.presto.spi.eventlistener.QueryCompletedEvent)12 QueryCreatedEvent (com.facebook.presto.spi.eventlistener.QueryCreatedEvent)6 QueryMetadata (com.facebook.presto.spi.eventlistener.QueryMetadata)6 Test (org.testng.annotations.Test)6 ImmutableList (com.google.common.collect.ImmutableList)4 QueryId (com.facebook.presto.spi.QueryId)3 SplitCompletedEvent (com.facebook.presto.spi.eventlistener.SplitCompletedEvent)3 List (java.util.List)3 Session (com.facebook.presto.Session)2 QueryStats (com.facebook.presto.execution.QueryStats)2 QueryContext (com.facebook.presto.spi.eventlistener.QueryContext)2 QueryFailureInfo (com.facebook.presto.spi.eventlistener.QueryFailureInfo)2 QueryIOMetadata (com.facebook.presto.spi.eventlistener.QueryIOMetadata)2 QueryStatistics (com.facebook.presto.spi.eventlistener.QueryStatistics)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 FailureInfo (com.facebook.presto.client.FailureInfo)1 NodeVersion (com.facebook.presto.client.NodeVersion)1 RuntimeStats (com.facebook.presto.common.RuntimeStats)1