Spring Boot 3 Observability – collect GraphQL error metrics

Spring Boot 3 Observability – collect GraphQL error metrics


0

I’ve been working on adding monitoring metrics in our GraphQL gateway recently.

I have a Spring Boot project with the following dependencies:
‘org.springframework.boot’ version ‘3.1.5’
spring-boot-starter-graphql:3.0.1
spring-boot-starter-actuator
spring-boot-starter-aop
…[others not relevant]…

So I have a GraphQL server that typically returns an HTTP 200 status code for all responses and in case of an issue with the request, I will have "errors" field in the JSON response object.

I want to integrate/configure somehow Spring Boot 3 Observability into the project to collect and add to the metrics these GraphQL errors.
First I noticed that they mention this in doc:
Source: https://docs.spring.io/spring-graphql/reference/observability.html#observability.server.request

GraphQL DataFetcher observations are created with the name "graphql.datafetcher", only for data fetching operations that are considered as "non trivial" (property fetching on a Java object is a trivial operation). Applications need to configure the org.springframework.graphql.observation.GraphQlObservationInstrumentation instrumentation in their application. It is using the org.springframework.graphql.observation.DefaultDataFetcherObservationConvention by default, backed by the DataFetcherObservationContext.

And indeed, I tested (using zipkin) and for a successful query I have those keys:

Spring Boot 3 Observability - collect GraphQL error metrics

But in case of an error in query – for example missing braces or incorrect syntax, missing required field – those tags are not displayed anymore, even if I expected to be there with appropriate values:

Spring Boot 3 Observability - collect GraphQL error metrics

I am testing with non-trivial operations – for example a getAllEntities that search in database, does some filtering and mapping.

Even if graphql.error.type would be displayed, I am not sure is enough for my metrics. Is there any solution to collect metrics about these graphql errors in some way? Not sure how is best..I am new to this.

Did I understand something wrong?
How can I obtain the required behaviour?

Thanks in advance!


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *