There are cases when a very lite "tracing" is needed, i.e. having just a Correlation-ID in the log messages,
by the support of Mapped Diagnostic Context (MDC)
This library covers exactly this need.
Warning
Under active development 🚧
- Per-thread
Correlation-IDcontext (LiteTracingContext) LiteTracedRunnablepropagating the context to another threadLiteTracedThreadFactorywrapping tasks inLiteTracedRunnable, with support for platform and virtual threadsnew LiteTracedExecutorService(...)for per-task propagation on pooled executors
| Scenario | Use |
|---|---|
| Virtual threads / thread-per-task | LiteTracedThreadFactory.ofVirtual() |
| Pooled executor, varying submitter contexts | new LiteTracedExecutorService(executor) |
| Single manual thread | LiteTracedRunnable |
Java 25
<dependencies>
<dependency>
<groupId>com.petromirdzhunev.libs</groupId>
<artifactId>lite-tracing</artifactId>
</dependency>
</dependencies>LiteTracingContext.set("correlation-id-123");
// Virtual threads
ExecutorService executor = Executors.newThreadPerTaskExecutor(LiteTracedThreadFactory.ofVirtual());
// Platform threads
ExecutorService pool = Executors.newCachedThreadPool(LiteTracedThreadFactory.ofPlatform());
// Pooled executor with per-task propagation (id captured at submission time)
ExecutorService traced = new LiteTracedExecutorService(Executors.newCachedThreadPool());- Install SDKMAN
- Initialize SDKMAN environment
sdk env installCheck .sdkmanrc for all the tools installed with this command.
Change the version by adding a -SNAPSHOT suffix in the pom.xml file and then execute:
mvnd -B clean install<dependencies>
<dependency>
<groupId>com.petromirdzhunev.lib</groupId>
<artifactId>lite-tracing</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>