mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-18 14:16:48 +00:00
feat(graphql): log query name if operation name is not provided (#10420)
This commit is contained in:
parent
34233deb51
commit
4ebc31c8c2
@ -119,14 +119,15 @@ public class GraphQLController {
|
||||
true, authentication, _authorizerChain, systemOperationContext, query, variables);
|
||||
Span.current().setAttribute("actor.urn", context.getActorUrn());
|
||||
|
||||
// operationName is an optional field only required if multiple operations are present
|
||||
final String queryName = operationName != null ? operationName : context.getQueryName();
|
||||
final String threadName = Thread.currentThread().getName();
|
||||
log.info(
|
||||
"Processing request, operation: {}, actor urn: {}", operationName, context.getActorUrn());
|
||||
log.info("Processing request, operation: {}, actor urn: {}", queryName, context.getActorUrn());
|
||||
log.debug("Query: {}, variables: {}", query, variables);
|
||||
|
||||
return CompletableFuture.supplyAsync(
|
||||
() -> {
|
||||
log.info("Executing operation {} for {}", operationName, threadName);
|
||||
log.info("Executing operation {} for {}", queryName, threadName);
|
||||
|
||||
/*
|
||||
* Execute GraphQL Query
|
||||
@ -149,13 +150,12 @@ public class GraphQLController {
|
||||
try {
|
||||
long totalDuration = submitMetrics(executionResult);
|
||||
String executionTook = totalDuration > 0 ? " in " + totalDuration + " ms" : "";
|
||||
log.info("Executed operation {}" + executionTook, operationName);
|
||||
log.info("Executed operation {}" + executionTook, queryName);
|
||||
// Remove tracing from response to reduce bulk, not used by the frontend
|
||||
executionResult.getExtensions().remove("tracing");
|
||||
String responseBodyStr =
|
||||
new ObjectMapper().writeValueAsString(executionResult.toSpecification());
|
||||
log.info(
|
||||
"Operation {} execution result size: {}", operationName, responseBodyStr.length());
|
||||
log.info("Operation {} execution result size: {}", queryName, responseBodyStr.length());
|
||||
log.trace("Execution result: {}", responseBodyStr);
|
||||
return new ResponseEntity<>(responseBodyStr, HttpStatus.OK);
|
||||
} catch (IllegalArgumentException | JsonProcessingException e) {
|
||||
|
@ -17,6 +17,7 @@ public class SpringQueryContext implements QueryContext {
|
||||
private final boolean isAuthenticated;
|
||||
private final Authentication authentication;
|
||||
private final Authorizer authorizer;
|
||||
@Getter private final String queryName;
|
||||
@Nonnull private final OperationContext operationContext;
|
||||
|
||||
public SpringQueryContext(
|
||||
@ -30,7 +31,7 @@ public class SpringQueryContext implements QueryContext {
|
||||
this.authentication = authentication;
|
||||
this.authorizer = authorizer;
|
||||
|
||||
String queryName =
|
||||
this.queryName =
|
||||
new Parser()
|
||||
.parseDocument(jsonQuery).getDefinitions().stream()
|
||||
.filter(def -> def instanceof OperationDefinition)
|
||||
|
Loading…
x
Reference in New Issue
Block a user