Bug description
The span produced for ToolCallingAdvisor is named tool _calling : there is a
space before _calling and a trailing space at the end. Tool calling is on by
default, so this appears in every trace where the model calls a tool.
Environment
Spring AI 2.0.0, Spring Boot 4.1.0, Java 21. Anthropic chat model with tool
callbacks supplied by an MCP client. Traces exported over OTLP to the
OpenTelemetry Collector. The same code is present on main.
Steps to reproduce
- Build a
ChatClient with tool callbacks and tracing to an OTLP endpoint.
- Send a prompt that makes the model call a tool.
- Read the span names.
From the Collector's debug exporter, piped through cat -A so that $ marks
end of line:
Name : tool _calling $
Name : spring_ai chat_client$
Name : call$
Expected behavior
A span name with no embedded or trailing whitespace, for example tool_calling.
Minimal Complete Reproducible example
https://github.com/kycasdzxc/spring-ai-otel-example
docker compose up -d, run the app, then ask a question that triggers a tool
call. The malformed name appears in the collector output and in Tempo.
The minimal condition is narrower than that project: any advisor whose
getName() returns a string containing spaces reproduces it. ToolCallingAdvisor
is built in, so no custom advisor is needed.
Root cause
DefaultAdvisorObservationConvention#getContextualName:
return ParsingUtils.reConcatenateCamelCase(context.getAdvisorName(), "_")
.replace("_around_advisor", "")
.replace("_advisor", "");
reConcatenateCamelCase splits on camelCase boundaries, so it expects an
identifier such as ToolCallingAdvisor. ToolCallingAdvisor#getName() returns
the display form "Tool Calling Advisor", and splitting that leaves the original
spaces attached to each token:
"Tool Calling Advisor"
-> ["Tool ", "Calling ", "Advisor"]
-> "tool _calling _advisor"
-> replace("_advisor", "") -> "tool _calling "
Advisors whose name contains no spaces are unaffected: call stays call.
Either normalising whitespace in getContextualName or having advisors supply an
identifier-shaped name would fix it.
Bug description
The span produced for
ToolCallingAdvisoris namedtool _calling: there is aspace before
_callingand a trailing space at the end. Tool calling is on bydefault, so this appears in every trace where the model calls a tool.
Environment
Spring AI 2.0.0, Spring Boot 4.1.0, Java 21. Anthropic chat model with tool
callbacks supplied by an MCP client. Traces exported over OTLP to the
OpenTelemetry Collector. The same code is present on
main.Steps to reproduce
ChatClientwith tool callbacks and tracing to an OTLP endpoint.From the Collector's debug exporter, piped through
cat -Aso that$marksend of line:
Expected behavior
A span name with no embedded or trailing whitespace, for example
tool_calling.Minimal Complete Reproducible example
https://github.com/kycasdzxc/spring-ai-otel-example
docker compose up -d, run the app, then ask a question that triggers a toolcall. The malformed name appears in the collector output and in Tempo.
The minimal condition is narrower than that project: any advisor whose
getName()returns a string containing spaces reproduces it.ToolCallingAdvisoris built in, so no custom advisor is needed.
Root cause
DefaultAdvisorObservationConvention#getContextualName:reConcatenateCamelCasesplits on camelCase boundaries, so it expects anidentifier such as
ToolCallingAdvisor.ToolCallingAdvisor#getName()returnsthe display form
"Tool Calling Advisor", and splitting that leaves the originalspaces attached to each token:
Advisors whose name contains no spaces are unaffected:
callstayscall.Either normalising whitespace in
getContextualNameor having advisors supply anidentifier-shaped name would fix it.