feat(server): greatly optimizing Branch.commits & Query.streams, when limit=0 (#3863)
* fix(server): optimize Branch.commits resolver * feat(server): optimizing Query.streams a bit too * fix(server): gql error req duplicate entries logged
This commit is contained in:
committed by
GitHub
parent
71b82f2cb2
commit
b074a4a13a
@@ -107,37 +107,44 @@ export const loggingPluginFactory: (deps: {
|
||||
apollo_query_duration_ms: Date.now() - apolloRequestStart
|
||||
})
|
||||
|
||||
for (const err of ctx.errors) {
|
||||
const operationName = ctx.request.operationName || null
|
||||
const query = ctx.request.query
|
||||
const variables = redactSensitiveVariables(ctx.request.variables)
|
||||
const operationName = ctx.request.operationName || null
|
||||
const query = ctx.request.query
|
||||
const variables = redactSensitiveVariables(ctx.request.variables)
|
||||
|
||||
const reqCtx = getRequestContext()
|
||||
if (reqCtx) {
|
||||
logger = logger.child({
|
||||
dbMetrics: reqCtx.dbMetrics
|
||||
})
|
||||
}
|
||||
const reqCtx = getRequestContext()
|
||||
if (reqCtx) {
|
||||
logger = logger.child({
|
||||
dbMetrics: reqCtx.dbMetrics
|
||||
})
|
||||
}
|
||||
|
||||
if (err.path) {
|
||||
logger = logger.child({
|
||||
'query-path': err.path.join(' > '),
|
||||
graphql_operation_name: operationName,
|
||||
graphql_query: query,
|
||||
graphql_variables: variables
|
||||
})
|
||||
}
|
||||
if (shouldLogAsInfoLevel(err)) {
|
||||
logger.info(
|
||||
{ err },
|
||||
'{graphql_operation_title} failed after {apollo_query_duration_ms} ms'
|
||||
)
|
||||
} else {
|
||||
logger.error(
|
||||
err,
|
||||
'{graphql_operation_title} failed after {apollo_query_duration_ms} ms'
|
||||
)
|
||||
}
|
||||
const importantError = ctx.errors.find((err) => !shouldLogAsInfoLevel(err))
|
||||
const firstError = ctx.errors[0]
|
||||
const loggableError = importantError || firstError
|
||||
|
||||
logger = logger.child({
|
||||
error_count: loggableError ? ctx.errors.length : undefined,
|
||||
first_error: loggableError
|
||||
? {
|
||||
message: loggableError.message,
|
||||
path: loggableError.path?.join(' > ')
|
||||
}
|
||||
: {},
|
||||
graphql_operation_name: operationName,
|
||||
graphql_query: query,
|
||||
graphql_variables: variables
|
||||
})
|
||||
|
||||
if (!importantError) {
|
||||
logger.info(
|
||||
{ err: firstError },
|
||||
'{graphql_operation_title} failed after {apollo_query_duration_ms} ms'
|
||||
)
|
||||
} else {
|
||||
logger.error(
|
||||
{ err: importantError },
|
||||
'{graphql_operation_title} failed after {apollo_query_duration_ms} ms'
|
||||
)
|
||||
}
|
||||
},
|
||||
willSendResponse: async (ctx) => {
|
||||
|
||||
Reference in New Issue
Block a user