Tracepanel

Integrations

What Tracepanel records in Spring Boot, in Ktor, and in the libraries they use.

Tracepanel records the parts of your app below with no code of yours. Each is on as soon as its library is on the classpath.

Spring Boot

Spring Boot 3.5 and 4 with Spring MVC, in Java or Kotlin.

Swagger UI of a Spring Boot app with the panel docked at the bottom, showing the call tree of GET /api/catalog/products: the controller method, its transaction and two N+1 queries

WhatWhat a trace gets
RequestsEach request, named by its route (GET /owners/{id}), with the controller method that served it as a span.
ErrorsThe exception a handler throws, with your frames and the source around them. An exception the app answers with a 4xx is the answer, not an error.
Answers laterA handler that answers later (a Kotlin suspend function, a Callable, a DeferredResult) is one trace until its answer. A suspend function's queries are in it on whichever thread they run.
Tasks and jobsAn @Async method's run is a task, linked to the request that queued it. An @Scheduled method's run and a CommandLineRunner's or an ApplicationRunner's are jobs.
Tasks in flightThe Tasks page's Now lists the @Async runs queued and running, the @Scheduled runs, and the messages a @KafkaListener or a @RabbitListener handles. A message is queued from its send when a KafkaTemplate or a RabbitTemplate in a trace sent it. Each app instance is a worker, named service@host.
The sessionThe HttpSession's attributes under session., when the request has a session, secrets masked.
The userThe principal's name from Spring Security, when the app has it, or the user your code names with Tracepanel.setUser(id, username). The username stays on your machine.

Ktor

Ktor 3, with the Tracepanel plugin installed.

Swagger UI of a Ktor app with the panel docked at the bottom, showing the call tree of GET /api/catalog/products: the route handler, its transaction and three N+1 queries

WhatWhat a trace gets
CallsEach call, named by its route (GET /books/{id}), with its handler as a span of the same name. Its coroutines carry the trace to every thread they run on, so the queries of a suspended transaction on Dispatchers.IO are in it, and so are those after a delay and inside async blocks.
ErrorsThe exception a call fails with. One that StatusPages answers with a 4xx is the answer, not an error.
PagesAn HTML page gets the badge, however it was written, respondText or respondHtml. A page written as it is made, with respondHtml, respondTextWriter, respondBytesWriter or a channel, goes out as the app writes it.
The userThe user your code names with call.tracepanelUser(id, username).
The sessionThe Sessions plugin's sessions, each one's properties under session., secrets masked. A deferred session isn't read.

Libraries

LibraryWhat Tracepanel records
JDBCEach SQL statement, whatever runs it (Spring Data JPA, Hibernate, JdbcTemplate, jOOQ, Exposed), with its parameters, the rows the app read from its results and the line of your code that ran it, and each transaction. The rows are counted when the results are read to their end or closed, the statement runs again or closes, or the trace ends, also for execute() with getResultSet(), so a SELECT with no LIMIT that returned too many rows is a large result. In Ktor, through the DataSource Jdbc.dataSource wraps. EXPLAIN runs from the console.
HTTP clientsEach call through RestClient, RestTemplate, WebClient, the JDK's HttpClient (a bean, or one wrapped with HttpCalls.wrap(client)) and Ktor's client with TracepanelClient. Each carries a traceparent, so the app it reaches links its trace to the call.
RedisEach command through Lettuce (Spring Data Redis, the cache), with its N+1 and duplicates.
MongoDBEach command (Spring Data MongoDB), with its N+1 and duplicates.
Kafka, RabbitMQEach message a KafkaTemplate or a RabbitTemplate sends, with its N+1. Each message a @KafkaListener or @RabbitListener receives is a trace of its own, linked to the one that sent it.
Logback, Log4j 2The records written during a request or a task, with the line that logged them, the message's template, the exception with its stack, and the MDC as extra. fields, secrets masked. Log4j 2's FATAL is critical. A record of an async Log4j 2 logger is written on another thread and isn't in a trace.

A request that carries a W3C traceparent continues its caller's trace.

A query that no code of yours made, such as Jackson writing a lazy relation or Spring Security loading a user, records the library's line that asked for it as code.caller. The panel shows it marked as a library's. Code is yours by its packages, as for the place of your own queries.

Dumps

Tracepanel.dump(...) prints values to look at, as python-devtools' debug() does: the line that called it, then each value as written in the call, its pretty text, its type and its length, on stderr.

Tracepanel.dump(order, order.lines(), "here");
src/main/java/shop/Orders.java:42 place
    order: Order[id=7, total=12.50, lines=[Line[sku="pen", quantity=2]]] (Order)
    order.lines(): [Line[sku="pen", quantity=2]] (List) len=1
    "here" (String) len=4

From Kotlin, import dev.tracepanel.core.Tracepanel.dump makes it dump(order).

