Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include information on whether a query is using SSQE or MSQE in QueryLogger #14938

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,37 @@ public static class QueryLogParams {
private final RequestContext _requestContext;
private final String _table;
private final BrokerResponse _response;
private final QueryEngine _queryEngine;
@Nullable
private final RequesterIdentity _identity;
@Nullable
private final ServerStats _serverStats;

public QueryLogParams(RequestContext requestContext, String table, BrokerResponse response,
@Nullable RequesterIdentity identity, @Nullable ServerStats serverStats) {
QueryEngine queryEngine, @Nullable RequesterIdentity identity, @Nullable ServerStats serverStats) {
_requestContext = requestContext;
// NOTE: Passing table name separately because table name within request context is always raw table name.
_table = table;
_response = response;
_queryEngine = queryEngine;
_identity = identity;
_serverStats = serverStats;
}

public enum QueryEngine {
SINGLE_STAGE("singleStage"),
MULTI_STAGE("multiStage");

private final String _name;

QueryEngine(String name) {
_name = name;
}

private String getName() {
return _name;
}
}
}

/**
Expand Down Expand Up @@ -255,6 +272,12 @@ void doFormat(StringBuilder builder, QueryLogger logger, QueryLogParams params)
builder.append(CommonConstants.UNKNOWN);
}
}
},
QUERY_ENGINE("queryEngine") {
@Override
void doFormat(StringBuilder builder, QueryLogger logger, QueryLogParams params) {
builder.append(params._queryEngine.getName());
}
};

public final String _entryName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,8 @@ protected BrokerResponse handleRequest(long requestId, String query, SqlNodeAndO

// Log query and stats
_queryLogger.log(
new QueryLogger.QueryLogParams(requestContext, tableName, brokerResponse, requesterIdentity, serverStats));
new QueryLogger.QueryLogParams(requestContext, tableName, brokerResponse,
QueryLogger.QueryLogParams.QueryEngine.SINGLE_STAGE, requesterIdentity, serverStats));

return brokerResponse;
} finally {
Expand Down Expand Up @@ -908,7 +909,8 @@ private BrokerResponseNative getEmptyBrokerOnlyResponse(PinotQuery pinotQuery, R
ParserUtils.fillEmptyResponseSchema(brokerResponse, _tableCache, schema, database, query);
brokerResponse.setTimeUsedMs(System.currentTimeMillis() - requestContext.getRequestArrivalTimeMillis());
_queryLogger.log(
new QueryLogger.QueryLogParams(requestContext, tableName, brokerResponse, requesterIdentity, null));
new QueryLogger.QueryLogParams(requestContext, tableName, brokerResponse,
QueryLogger.QueryLogParams.QueryEngine.SINGLE_STAGE, requesterIdentity, null));
return brokerResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ protected BrokerResponse handleRequest(long requestId, String query, SqlNodeAndO

// Log query and stats
_queryLogger.log(
new QueryLogger.QueryLogParams(requestContext, tableNames.toString(), brokerResponse, requesterIdentity,
null));
new QueryLogger.QueryLogParams(requestContext, tableNames.toString(), brokerResponse,
QueryLogger.QueryLogParams.QueryEngine.MULTI_STAGE, requesterIdentity, null));

return brokerResponse;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void shouldFormatLogLineProperly() {
+ "offlineThreadCpuTimeNs(total/thread/sysActivity/resSer):45/14/15/16,"
+ "realtimeThreadCpuTimeNs(total/thread/sysActivity/resSer):54/17/18/19,"
+ "clientIp=ip,"
+ "queryEngine=singleStage,"
+ "query=SELECT * FROM foo");
//@formatter:on
}
Expand Down Expand Up @@ -281,6 +282,7 @@ public String getClientIp() {
ServerStats serverStats = new ServerStats();
serverStats.setServerStats("serverStats");

return new QueryLogger.QueryLogParams(requestContext, "table", response, identity, serverStats);
return new QueryLogger.QueryLogParams(requestContext, "table", response,
QueryLogger.QueryLogParams.QueryEngine.SINGLE_STAGE, identity, serverStats);
}
}
Loading