Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,53 @@ jobs:
-Porg.gradle.java.installations.fromEnv=JAVA_HOME_${{ matrix.java }}_X64
- if: matrix.java == '21'
run: ./gradlew publishToMavenLocal --console=plain
- uses: actions/upload-artifact@v7
if: failure()
with:
name: test-reports-java-${{ matrix.java }}
path: |
**/build/reports/tests/**
**/build/test-results/**
retention-days: 7

micronaut5:
name: Micronaut 5 on Java 25
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: |
25
21
- uses: gradle/actions/setup-gradle@v6
- run: ./gradlew :tracepanel-micronaut:testMicronaut5 :tracepanel-micronaut:testMicronaut5Integration --console=plain -Porg.gradle.java.installations.fromEnv=JAVA_HOME_25_X64
- uses: actions/upload-artifact@v7
if: failure()
with:
name: test-reports-micronaut5
path: |
tracepanel-micronaut/build/reports/tests/**
tracepanel-micronaut/build/test-results/**
retention-days: 7

# The branch's required check: every Java's tests passed, or the build was skipped.
check:
name: Build and test
needs: [changes, test]
needs: [changes, test, micronaut5]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- env:
CHANGES: ${{ needs.changes.result }}
TEST: ${{ needs.test.result }}
run: test "$CHANGES" = success && { test "$TEST" = success || test "$TEST" = skipped; }
MICRONAUT: ${{ needs.micronaut5.result }}
run: >-
test "$CHANGES" = success &&
{ test "$TEST" = success || test "$TEST" = skipped; } &&
{ test "$MICRONAUT" = success || test "$MICRONAUT" = skipped; }
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ jobs:
run: |
unzip -q bundle/*.zip -d files
find files -type f \( -name '*.jar' -o -name '*.pom' -o -name '*.module' \) | sort | tee subjects.txt
# Five of each module: tracepanel-core, tracepanel-spring-boot, tracepanel-ktor and tracepanel-junit.
[ "$(wc -l < subjects.txt)" -ge 20 ] || { echo "::error::fewer than 20 files in the bundle" && exit 1; }
# Five of each module: tracepanel-core, tracepanel-spring-boot, tracepanel-ktor, tracepanel-junit and tracepanel-micronaut.
[ "$(wc -l < subjects.txt)" -ge 25 ] || { echo "::error::fewer than 25 files in the bundle" && exit 1; }
- uses: actions/attest@v4
with:
subject-path: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Added

- `tracepanel-micronaut`, for Micronaut 4.10 and 5: each request, SQL and
transactions, calls through its HTTP clients, logs, errors and the console.

## 0.16.0 (2026-11-10)

### Changed
Expand Down
62 changes: 47 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
[![Maven Central](https://img.shields.io/maven-central/v/dev.tracepanel/tracepanel-core)](https://central.sonatype.com/namespace/dev.tracepanel)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://github.com/tracepanel/tracepanel-java#tracepanel-for-java)

**See what your Spring Boot or Ktor app is really doing.** Tracepanel records
each request, `@Async` task, scheduled job and message of your app, in Java or
Kotlin, with its SQL queries, Redis and MongoDB commands, outgoing HTTP calls,
logs and errors. It points out N+1 queries, duplicates, slow SQL and long
transactions, and names the line of code to fix. You read it in a panel on
your pages and in a console.
**See what your Spring Boot, Micronaut or Ktor app is really doing.**
Tracepanel records each request, `@Async` task, scheduled job and message of
your app, in Java or Kotlin, with its SQL queries, Redis and MongoDB commands,
outgoing HTTP calls, logs and errors. It points out N+1 queries, duplicates,
slow SQL and long transactions, and names the line of code to fix. You read it
in a panel on your pages and in a console.

It runs while you develop, and everything stays on your machine.

Expand All @@ -22,11 +22,11 @@ It runs while you develop, and everything stays on your machine.
| | Supported |
| --- | --- |
| **Java** | 17 and later, apps in Java or Kotlin. |
| **Frameworks** | Spring Boot 3.5 and 4 with Spring MVC, Kotlin suspend functions, `Callable` and `DeferredResult` handlers included. Ktor 3. WebFlux apps aren't supported yet. |
| **Frameworks** | Spring Boot 3.5 and 4 with Spring MVC, Kotlin suspend functions, `Callable` and `DeferredResult` handlers included. Ktor 3. Micronaut 4.10 and 5 (on Java 25). WebFlux apps aren't supported yet. |
| **Databases** | SQL through JDBC, whatever runs it: Spring Data JPA, Hibernate, `JdbcTemplate`, jOOQ, Exposed. Transactions. EXPLAIN on PostgreSQL, MySQL, H2 and SQLite of a SELECT or a `WITH … SELECT` that changes no data (ANALYZE rolled back). |
| **Redis and MongoDB** | Lettuce (Spring Data Redis, the cache) and Spring Data MongoDB, with their own N+1 and duplicates. |
| **Messaging** | Kafka and RabbitMQ: what a `KafkaTemplate` or a `RabbitTemplate` sends, and each message a `@KafkaListener` or `@RabbitListener` receives as a trace of its own, linked to the one that sent it. |
| **HTTP clients** | `RestClient`, `RestTemplate`, `WebClient` and the JDK's `HttpClient`, each call with a `traceparent`. Ktor's client through `TracepanelClient`. |
| **HTTP clients** | `RestClient`, `RestTemplate`, `WebClient` and the JDK's `HttpClient`, each call with a `traceparent`. Ktor's client through `TracepanelClient`. Micronaut's clients, `@Client` interfaces included. |
| **Background work** | `@Async` methods as tasks, linked to the request that queued them; `@Scheduled` methods, `CommandLineRunner`s and `ApplicationRunner`s as jobs; the tasks in flight listed live. |
| **Logs** | Logback and Log4j 2, each record on the request or task that made it, with its line, MDC and exception. |
| **Errors** | Thrown in a handler, with your frames and the source around them. |
Expand Down Expand Up @@ -96,6 +96,22 @@ off, even if the dependency reached the build by mistake, and says so once in
the log. `TRACEPANEL_ENABLED=1` turns it on anyway, `TRACEPANEL_ENABLED=0`
off.

### Micronaut

Add the dependency for development only. Micronaut finds Tracepanel's beans
by itself: each request, your DataSources and your HTTP clients.

```kotlin
dependencies {
developmentOnly("dev.tracepanel:tracepanel-micronaut:0.16.0")
}
```

Tracepanel is on in a `dev`, `development` or `local` environment
(`MICRONAUT_ENVIRONMENTS=dev ./gradlew run`), or with
`TRACEPANEL_ENABLED=1`. The console is at `/__tracepanel__/` on your app.
Micronaut 4.10 runs on Java 17, Micronaut 5 on Java 25.

### Ktor

Install the plugin. Ktor has no dependency injection to find your DataSource
Expand Down Expand Up @@ -152,6 +168,15 @@ fix:
- The signed-in user from Spring Security, or
`Tracepanel.setUser(id, username)`.

### Micronaut

- Each request, named by its route (`GET /books/{id}`) and its controller
method, on Micronaut's executors and, with `micronaut-reactor`, Reactor's.
- SQL and transactions through your `DataSource` beans, Micronaut Data's
`@Transactional` included, and calls through its HTTP clients.
- Logs and errors as in Spring Boot, and the user from the request's
principal.

### Ktor

- Each call, named by its route (`GET /books/{id}`), its coroutines included.
Expand Down Expand Up @@ -360,8 +385,8 @@ The same environment variables as the other Tracepanel SDKs:

| Variable | Default | What it sets |
| --- | --- | --- |
| `TRACEPANEL_ENABLED` | in development (a `dev` or `local` profile or DevTools; Ktor's development mode) | `0` turns Tracepanel off, `1` on |
| `TRACEPANEL_SERVICE` | `spring.application.name`, or Ktor's `ktor.application.id` | the app's name in the console |
| `TRACEPANEL_ENABLED` | in development (Spring's dev profiles or DevTools, Micronaut's dev environments, or Ktor's development mode) | `0` turns Tracepanel off, `1` on |
| `TRACEPANEL_SERVICE` | `spring.application.name`, `micronaut.application.name`, or `ktor.application.id` | the app's name in the console |
| `TRACEPANEL_DIR` | `.tracepanel` | the project's store, where the agent keeps the traces |
| `TRACEPANEL_AGENT_BIN` | the one the SDK downloads | the agent to start, such as a build of your own |
| `TRACEPANEL_AGENT` | `auto` | an agent elsewhere (`tcp:host:port`), never started |
Expand Down Expand Up @@ -439,8 +464,14 @@ the same in every framework, under
./gradlew check
```

It runs the tests on Spring Boot 4 and on 3.5, and on Ktor. The tests of
MongoDB, Redis, Kafka and RabbitMQ need a server of each:
It runs the tests on Spring Boot 4 and on 3.5, on Ktor, and on Micronaut 4
with and without Micronaut Data. Micronaut 5's need Java 25:

```bash
./gradlew :tracepanel-micronaut:testMicronaut5 :tracepanel-micronaut:testMicronaut5Integration
```

The tests of MongoDB, Redis, Kafka and RabbitMQ need a server of each:
`TEST_MONGODB_URI=mongodb://127.0.0.1:27017/test`, `TEST_REDIS_PORT=6379`,
`TEST_KAFKA_BOOTSTRAP=localhost:9092` and `TEST_RABBITMQ_PORT=5672`. The
tests of the console's Live and EXPLAIN with the real agent need its
Expand All @@ -450,9 +481,10 @@ writes the checksums of that version's downloads.

`tracepanel-core` records traces and talks to the agent, with no framework
and no dependencies. `tracepanel-spring-boot` is the Spring Boot
integration, `tracepanel-ktor` the Ktor one, and `tracepanel-junit` the
JUnit extension. The extension's tests with the real agent download it, as
a project does, unless `TEST_AGENT_BIN` names one.
integration, `tracepanel-micronaut` the Micronaut one, `tracepanel-ktor` the
Ktor one, and `tracepanel-junit` the JUnit extension. The extension's tests
with the real agent download it, as a project does, unless `TEST_AGENT_BIN`
names one.

## License

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// tracepanel-junit runs each test as a trace, failed by what the agent finds in it.
rootProject.name = "tracepanel-java"

include("tracepanel-core", "tracepanel-spring-boot", "tracepanel-ktor", "tracepanel-junit")
include("tracepanel-core", "tracepanel-spring-boot", "tracepanel-ktor", "tracepanel-junit", "tracepanel-micronaut")
7 changes: 4 additions & 3 deletions tracepanel-core/src/main/java/dev/tracepanel/core/Stacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class Stacks {
private static final List<String> LIBRARIES = List.of(
"java.", "javax.", "jakarta.", "jdk.", "sun.", "com.sun.", "kotlin.", "kotlinx.", "scala.", "groovy.",
"org.springframework.", "org.hibernate.", "com.zaxxer.", "org.postgresql.", "com.mysql.", "org.mariadb.",
"org.h2.", "org.hsqldb.", "org.apache.", "org.eclipse.", "io.netty.", "reactor.", "io.micrometer.",
"org.h2.", "org.hsqldb.", "org.apache.", "org.eclipse.", "io.netty.", "io.micronaut.", "reactor.", "io.micrometer.",
"ch.qos.logback.", "org.slf4j.", "org.thymeleaf.", "com.fasterxml.", "org.jboss.", "net.bytebuddy.",
"org.junit.", "dev.tracepanel.", "io.opentelemetry.", "io.ktor.", "org.jetbrains.", "com.google.",
"okhttp3.", "okio.", "io.grpc.", "io.undertow.", "io.vertx.", "org.aspectj.", "org.glassfish.", "org.jooq.",
Expand Down Expand Up @@ -80,12 +80,13 @@ public boolean inApp(String className) {
/**
* Classes made at runtime in the app's packages: Hibernate's lazy proxies (Author$HibernateProxy, Hibernate 6's
* name, or Author$HibernateProxy$…), Spring's CGLIB subclasses (…$$SpringCGLIB$$0), lambdas (…$$Lambda/0x…),
* ByteBuddy's, and the JDK's interface proxies ($Proxy172). Their frames have no line of the app's to point at.
* ByteBuddy's, the JDK's interface proxies ($Proxy172), and what Micronaut generates as it compiles
* ($BookController$Definition$Exec). Their frames have no line of the app's to point at.
*/
private static boolean generated(String className) {
String simple = className.substring(className.lastIndexOf('.') + 1);
return className.contains("$$") || className.contains("$HibernateProxy") || className.contains("$ByteBuddy$")
|| simple.startsWith("$Proxy");
|| simple.startsWith("$");
}

