Observability
Spring AI 基于 Spring 生态系统中的可观察性功能,提供对 AI 相关操作的洞察。Spring AI 为其核心组件提供指标和跟踪功能: ChatClient
(包括 Advisor
)、 ChatModel
、 EmbeddingModel
、 ImageModel
和 VectorStore
。
Spring AI builds upon the observability features in the Spring ecosystem to provide insights into AI-related operations.
Spring AI provides metrics and tracing capabilities for its core components: ChatClient
(including Advisor
),
ChatModel
, EmbeddingModel
, ImageModel
, and VectorStore
.
低基数键将被添加到指标和跟踪中,而高基数键将只被添加到跟踪中。 |
Low cardinality keys will be added to metrics and traces, while high cardinality keys will only be added to traces. |
1.0.0-RC1 Breaking Changes
1.0.0-RC1 Breaking Changes
以下配置属性已重命名以更好地反映其用途:
Following configuration properties have been renamed to better reflect their purpose:
-
spring.ai.chat.client.observations.include-prompt
→spring.ai.chat.client.observations.log-prompt
-
spring.ai.chat.observations.include-prompt
→spring.ai.chat.observations.log-prompt
-
spring.ai.chat.observations.include-completion
→spring.ai.chat.observations.log-completion
-
spring.ai.image.observations.include-prompt
→spring.ai.image.observations.log-prompt
-
spring.ai.vectorstore.observations.include-query-response
→spring.ai.vectorstore.observations.log-query-response
Chat Client
spring.ai.chat.client
观测在调用 ChatClient 的 call()
或 stream()
操作时记录。它们测量执行调用所花费的时间并传播相关的追踪信息。
The spring.ai.chat.client
observations are recorded when a ChatClient call()
or stream()
operations are invoked.
They measure the time spent performing the invocation and propagate the related tracing information.
Name | Description |
---|---|
|
Always |
|
Always |
|
Is the chat model response a stream - |
|
The kind of framework API in Spring AI: |
Name | Description |
---|---|
|
The content of the prompt sent via the chat client. Optional. |
|
Map of advisor parameters. The conversation ID is now included in |
|
List of configured chat client advisors. |
|
Identifier of the conversation when using the chat memory. |
|
Chat client system parameters. Optional. Superseded by |
|
Chat client system text. Optional. Superseded by |
|
Enabled tool function names. Superseded by |
|
List of configured chat client function callbacks. Superseded by |
|
Names of the tools passed to the chat client. |
|
Chat client user parameters. Optional. Superseded by |
|
Chat client user text. Optional. Superseded by |
Prompt Content
ChatClient
提示内容通常很大,可能包含敏感信息。因此,默认情况下不导出。
The ChatClient
prompt content is typically big and possibly containing sensitive information.
For those reasons, it is not exported by default.
Spring AI 支持记录提示内容以帮助调试和故障排除。
Spring AI supports logging the prompt content to help with debugging and troubleshooting.
Property | Description | Default |
---|---|---|
|
Whether to log the chat client prompt content. |
|
如果启用聊天客户端提示内容的日志记录,则存在暴露敏感或私人信息的风险。请小心!
If you enable logging of the chat client prompt content, there’s a risk of exposing sensitive or private information. Please, be careful!
Input Data (Deprecated)
spring.ai.chat.client.observations.include-input
属性已弃用,由 spring.ai.chat.client.observations.log-prompt
替换。请参阅 Prompt Content 。
The spring.ai.chat.client.observations.include-input
property is deprecated, replaced by spring.ai.chat.client.observations.log-prompt
. See _prompt_content.
ChatClient
输入数据通常很大,可能包含敏感信息。因此,默认情况下不导出。
The ChatClient
input data is typically big and possibly containing sensitive information.
For those reasons, it is not exported by default.
Spring AI 支持记录输入数据以帮助调试和故障排除。
Spring AI supports logging input data to help with debugging and troubleshooting.
Property | Description | Default |
---|---|---|
|
Whether to include the input content in the observations. |
|
如果启用在观测中包含输入内容,则存在暴露敏感或私人信息的风险。请小心!
If you enable the inclusion of the input content in the observations, there’s a risk of exposing sensitive or private information. Please, be careful!
Chat Client Advisors
spring.ai.advisor
观测在执行顾问时记录。它们测量顾问中花费的时间(包括内部顾问中花费的时间)并传播相关的追踪信息。
The spring.ai.advisor
observations are recorded when an advisor is executed.
They measure the time spent in the advisor (including the time spend on the inner advisors) and propagate the related tracing information.
Name | Description |
---|---|
|
Always |
|
Always |
|
Where the advisor applies it’s logic in the request processing, one of |
|
The kind of framework API in Spring AI: |
Name | Description |
---|---|
|
Name of the advisor. |
|
Advisor order in the advisor chain. |
Chat Model
可观测性功能目前仅支持来自以下 AI 模型提供商的 |
Observability features are currently supported only for |
gen_ai.client.operation
观测在调用 ChatModel 的 call
或 stream
方法时记录。它们测量方法完成所花费的时间并传播相关的追踪信息。
The gen_ai.client.operation
observations are recorded when calling the ChatModel call
or stream
methods.
They measure the time spent on method completion and propagate the related tracing information.
gen_ai.client.token.usage
指标测量单个模型调用使用的输入和输出令牌数量。
The gen_ai.client.token.usage
metrics measures number of input and output tokens used by a single model call.
Name | Description |
---|---|
|
The name of the operation being performed. |
|
The model provider as identified by the client instrumentation. |
|
The name of the model a request is being made to. |
|
The name of the model that generated the response. |
Name | Description |
---|---|
|
The frequency penalty setting for the model request. |
|
The maximum number of tokens the model generates for a request. |
|
The presence penalty setting for the model request. |
|
List of sequences that the model will use to stop generating further tokens. |
|
The temperature setting for the model request. |
|
The top_k sampling setting for the model request. |
|
The top_p sampling setting for the model request. |
|
Reasons the model stopped generating tokens, corresponding to each generation received. |
|
The unique identifier for the AI response. |
|
The number of tokens used in the model input (prompt). |
|
The number of tokens used in the model output (completion). |
|
The total number of tokens used in the model exchange. |
|
The full prompt sent to the model. Optional. |
|
The full response received from the model. Optional. |
|
List of tool definitions provided to the model in the request. |
为了测量用户令牌,上表列出了观测追踪中存在的值。使用 |
For measuring user tokens, the previous table lists the values present in an observation trace.
Use the metric name |
Chat Prompt and Completion Data
聊天提示和完成数据通常很大,可能包含敏感信息。因此,默认情况下不导出。
The chat prompt and completion data is typically big and possibly containing sensitive information. For those reasons, it is not exported by default.
Spring AI 支持记录聊天提示和完成数据,这对于故障排除场景非常有用。当追踪可用时,日志将包含追踪信息以实现更好的关联。
Spring AI supports logging chat prompt and completion data, useful for troubleshooting scenarios. When tracing is available, the logs will include trace information for better correlation.
Property | Description | Default |
---|---|---|
|
Log the prompt content. |
|
|
Log the completion content. |
|
|
Include error logging in observations. |
|
如果启用聊天提示和完成数据的日志记录,则存在暴露敏感或私人信息的风险。请小心!
If you enable logging of the chat prompt and completion data, there’s a risk of exposing sensitive or private information. Please, be careful!
Tool Calling
spring.ai.tool
观测在聊天模型交互的上下文中执行工具调用时记录。它们测量工具调用完成所花费的时间并传播相关的追踪信息。
The spring.ai.tool
observations are recorded when performing tool calling in the context of a chat model interaction. They measure the time spent on toll call completion and propagate the related tracing information.
Name | Description |
---|---|
|
The name of the operation being performed. It’s always |
|
The provider responsible for the operation. It’s always |
|
The kind of operation performed by Spring AI. It’s always |
|
The name of the tool. |
Name |
Description |
|
Description of the tool. |
|
Schema of the parameters used to call the tool. |
|
The input arguments to the tool call. (Only when enabled) |
|
Schema of the parameters used to call the tool. (Only when enabled) |
Tool Call Arguments and Result Data
工具调用的输入参数和结果默认情况下不导出,因为它们可能包含敏感信息。
The input arguments and result from the tool call are not exported by default, as they can be potentially sensitive.
Spring AI 支持将工具调用参数和结果数据导出为跨度属性。
Spring AI supports exporting tool call arguments and result data as span attributes.
Property | Description | Default |
---|---|---|
|
Include the tool call content in observations. |
|
如果您启用在观测中包含工具调用参数和结果,则存在暴露敏感或私有信息的风险。请务必小心!
If you enable the inclusion of the tool call arguments and result in the observations, there’s a risk of exposing sensitive or private information. Please, be careful!
EmbeddingModel
目前,可观测性功能仅支持以下 AI 模型提供商的 |
Observability features are currently supported only for |
gen_ai.client.operation
观测记录在嵌入模型方法调用上。它们测量方法完成所花费的时间并传播相关的跟踪信息。
The gen_ai.client.operation
observations are recorded on embedding model method calls.
They measure the time spent on method completion and propagate the related tracing information.
gen_ai.client.token.usage
指标测量单个模型调用使用的输入和输出令牌数量。
The gen_ai.client.token.usage
metrics measures number of input and output tokens used by a single model call.
Name | Description |
---|---|
|
The name of the operation being performed. |
|
The model provider as identified by the client instrumentation. |
|
The name of the model a request is being made to. |
|
The name of the model that generated the response. |
Name | Description |
---|---|
|
The number of dimensions the resulting output embeddings have. |
|
The number of tokens used in the model input. |
|
The total number of tokens used in the model exchange. |
为了测量用户令牌,上表列出了观测跟踪中存在的值。使用由 |
For measuring user tokens, the previous table lists the values present in an observation trace.
Use the metric name |
Image Model
目前,可观测性功能仅支持以下 AI 模型提供商的 |
Observability features are currently supported only for |
gen_ai.client.operation
观测记录在图像模型方法调用上。它们测量方法完成所花费的时间并传播相关的跟踪信息。
The gen_ai.client.operation
observations are recorded on image model method calls.
They measure the time spent on method completion and propagate the related tracing information.
gen_ai.client.token.usage
指标测量单个模型调用使用的输入和输出令牌数量。
The gen_ai.client.token.usage
metrics measures number of input and output tokens used by a single model call.
Name | Description |
---|---|
|
The name of the operation being performed. |
|
The model provider as identified by the client instrumentation. |
|
The name of the model a request is being made to. |
Name | Description |
---|---|
|
The format in which the generated image is returned. |
|
The size of the image to generate. |
|
The style of the image to generate. |
|
The unique identifier for the AI response. |
|
The name of the model that generated the response. |
|
The number of tokens used in the model input (prompt). |
|
The number of tokens used in the model output (generation). |
|
The total number of tokens used in the model exchange. |
|
The full prompt sent to the model. Optional. |
为了测量用户令牌,上表列出了观测跟踪中存在的值。使用由 |
For measuring user tokens, the previous table lists the values present in an observation trace.
Use the metric name |
Image Prompt Data
图像提示数据通常很大,可能包含敏感信息。因此,默认情况下不导出。
The image prompt data is typically big and possibly containing sensitive information. For those reasons, it is not exported by default.
Spring AI 支持记录图像提示数据,这对于故障排除场景很有用。当跟踪可用时,日志将包含跟踪信息以实现更好的关联。
Spring AI supports logging image prompt data, useful for troubleshooting scenarios. When tracing is available, the logs will include trace information for better correlation.
Property | Description | Default |
---|---|---|
|
Log the image prompt content. |
|
如果您启用图像提示数据的日志记录,则存在暴露敏感或私有信息的风险。请务必小心!
If you enable logging of the image prompt data, there’s a risk of exposing sensitive or private information. Please, be careful!
Vector Stores
Spring AI 中的所有向量存储实现都经过检测,可通过 Micrometer 提供指标和分布式跟踪数据。
All vector store implementations in Spring AI are instrumented to provide metrics and distributed tracing data through Micrometer.
db.vector.client.operation
观测记录在与向量存储交互时。它们测量 query
、 add
和 remove
操作所花费的时间并传播相关的跟踪信息。
The db.vector.client.operation
observations are recorded when interacting with the Vector Store.
They measure the time spent on the query
, add
and remove
operations and propagate the related tracing information.
Name | Description |
---|---|
|
The name of the operation or command being executed. One of |
|
The database management system (DBMS) product as identified by the client instrumentation. One of |
|
The kind of framework API in Spring AI: |
Name | Description |
---|---|
|
The name of a collection (table, container) within the database. |
|
The name of the database, fully qualified within the server address and port. |
|
The record identifier if present. |
|
The metric used in similarity search. |
|
The dimension of the vector. |
|
The name field as of the vector (e.g. a field name). |
|
The content of the search query being executed. |
|
The metadata filters used in the search query. |
|
Returned documents from a similarity search query. Optional. |
|
Similarity threshold that accepts all search scores. A threshold value of 0.0 means any similarity is accepted or disable the similarity threshold filtering. A threshold value of 1.0 means an exact match is required. |
|
The top-k most similar vectors returned by a query. |
Response Data
向量搜索响应数据通常很大,可能包含敏感信息。因此,默认情况下不导出。
The vector search response data is typically big and possibly containing sensitive information. For those reasons, it is not exported by default.
Spring AI 支持记录向量搜索响应数据,这对于故障排除场景很有用。当跟踪可用时,日志将包含跟踪信息以实现更好的关联。
Spring AI supports logging vector search response data, useful for troubleshooting scenarios. When tracing is available, the logs will include trace information for better correlation.
Property | Description | Default |
---|---|---|
|
Log the vector store query response content. |
|
如果您启用向量搜索响应数据的日志记录,则存在暴露敏感或私有信息的风险。请务必小心!
If you enable logging of the vector search response data, there’s a risk of exposing sensitive or private information. Please, be careful!