Skip to content
Merged
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
20 changes: 13 additions & 7 deletions packages/cubejs-api-gateway/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ class ApiGateway {
this.log({
type: 'Query Rewrite completed',
queryRewriteId,
normalizedQueries,
normalizedQueries: normalizedQueries.map(q => this.sanitizeQueryForLogging(q)),
duration: Date.now() - startTime,
query
}, context);
Expand Down Expand Up @@ -1631,7 +1631,7 @@ class ApiGateway {
this.log({
type: 'Load Request SQL',
duration: this.duration(loadRequestSQLStarted),
query: normalizedQueries[index],
query: this.sanitizeQueryForLogging(normalizedQueries[index]),
sqlQuery
}, context);

Expand All @@ -1642,6 +1642,12 @@ class ApiGateway {
return sqlQueries;
}

private sanitizeQueryForLogging(query: NormalizedQuery): NormalizedQuery {
const res: NormalizedQuery = { ...query };
delete res.cacheMode;
return res;
}

/**
* Execute query and return adapter's result.
* @internal
Expand Down Expand Up @@ -2170,7 +2176,7 @@ class ApiGateway {

public async contextByReq(req: Request, securityContext, requestId: string): Promise<ExtendedRequestContext> {
req.securityContext = securityContext;

const extensions = typeof this.extendContext === 'function' ? await this.extendContext(req) : {};

return {
Expand Down Expand Up @@ -2205,31 +2211,31 @@ class ApiGateway {
if (e instanceof CubejsHandlerError) {
this.log({
type: e.type,
query,
query: this.sanitizeQueryForLogging(query),
error: e.message,
duration: this.duration(requestStarted)
}, context);
res({ error: e.message, stack, requestId, plainError }, { status: e.status });
} else if (e.error === 'Continue wait') {
this.log({
type: 'Continue wait',
query,
query: this.sanitizeQueryForLogging(query),
error: e.message,
duration: this.duration(requestStarted),
}, context);
res({ error: e.message || e.error.message || e.error.toString(), requestId }, { status: 200 });
} else if (e.error) {
this.log({
type: 'Orchestrator error',
query,
query: this.sanitizeQueryForLogging(query),
error: e.error,
duration: this.duration(requestStarted),
}, context);
res({ error: e.message || e.error.message || e.error.toString(), requestId }, { status: 400 });
} else if (e.type === 'UserError') {
this.log({
type: e.type,
query,
query: this.sanitizeQueryForLogging(query),
error: e.message,
duration: this.duration(requestStarted)
}, context);
Expand Down
Loading