In the browser
The click gets a name
@causeline/react wraps fetch and XHR. Wrap a handler in trace() and the click becomes the root of a trace, with every request and state update inside it.
Checkout.tsx
const onCheckout = () =>
trace('Checkout', async () => {
const res = await fetch('/api/orders', { method: 'POST', body });
setStatus(res.ok ? 'paid' : 'failed');
});
On the wire
The header carries it
Each request to your own API gets a W3C traceparent header: the trace ID, the span that sent it, and a sampled flag. Calls to other origins are left alone.
POST /api/orders
traceparent: 00-8969ad7e690b50a8721f9fd8e0e5c925-00f067aa0ba902b7-01
# trace id parent span sampled
In Spring Boot
Spring Boot joins in
The starter reads the header and builds on Micrometer Observation. Controllers, @Observed services, repositories, transactions, JDBC and R2DBC queries, outbound calls and messages become spans in the same trace.
- REQUESTPOST /api/orders925 ms
- CONTROLLEROrderController.createOrder915 ms
- TRANSACTIONOrderService.createOrder907 ms
- DATABASEinsert into orders (item, quantity) values ('book', 1)3 ms
- SERVICEPaymentClient.charge857 ms
- HTTP CLIENTPOST /fake-payment/charge844 ms
Inside your app
It lands at /causeline
Browser spans upload to /causeline/api/spans; server spans go through a bounded queue that never blocks a request. Both land in an in-memory store inside your app, lined up by the span tree, not by clocks.
Application log
INFO CauselineWebConfiguration : Causeline UI: http://localhost:8080/causeline/?token=…
Open the link and the whole action is there. The store keeps the latest 1,000 traces, within 64 MB.
Insights
Rules read the tree
Self time is a span’s duration minus the time its children ran. The rules use it to name the bottleneck, then look for repeated queries, long transactions and exceptions.
BottleneckPOST /fake-payment/charge · 844 ms · 88% of the checkout.
Long transactionOrderService.createOrder lasted 907 ms, 844 ms of it waiting for the payment call. It holds a database connection the whole time.
After the fix
Replay, compare, keep
Replay the captured request to local, dev or QA, then compare the two runs span by span. When it’s right, copy it as a test so it stays right.
CreateOrderTest.java
causeline.trace("POST /api/orders")
.hasNoFailedSpans()
.hasQueryCountAtMost(2)
.hasNoRepeatedQueries();
Security and load
Before you ship
The same traces get two more checks. Security hints read every trace for OWASP Top 10 problems, and active probes (IDOR, mass assignment, open redirect, auth boundary) send one edited request each, by hand. Load replay sends a captured request or flow many times and shows which span grew.
Secret in a logOrderService logged a field named password while handling POST /api/orders.
What grew under loadPaymentClient.charge, self time at p95, with 20 requests in flight.
Hints, not a scanner: nothing is sent unless you press the button, and load only goes to local or a target you mark allow-load.
Coding agents
Your agent reads it too
The same traces are served over MCP at /causeline/mcp. Claude Code, Cursor or Copilot can find the failed request, read where it was thrown, fix the code, then replay the request and compare the runs. What the agent sees is redacted like an export; what it may replay is up to you.
application-dev.yml
causeline:
mcp:
hide: ["/api/admin/**"]
replay:
# default: GET and HEAD only
allow: ["POST /api/orders"]
AgentReplayed POST /api/orders after the fix: 500 became 201, PaymentTimeoutException gone.
Spring AI and Python
Models and RAG
With Spring AI 2.0 in your app, chat calls and vector searches become spans in the same trace, streaming included. Click a search or a chat call and the RAG panel follows the question: the query, the ranked chunks with their scores, the final prompt with each chunk marked In prompt or Not in prompt, the answer and its tokens.
If Spring calls a FastAPI service, causeline for Python puts that service in the same trace. LangChain chat calls and retriever runs show up in the same panel, with no changes to your chains.
app.py
import causeline
from fastapi import FastAPI
causeline.init(endpoint="http://localhost:8080", service="ai-service")
app = FastAPI()
causeline.instrument(app)
Low relevanceThe best chunk scored 0.31, below the 0.5 you set for this store. The rules use no model, and they name spans and numbers, never your prompts.
Prompts, answers and chunks stay in the local UI. Exports and coding agents get the metadata only, and a replay or load run that would call a model again is refused until you allow it.