The expressions come from the call's source, in any module of the Gradle or Maven build the app runs in, at any depth: the modules its settings.gradle includes or its pom.xml lists, and any directory with a src. Else they come from the module of the class's build/classes or target/classes. Every source set counts, such as main, test or Kotlin multiplatform's commonMain. Without the source, the values print alone.

In a request, a task or a job, the dump is recorded too, on the span it ran in, and the call tree always shows it, as a DUMP row. It prints when Tracepanel is off, and records nothing then. A value is cut at 16 KB.

A secret is masked, printed and recorded alike: a value whose expression ends in a secret's name, such as password, user.getApiKey() or headers["Authorization"], and inside a value each field, record component, map key or name=value pair of a class's own text under a secret's name, as a Kotlin data class prints them. Names are read word by word, so author, tokens.size(), tokenCount and hasPassword stay as they are. See Dumps for where dumps show.

What a request carried

In Spring Boot and Ktor, each request records its headers, query, cookies and body, the session, and the response's headers, for the panel's Request tab. The body is recorded as far as the app read it itself, up to 16 KB: JSON with the values under a secret's name masked at any depth, a form with its fields and its files by name and size. TRACEPANEL_CAPTURE_REQUEST=0 leaves it all out.

A redirect that answers the browser's navigation, such as Spring's redirect: or Ktor's respondRedirect, sets a cookie for 30 seconds, so the panel on the next page lists the POST and the redirects before it. A streamed HTML page gets the panel too: in Spring a page the app flushes before it ends, in Ktor a page written as it is made.

Profiles

A request with the panel's Profile button on, or an X-Tracepanel-Profile: 1 header, is profiled. A thread samples the stack of the thread running the request every millisecond, and follows the request to other threads: an async request's dispatch, or a coroutine on Dispatchers.IO. Each function is named Class.method, yours told from the libraries' by its package. Where the app's packages aren't known, such as without @SpringBootApplication, the frames of the JVM, the frameworks, the drivers and common libraries, such as OpenTelemetry, Ktor, OkHttp, gRPC, Lettuce and the AWS SDK, are never counted as your code. Each sample counts in the 10 ms of the trace it was taken in, so the console splits the trace's time by them as it does every language's: a query is Database, the code's own time Your code, the framework's or Waiting, such as a parked thread. See Profile. A request nobody asked to profile costs nothing.

Your code can profile the rest of the trace it runs in, from the line that calls it to the trace's end:

Tracepanel.profile();
Report report = reports.build(month);

From Kotlin, import dev.tracepanel.core.Tracepanel.profile makes it profile(). Tracepanel.profile(true) counts the trace's memory too. It returns whether the trace is profiled: outside a trace, with Tracepanel off or with TRACEPANEL_PROFILE_ENABLED=0 it does nothing and returns false. Tracepanel.get().profile(trace) still works.

A profiled trace says why in its root span's profile.reason: setting for TRACEPANEL_PROFILE, header, cookie for the panel's button, parent when the calling app's trace asked, or code. A trace already profiled keeps its reason. The Profile tab shows it.

A profile asked for, or started by Tracepanel.profile(), follows the request to the apps it calls. Its HTTP calls carry the same X-Tracepanel-Profile value. The Kafka and RabbitMQ messages it sends with a KafkaTemplate or a RabbitTemplate carry it as a tracepanel-profile header, so the listener that receives one profiles its trace too. A tracepanel-profile header the app sets on a message itself wins over the forwarded one.

Memory

The Profile button's memory mode, an X-Tracepanel-Profile: memory header, the tracepanel_profile=memory cookie or Tracepanel.profile(true) counts a trace's memory too. TRACEPANEL_PROFILE_MEMORY=1 counts it for every profiled trace. The Profile tab's Memory shows:

  • Allocated: what the threads that ran the trace allocated while they ran it, garbage or not, counted by the JVM for each thread. It is the trace's own, on every thread Tracepanel follows it to: an async request's, a coroutine's. Work handed to another thread pool isn't in it. A virtual thread on Java 21 leaves it out, as the JVM can't count one.
  • Peak: the heap's highest level while the trace ran, above where it started, read every 10 ms, before each collection and at the end.
  • Net: the heap's level at the end less at the start. Garbage counts until it is collected, so a collection meanwhile can make it negative.
  • Shared: other traces ran meanwhile. The heap is the process's, so peak and net hold theirs too. Allocated stays the trace's own.

Allocation sites aren't recorded. The JVM's only cheap source, JFR's allocation samples, takes a handful of samples in a request, tells where memory was allocated rather than where it was held, and arrives about a second late, so every trace would wait for it.

Every profile has the garbage collector's runs: how many ran while the trace did, their pauses in all, and each pause on the trace's clock, to the millisecond. A concurrent collector, such as ZGC or Shenandoah, counts its cycles as runs and only its pauses as pause time. See Profile.

On this page