Observability
Observability support with Micrometer直接用 Spring for GraphQL 中的工具记录。这同时支持度量标准和 GraphQL 请求的跟踪以及“非平凡”数据提取操作。由于 GraphQL 引擎运行在传输层之上,你也应该 预期传输的观察结果(如果在 Spring Framework 中受支持)。
Observability support with Micrometer is directly instrumented in Spring for GraphQL. This enables both metrics and traces for GraphQL requests and "non-trivial" data fetching operations. Because the GraphQL engine operates on top of a transport layer, you should also expect observations from the transport, if supported in Spring Framework.
仅在应用程序中配置 `ObservationRegistry`时才会发布观察结果。你可以详细了解 配置 Spring Boot 中的可观察性基础设施。如果你想自定义与 GraphQL 观察结果一起产生的元数据,则可以直接在工具上 配置自定义惯例。如果你的应用程序正在使用 Spring Boot,则首选方式是将自定义惯例作为一个 bean 贡献出来。
Observations are only published if an ObservationRegistry
is configured in the application.
You can learn more about configuring the observability infrastructure in Spring Boot.
If you would like to customize the metadata produced with the GraphQL observations, you can configure a custom convention on the instrumentation directly.
If your application is using Spring Boot, contributing the custom convention as a bean is the preferred way.
Server Requests instrumentation
对于传统和反应式应用程序以及所有受支持的传输,GraphQL 服务器请求观察结果使用名称 "graphql.request"
创建。此工具假定必须在 GraphQL 上下文中使用众所周知的 "micrometer.observation"
键将任何父观察结果设置为当前观察结果。对于跨网络边界的跟踪传播,必须由传输层中的单独工具负责。在 HTTP 的情况下,Spring Framework 具有专门的工具来处理跟踪传播。
GraphQL Server Requests observations are created with the name "graphql.request"
for traditional and Reactive applications and above all supported transports.
This instrumentation assumes that any parent observation must be set as the current one on the GraphQL context with the well-known "micrometer.observation"
key.
For trace propagation across network boundaries, a separate instrumentation at the transport level must be in charge.
In the case of HTTP, Spring Framework has dedicated instrumentation that takes care of trace propagation.
应用程序需要在其应用程序中配置 org.springframework.graphql.observation.GraphQlObservationInstrumentation
检测机制。它默认使用 org.springframework.graphql.observation.DefaultExecutionRequestObservationConvention
,由 ExecutionRequestObservationContext
支持。
Applications need to configure the org.springframework.graphql.observation.GraphQlObservationInstrumentation
instrumentation in their application.
It is using the org.springframework.graphql.observation.DefaultExecutionRequestObservationConvention
by default, backed by the ExecutionRequestObservationContext
.
默认情况下,将创建以下 KeyValues:
By default, the following KeyValues are created:
Name |
Description |
|
GraphQL Operation name. |
|
Outcome of the GraphQL request. |
graphql.operation
KeyValue 将使用提供的查询的自定义名称,如果没有则使用 the standard name for the operation("query"
、"mutation"
或 "subscription"
)。如果已发送有效的 GraphQL 响应,则 graphql.outcome
KeyValue 将为 "SUCCESS"
;如果无法解析请求,则为 "REQUEST_ERROR"
;如果无法生成有效的 GraphQL 响应,则为 "INTERNAL_ERROR"
。
The graphql.operation
KeyValue will use the custom name of the provided query, or the standard name for the operation if none ("query"
, "mutation"
or "subscription"
).
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.
Name |
Description |
|
|
Spring for GraphQL 还为服务器请求观察结果提供事件。 Micrometer Observation Events 通常作为跟踪中的跨度注释进行处理。此工具记录在 GraphQL 响应中列出的错误作为事件。
Spring for GraphQL also contributes Events for Server Request Observations. Micrometer Observation Events are usually handled as span annotations in traces. This instrumentation records errors listed in the GraphQL response as events.
Name |
Contextual Name |
the GraphQL error type, e.g. |
the full GraphQL error message, e.g. |
DataFetcher instrumentation
GraphQL DataFetcher 观测以名称 "graphql.datafetcher"
创建,仅用于被视为“非平凡”的数据获取操作(在 Java 对象上获取属性是平凡操作)。应用程序需要在其应用程序中配置 org.springframework.graphql.observation.GraphQlObservationInstrumentation
检测机制。它默认使用 org.springframework.graphql.observation.DefaultDataFetcherObservationConvention
,由 DataFetcherObservationContext
支持。
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
.
默认情况下,将创建以下 KeyValues:
By default, the following KeyValues are created:
Name |
Description |
|
Class name of the data fetching error |
|
Name of the field being fetched. |
|
Outcome of the GraphQL data fetching operation, "SUCCESS" or "ERROR". |
Name |
Description |
|
Path to the field being fetched (for example, "/bookById"). |