Record response errors as events in Request Observations

Prior to this commit, GraphQL Request Observations would not record
errors as Observation errors, because with GraphQL errors can partially
affect the response and there can be multiple. Instead, an invalid
request (for example) would lead to a `"graphql.outcome", "REQUEST_ERROR"`
low cardinality KeyValue. In this case, developers would not know what
type of error occured nor if there were multiple.

This commit records all errors listed in the GraphQL as
Observation.Event on the request Observation. Such events are usually
handled by the tracing handler and are recorded as span annotations for
traces. Other `ObservationHandler` annotations can leverage events in a
different fashion.

Closes gh-859
This commit is contained in:
Brian Clozel
2024-02-13 23:20:11 +01:00
parent 98d39bc21d
commit c55de8d091
3 changed files with 67 additions and 6 deletions

View File

@@ -41,6 +41,16 @@ The `graphql.outcome` KeyValue will be `"SUCCESS"` if a valid GraphQL response h
|`graphql.execution.id` _(required)_|`graphql.execution.ExecutionId` of the GraphQL request.
|===
Spring for GraphQL also contributes Events for Server Request Observations.
https://docs.micrometer.io/micrometer/reference/observation/components.html#micrometer-observation-events[Micrometer Observation Events] are usually handled as span annotations in traces.
This instrumentation records errors listed in the GraphQL response as events.
.Observation Events
[cols="a,a"]
|===
|Name | Contextual Name
|the GraphQL error type, e.g. `InvalidSyntax`|the full GraphQL error message, e.g. `"Invalid syntax with offending token 'invalid'..."`
|===
[[observability.server.datafetcher]]