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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations