Search in sources :

Example 1 with QueryGuid

use of io.confluent.ksql.util.QueryGuid in project ksql by confluentinc.

the class QueryLoggerTest method shouldContainAQueryID.

@Test
public void shouldContainAQueryID() {
    String message = "my message";
    String query = "DESCRIBE cat EXTENDED;";
    QueryLogger.info(message, query);
    testAppender.getLog().forEach((e) -> {
        final QueryLoggerMessage msg = (QueryLoggerMessage) e.getMessage();
        final QueryGuid queryGuid = msg.getQueryIdentifier();
        assertThat(queryGuid.getStructuralGuid(), not(isEmptyOrNullString()));
        assertThat(queryGuid.getQueryGuid(), not(isEmptyOrNullString()));
    });
}
Also used : QueryGuid(io.confluent.ksql.util.QueryGuid) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Test(org.junit.Test)

Example 2 with QueryGuid

use of io.confluent.ksql.util.QueryGuid in project ksql by confluentinc.

the class QueryLogger method log.

private static void log(final Level level, final Object message, final String query) {
    try {
        final String anonQuery = anonymizeQueries ? anonymizer.anonymize(query) : query;
        final QueryGuid queryGuids = buildGuids(query, anonQuery);
        logger.log(level, buildPayload(message, anonQuery, queryGuids));
    } catch (ParsingException e) {
        if (logger.isDebugEnabled()) {
            Logger.getRootLogger().log(Level.DEBUG, String.format("Failed to parse a query in query logger, message: %s", message));
        }
    }
}
Also used : ParsingException(io.confluent.ksql.parser.ParsingException) QueryGuid(io.confluent.ksql.util.QueryGuid)

Aggregations

QueryGuid (io.confluent.ksql.util.QueryGuid)2 ParsingException (io.confluent.ksql.parser.ParsingException)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Test (org.junit.Test)1