|
1 | 1 | [[observability]]
|
2 | 2 | = Observability
|
3 | 3 |
|
4 |
| -https://micrometer.io/docs/observation |
5 |
| -{spring-framework-ref-docs}/integration.html#integration.observability |
6 |
| -{spring-boot-ref-docs}/actuator.html#actuator.metrics |
| 4 | +https://micrometer.io/docs/observation[Observability support with Micrometer] is directly instrumented in Spring for GraphQL. |
| 5 | +This enables both metrics and traces for GraphQL requests and "non-trivial" data fetching operations. |
| 6 | +Because the GraphQL engine operates on top of a transport layer, you should also {spring-framework-ref-docs}/integration.html#integration.observability[expect observations from the transport], if supported in Spring Framework. |
| 7 | + |
| 8 | +Observations are only published if an `ObservationRegistry` is configured in the application. |
| 9 | +You can learn more about {spring-boot-ref-docs}/actuator.html#actuator.metrics[configuring the observability infrastructure in Spring Boot]. |
| 10 | +If you would like to customize the metadata produced with the GraphQL observations, you can {spring-framework-ref-docs}/integration.html#integration.observability.config.conventions[configure a custom convention on the instrumentation directly]. |
| 11 | +If your application is using Spring Boot, contributing the custom convention as a bean is the preferred way. |
| 12 | + |
| 13 | +[[observability.server.request]] |
| 14 | +== Server Requests instrumentation |
| 15 | + |
| 16 | +GraphQL Server Requests observations are created with the name `"graphql.request"` for Servlet and Reactive applications and above all supported transports. |
| 17 | +Applications need to configure the `org.springframework.graphql.observation.GraphQlObservationInstrumentation` instrumentation in their application. |
| 18 | +It is using the `org.springframework.graphql.observation.DefaultExecutionRequestObservationConvention` by default, backed by the `ExecutionRequestObservationContext`. |
| 19 | + |
| 20 | +By default, the following KeyValues are created: |
| 21 | + |
| 22 | +.Low cardinality Keys |
| 23 | +[cols="a,a"] |
| 24 | +|=== |
| 25 | +|Name | Description |
| 26 | +|`graphql.operation` _(required)_|GraphQL Operation name. |
| 27 | +|`graphql.outcome` _(required)_|Outcome of the GraphQL request. |
| 28 | +|=== |
| 29 | + |
| 30 | +The `graphql.operation` KeyValue will use the custom name of the provided query, or http://spec.graphql.org/draft/#sec-Language.Operations[the standard name for the operation] if none (`"query"`, `"mutation"` or `"subscription"`). |
| 31 | +The `graphql.outcome` KeyValue will be `"SUCCESS"` if a valid GraphQL response has been sent, `"REQUEST_ERROR"` if the request could not be parsed, or `"INTERNAL_ERROR"` if no valid GraphQL response could be produced. |
| 32 | + |
| 33 | +.High cardinality Keys |
| 34 | +[cols="a,a"] |
| 35 | +|=== |
| 36 | +|Name | Description |
| 37 | +|`graphql.execution.id` _(required)_|`graphql.execution.ExecutionId` of the GraphQL request. |
| 38 | +|=== |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +[[observability.server.datafetcher]] |
| 43 | +== DataFetcher instrumentation |
| 44 | + |
| 45 | +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). |
| 46 | +Applications need to configure the `org.springframework.graphql.observation.GraphQlObservationInstrumentation` instrumentation in their application. |
| 47 | +It is using the `org.springframework.graphql.observation.DefaultDataFetcherObservationConvention` by default, backed by the `DataFetcherObservationContext`. |
| 48 | + |
| 49 | +By default, the following KeyValues are created: |
| 50 | + |
| 51 | +.Low cardinality Keys |
| 52 | +[cols="a,a"] |
| 53 | +|=== |
| 54 | +|Name | Description |
| 55 | +|`graphql.error.type` _(required)_|Class name of the data fetching error |
| 56 | +|`graphql.field.name` _(required)_|Name of the field being fetched. |
| 57 | +|`graphql.outcome` _(required)_|Outcome of the GraphQL data fetching operation, "SUCCESS" or "ERROR". |
| 58 | +|=== |
| 59 | + |
| 60 | + |
| 61 | +.High cardinality Keys |
| 62 | +|=== |
| 63 | +|Name | Description |
| 64 | +|`graphql.field.path` _(required)_|Path to the field being fetched (for example, "/bookById"). |
| 65 | +|=== |
0 commit comments