/** The app's frame nearest to the call being made now, as "path:line in method", or null when none is the app's. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ void the_app_s_code_is_its_own_packages_not_the_libraries() {
assertTrue(!stacks.inApp("com.shopping.Other"));
assertTrue(!stacks.inApp("org.springframework.web.Servlet"));
// Made at runtime in the app's package: a lazy relation's proxy (Hibernate 6 names it Author$HibernateProxy),
// a Spring subclass, a lambda, an interface's proxy.
// a Spring subclass, a lambda, an interface's proxy, Micronaut's compiled bean definitions.
assertTrue(!stacks.inApp("com.shop.Author$HibernateProxy$Xyz"));
assertTrue(!stacks.inApp("com.shop.Author$HibernateProxy"));
assertTrue(!stacks.inApp("com.shop.BookService$$SpringCGLIB$$0"));
assertTrue(!stacks.inApp("com.shop.BookService$$Lambda/0x000001f001234567"));
assertTrue(!stacks.inApp("com.shop.$Proxy172"));
assertTrue(!stacks.inApp("com.shop.$BookController$Definition$Exec"));
assertTrue(stacks.inApp("com.shop.BookService$Page"));
assertEquals("com/shop/BookService.java:42 in list", stacks.where("com.shop.BookService", "BookService.java", 42, "list"));
}
Expand Down
130 changes: 130 additions & 0 deletions tracepanel-micronaut/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
description = "Tracepanel for Micronaut: request traces, JDBC, declarative HTTP clients, logs, a badge and the local console."

val micronaut4 = "4.10.24"
val micronaut5 = "5.2.6"
val h2 = "2.5.252"
val logback = "1.6.6"

dependencies {
api(project(":tracepanel-core"))
compileOnly(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
compileOnly("io.micronaut:micronaut-http-server")
compileOnly("io.micronaut:micronaut-http-client-core")
compileOnly("io.micronaut:micronaut-core-reactive")
compileOnly("org.jetbrains:annotations:26.1.0")
// Reactor comes with Micronaut's Netty server and HTTP client, of the app's own version.
compileOnly("io.projectreactor:reactor-core")
compileOnly("ch.qos.logback:logback-classic:$logback")
compileOnly("org.apache.logging.log4j:log4j-core:2.24.3")
annotationProcessor(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
annotationProcessor("io.micronaut:micronaut-inject-java")

testImplementation(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
testImplementation("io.micronaut.test:micronaut-test-junit5")
testImplementation("io.micronaut:micronaut-http-server-netty")
testImplementation("io.micronaut:micronaut-http-client")
testImplementation("io.micronaut:micronaut-jackson-databind")
testImplementation("io.micronaut.reactor:micronaut-reactor")
testImplementation("io.micronaut.sql:micronaut-jdbc-hikari")
testImplementation("io.projectreactor:reactor-core")
testImplementation("com.h2database:h2:$h2")
testImplementation("ch.qos.logback:logback-classic:$logback")
testImplementation(testFixtures(project(":tracepanel-core")))
testAnnotationProcessor(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
testAnnotationProcessor("io.micronaut:micronaut-inject-java")
}

// Compile against Micronaut 4's Java 17 API; exercise the same integration on Micronaut 5 and Java 25.
val micronaut5Tests = testing.suites.register<JvmTestSuite>("testMicronaut5") {
useJUnitJupiter("6.1.3")
sources.java.setSrcDirs(listOf("src/test/java"))
sources.resources.setSrcDirs(listOf("src/test/resources"))
dependencies {
implementation(project())
implementation(platform("io.micronaut.platform:micronaut-platform:$micronaut5"))
implementation("io.micronaut.test:micronaut-test-junit5")
implementation("io.micronaut:micronaut-http-server-netty")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-jackson-databind")
implementation("io.micronaut.reactor:micronaut-reactor")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.projectreactor:reactor-core:3.8.8")
implementation("com.h2database:h2:$h2")
implementation("ch.qos.logback:logback-classic:$logback")
implementation(testFixtures(project(":tracepanel-core")))
}
targets.all {
testTask.configure {
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }
useJUnitPlatform { excludeTags("integration") }
}
}
}
dependencies {
"testMicronaut5AnnotationProcessor"(platform("io.micronaut.platform:micronaut-platform:$micronaut5"))
"testMicronaut5AnnotationProcessor"("io.micronaut:micronaut-inject-java")
}
tasks.named<JavaCompile>("compileTestMicronaut5Java") {
javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(25) }
options.release = 25
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:-processing")
options.compilerArgs.addAll(listOf("-Amicronaut.processing.group=dev.tracepanel", "-Amicronaut.processing.module=tracepanel-micronaut"))
}
tasks.withType<Test>().configureEach {
environment("TRACEPANEL_DIR", layout.buildDirectory.dir("tracepanel-test/$name").get().asFile.absolutePath)
environment("TRACEPANEL_AGENT", "off")
}

// Separate JVMs keep the core's process-wide recorder and fake agent out of unit tests.
tasks.test { useJUnitPlatform { excludeTags("integration") } }
val integrationTest = tasks.register<Test>("integrationTest") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
useJUnitPlatform { includeTags("integration") }
environment("TRACEPANEL_AGENT", "auto")
shouldRunAfter(tasks.test)
}
tasks.register<Test>("testMicronaut5Integration") {
val sources = micronaut5Tests.get().sources
testClassesDirs = sources.output.classesDirs
classpath = sources.runtimeClasspath
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }
useJUnitPlatform { includeTags("integration") }
environment("TRACEPANEL_AGENT", "auto")
shouldRunAfter(tasks.named("testMicronaut5"))
}
// Micronaut Data makes the app's DataSource transaction-aware: its own classpath, with the SDK's wrapper under it.
val micronautDataTests = testing.suites.register<JvmTestSuite>("testMicronautData") {
useJUnitJupiter("6.1.3")
dependencies {
implementation(project())
implementation(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
implementation("io.micronaut.test:micronaut-test-junit5")
implementation("io.micronaut:micronaut-http-server-netty")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-jackson-databind")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.data:micronaut-data-tx-jdbc")
implementation("ch.qos.logback:logback-classic:$logback")
implementation("com.h2database:h2:$h2")
implementation(testFixtures(project(":tracepanel-core")))
}
targets.all {
testTask.configure {
environment("TRACEPANEL_AGENT", "auto")
shouldRunAfter(integrationTest)
}
}
}
dependencies {
"testMicronautDataAnnotationProcessor"(platform("io.micronaut.platform:micronaut-platform:$micronaut4"))
"testMicronautDataAnnotationProcessor"("io.micronaut:micronaut-inject-java")
}
tasks.check { dependsOn(integrationTest, micronautDataTests) }

// The auto-configured integration has package-private beans rather than a public API.
tasks.javadoc {
(options as StandardJavadocDocletOptions).memberLevel = JavadocMemberLevel.PACKAGE
}
Loading
Loading