Quick revision
The short answer
Spring AI instruments ChatClient, ChatModel, EmbeddingModel, advisors, tool calls and vector stores with Micrometer observations, so with Spring Boot Actuator we get timers, token usage metrics and traces without extra code. Token usage is tagged by provider and model, which makes cost dashboards possible, and names follow the generative AI semantic conventions (check your version). Prompt and completion content is not logged unless we enable it explicitly, because it may contain personal data. A good dashboard shows request and error rates, latency and time to first token, tokens and estimated cost per feature and tenant, retrieval hits and fallback rates, with traces linking the whole request.
What to remember
In this answer, we saw that Spring AI wraps ChatClient, ChatModel, EmbeddingModel, advisors, tool calls and vector stores in Micrometer observations, giving metrics and traces through Spring Boot Actuator without extra code. Token usage is tagged by provider and model for cost dashboards, with feature and tenant tags added by us. Prompt and completion logging is off by default for privacy, and a good dashboard covers rates, errors, latency, time to first token, tokens and cost, retrieval and fallbacks, with traces tying each request together.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Spring AI instruments ChatClient, ChatModel, EmbeddingModel, advisors, tool calls and vector stores with Micrometer observations, so with Spring Boot Actuator we get timers, token usage metrics and traces without extra code. Token usage is tagged by provider and model, which makes cost dashboards possible, and names follow the generative AI semantic conventions (check your version). Prompt and completion content is not logged unless we enable it explicitly, because it may contain personal data. A good dashboard shows request and error rates, latency and time to first token, tokens and estimated cost per feature and tenant, retrieval hits and fallback rates, with traces linking the whole request.
Why this question is asked
An AI feature fails in ways ordinary services do not. It can be slow because the model is busy, expensive because prompts grew, or wrong while returning HTTP 200. Without telemetry, every one of these shows up first as a user complaint or an invoice. Interviewers ask this question to see whether we know what Spring AI gives for free and what we still need to add. In this answer, we will recap Micrometer observations, see what Spring AI instruments, look at token metrics, discuss why content logging is off, design the dashboard and connect it all with traces.
1A Quick Recap of Micrometer Observations
Micrometer is the metrics and tracing facade that Spring Boot uses. Its Observation API lets a library wrap an operation once, and from that single wrapper we get a timer metric (how often and how long), and, if tracing is configured, a span in a distributed trace. Spring Boot Actuator exposes the metrics, for example to Prometheus at /actuator/prometheus, and a tracing bridge such as Micrometer Tracing with OpenTelemetry sends the spans to a tracing backend.
2What Spring AI Instruments
Spring AI creates observations around its main operations: the ChatClient call as a whole, each advisor in the chain, the ChatModel call to the provider, EmbeddingModel calls, tool calls the model requests, and vector store operations such as similarity searches and adds. Each observation carries low-cardinality tags such as the provider, the operation and the model, so we can group by them.
- ChatClient callwhole request through Spring AI
- Advisorsmemory, retrieval, our own
- Vector store querysimilarity search
- ChatModel callprovider, model, tokens
- Tool callseach tool the model invokes
5 layers, from the top down. Step through them one at a time.
Notice that we wrote no instrumentation code. The metrics appear because Spring AI wraps its operations and Actuator exports them. The exact metric and tag names follow the OpenTelemetry semantic conventions for generative AI, which have evolved, so we check the names our version produces before building dashboards on them.
3Token Usage and Cost
Token usage metrics count input and output tokens separately, tagged by provider and model. That is the raw material for cost: tokens times the price per token for that model. Because prices differ for input and output and between models, a dashboard computes cost per series, for example input tokens times the input price plus output tokens times the output price.
Spring AI cannot know business context such as which product feature or which customer tenant made the call. Those tags come from us. A small advisor or an ObservationFilter can add feature and tenant to the observations. We keep tag values to a bounded set: feature names and tenant ids are fine for a moderate number of tenants, but user ids or conversation ids would create millions of series and overload the metrics system; those belong in traces and logs.
4Why Content Logging Is Off by Default
The observations can include the prompt and completion text, but Spring AI keeps that off unless we turn it on with observation properties such as a log-prompt or log-completion setting (exact property names: check your version). The reason is simple: prompts contain whatever users type and whatever documents retrieval found, which often includes names, addresses, health details or internal secrets. Logging them by default would copy personal data into log systems with broad access and long retention, outside the controls we put on the main database. We enable it in development, or in production only for a short, approved debugging window, preferably with redaction and a restricted log destination.
5Designing the Dashboard
A dashboard for an AI feature combines the usual service health with signals specific to models. We want to see at a glance whether it is up, fast, affordable and behaving normally.
| Panel | Why it matters |
|---|---|
| Requests per second | traffic and sudden drops |
| Error rate by type | 429, timeouts, 5xx, content policy, parse errors |
| Latency p50 and p95; time to first token | what users feel, especially for streams |
| Input and output tokens per request | early warning of prompt growth |
| Estimated cost per feature and tenant | attribution and budget alerts |
| Retrieval hits and empty results | RAG quality; empty means no context |
| Fallback and retry rates | provider health and degraded mode |
| Tool call count and failures | agent loops and broken tools |
6Connecting It All With Traces
Metrics tell us that something is wrong; traces tell us where. Because Spring AI's observations become spans, one user request shows as a tree: the HTTP request, the ChatClient call, the memory advisor, the vector store query, the model call and any tool calls, each with its duration. When a request takes 14 seconds, the trace shows whether it was 12 seconds in the model, 2 seconds in a slow vector query, or three tool calls in a row. For that to work, the trace context must flow from the incoming request into the Spring AI calls, which happens automatically on the same thread and needs context propagation for reactive streams and async work.
7Follow-up questions
Why should prompt logging stay off in production by default?
Because prompts and completions carry personal and confidential data from users and retrieved documents. Logs are usually widely readable, copied to several systems and kept for a long time, and they are rarely covered by deletion requests. Keeping it off protects privacy and compliance; when we need content for debugging or quality review, we capture a small, sampled, redacted set into a restricted store with short retention, and we enable full logging only briefly with approval.
Which metric warns first about a cost problem?
Input tokens per request. Prompt growth from longer histories, more retrieved chunks or a larger system prompt shows up there days before it shows on the invoice.
Does observability cover streaming calls?
Yes, streaming calls are observed too, but token usage often arrives only at the end of the stream, and time to first token should be measured explicitly because total duration alone hides it.
8Conclusion
In this answer, we saw that Spring AI wraps ChatClient, ChatModel, EmbeddingModel, advisors, tool calls and vector stores in Micrometer observations, giving metrics and traces through Spring Boot Actuator without extra code. Token usage is tagged by provider and model for cost dashboards, with feature and tenant tags added by us. Prompt and completion logging is off by default for privacy, and a good dashboard covers rates, errors, latency, time to first token, tokens and cost, retrieval and fallbacks, with traces tying each request together.
Open with
Spring AI instruments its main operations with Micrometer observations: the ChatClient call, each advisor, the ChatModel call, EmbeddingModel calls, tool calls and vector store operations. With Spring Boot Actuator and a registry like Prometheus, I get timers and token usage metrics, and with Micrometer Tracing, spans, without writing instrumentation.
Then, if they want more
Token usage is counted as input and output tokens, tagged with provider and model, following the generative AI semantic conventions, so I can compute estimated cost per model; I check the exact names for our version. I add business tags like feature and tenant myself, with an advisor or observation filter, keeping cardinality bounded.
Logging of prompt and completion content is off by default and must be enabled through observation properties, which is right, because prompts contain personal data and logs are widely accessible.
On the dashboard I would show request rate, error rate by type such as 429 or timeouts, latency and time to first token, tokens per request and estimated cost per feature and tenant, retrieval hit counts and empty results, and fallback and retry rates.
And traces connect the user request, retrieval, model calls and tool calls, so I can see where time went.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring AI reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What observability does Spring AI provide out of the box for chat and embedding calls...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/a4e606265f/