Skip to main content
Version: 2.1.1 (Latest)

Observability

Spring AI Watsonx.ai records Micrometer observations for chat, embedding, rerank and text extraction calls. With Spring Boot Actuator and a metrics or tracing backend on the classpath, they appear as metrics and spans without extra code. The models take an ObservationRegistry, and Spring Boot auto-configuration supplies it.

Observations​

ModelObservationConvention
ChatSpring AI ChatModelObservationDocumentationDefaultChatModelObservationConvention
EmbeddingsSpring AI EmbeddingModelObservationDocumentationSpring AI default convention
RerankRerankModelObservationDocumentationDefaultRerankModelObservationConvention
Text extractionTextExtractionModelObservationDocumentationDefaultTextExtractionModelObservationConvention

Chat and embedding observations use the standard Spring AI key names. See the Spring AI observability documentation for those.

Rerank​

Low cardinality: gen_ai.operation.name, gen_ai.system, gen_ai.request.model, gen_ai.response.model.

High cardinality: gen_ai.rerank.document_count, gen_ai.rerank.top_n, gen_ai.usage.input_tokens.

Text extraction​

The observation name is gen_ai.client.operation.

Low cardinality: gen_ai.operation.name, gen_ai.system, gen_ai.request.model, and gen_ai.text_extraction.status, the extraction job status or unknown.

High cardinality: gen_ai.text_extraction.document_name, gen_ai.text_extraction.page_count.

Custom conventions​

With auto-configuration, declare a single bean of the convention type and it is applied to the model: ChatModelObservationConvention, EmbeddingModelObservationConvention, RerankModelObservationConvention or TextExtractionModelObservationConvention.

@Bean
RerankModelObservationConvention rerankObservationConvention() {
return new MyRerankObservationConvention();
}

Without auto-configuration, call the model's setObservationConvention(...) method:

rerankModel.setObservationConvention(new MyRerankObservationConvention());

watsonx.ai warnings​

watsonx.ai returns warnings in system.warnings, such as the date a model is deprecated or withdrawn. Chat, embedding and rerank calls log them at DEBUG level (since 2.1.0), and chat and embedding responses also carry them in their metadata under warnings. watsonx.ai repeats a warning in every response, and each one is logged:

logging:
level:
org.springaicommunity.watsonx.util.WatsonxAiWarnings: DEBUG