maple-agent-tracing-spring-ai
Installation
SKILL.md
Maple agent tracing for Spring AI
Goal: every conversation with the Spring AI app shows up in Maple Agent Sessions as exactly one session, one turn per ChatClient call, with transcript, model calls, tool calls (failures marked), sub-agent lanes and tokens.
Mechanism: Spring AI's Micrometer Observations → micrometer-tracing-bridge-otel → OpenTelemetry SDK → OTLP/HTTP to Maple, all from spring-boot-starter-opentelemetry. Out of the box: sampling is 10%, prompts/replies never reach spans (log-prompt/log-completion only log to SLF4J), and thrown tool errors end the span OK. Steps 2-5 fix all three.
Step 0: Detect versions and existing setup
- Read
pom.xml/build.gradle(.kts): Spring Boot version,spring-ai-bomversion, model starter (spring-ai-starter-model-*). Target Spring AI 2.0.x (verified 2.0.1) on Boot 4.x (verified 4.1.1), Java 17+. Spring AI 1.1.x on Boot 3.5: see Step 2d. - Grep for existing tracing:
micrometer-tracing-bridge,spring-boot-starter-opentelemetry,opentelemetry-exporter-otlp,management.otlp,management.opentelemetry,management.tracing,-javaagent,opentelemetry-javaagent,OTEL_EXPORTER_OTLP,ObservationFilter,ObservationPredicate,ToolExecutionExceptionProcessor.- Existing Boot tracing to another backend: Boot has one OTLP span exporter. Ask the user whether to repoint it at Maple; to keep both, add a second exporter via an
OtlpHttpSpanExporterbean only if they insist. - OTel Java agent attached (
-javaagent:...opentelemetry-javaagent.jar): see Step 2c. - Existing
ToolExecutionExceptionProcessorbean: patch it (Step 5) instead of adding the one in Step 3.
- Existing Boot tracing to another backend: Boot has one OTLP span exporter. Ask the user whether to repoint it at Maple; to keep both, add a second exporter via an
- Find every
ChatClientcall site (.prompt(,.call(),.stream()) and where the conversation/thread id lives in the request. Find everyChatClient.Builder(each role/sub-agent).