diff --git a/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java b/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java index 1c4f2824c6357..184379d44a7ad 100644 --- a/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java +++ b/metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java @@ -24,7 +24,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; @@ -193,12 +192,14 @@ private void submitMetrics(ExecutionResult executionResult) { // Extract top level resolver, parent is top level query. Assumes single query per call. List> resolvers = (List>) executionData.get("resolvers"); - Optional> parentResolver = - resolvers.stream() - .filter(resolver -> resolver.get("parentType").equals("Query")) - .findFirst(); String fieldName = - parentResolver.isPresent() ? (String) parentResolver.get().get("fieldName") : "UNKNOWN"; + resolvers.stream() + .filter( + resolver -> List.of("Query", "Mutation").contains(resolver.get("parentType"))) + .findFirst() + .map(parentResolver -> parentResolver.get("fieldName")) + .map(Object::toString) + .orElse("UNKNOWN"); MetricUtils.get() .histogram(MetricRegistry.name(this.getClass(), fieldName)) .update(totalDuration);