Skip to content

Record response errors as events in Request Observations #859

Closed
@stefaniasm

Description

@stefaniasm

Project details:
Spring Boot project, having:

  • org.springframework.boot' version '3.1.5'
  • spring-boot-starter-graphql:3.0.1
  • spring-boot-starter-actuator
  • spring-boot-starter-aop
  • no custom handlers, filters or error handling

According to this doc: https://docs.spring.io/spring-graphql/reference/observability.html#observability.server.request, by default, in case of data fetching errors, the graphql.error.type should be created and have an appropriate value.
But in case of Spring GraphQL, from what I know, read and debugged, errors (any GraphQl Error, for instance a ValidationError) are resolved and returned in "error" field in response, there is no Throwable exception thrown.

Having all this info, I noticed the following check in DefaultDataFetcherObservationConvention, when errorType is saved:

	protected KeyValue errorType(DataFetcherObservationContext context) {
		if (context.getError() != null) {
			return KeyValue.of(DataFetcherLowCardinalityKeyNames.ERROR_TYPE, context.getError().getClass().getSimpleName());
		} return ERROR_TYPE_NONE;
	}

context.getError() refers to a Throwable error, which is missing in the case described above. So the key is not created in case of a ValidationError, even if I expect it to be there. I am mentioning that for a successful request, I can see the key with default value NONE created, so the configurations should be ok.

Is this the intended behaviour?
If yes..then in what case I will have the DataFetcherLowCardinalityKeyNames.ERROR_TYPE populated with a different value than the default one?
If yes, does that mean that in order to collect informations about GraphQL errors I should do something custom, like a filter or a handler?

Thank you in advance!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions