Skip to content

Distributed Tracing

Auralog automatically generates a trace ID for each SDK session, allowing you to correlate logs across multiple services and see the full request flow.

When you call Auralog.init(), the SDK generates a unique trace ID. Every log sent during that session includes this trace ID. If your app calls multiple backend services, you can propagate the trace ID so all services log under the same trace.

By default, every log includes a trace ID with no extra configuration:

import ai.auralog.Auralog;
import ai.auralog.AuralogConfig;
Auralog.init(AuralogConfig.builder()
.apiKey("aura_...")
.build());
Auralog.info("request received"); // trace ID auto-attached
Auralog.info("processing complete"); // same trace ID

To correlate logs across services, pass the trace ID in HTTP headers:

import ai.auralog.Auralog;
import java.net.http.HttpRequest;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.example.com/process"))
.header("X-Trace-Id", Auralog.getTraceId())
.build();
import ai.auralog.Auralog;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
public class TraceFilter implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
String incoming = ((HttpServletRequest) req).getHeader("X-Trace-Id");
if (incoming != null) {
Auralog.setTraceId(incoming);
}
chain.doFilter(req, res);
}
}

You can override the trace ID for individual logs by including traceId in metadata:

Auralog.info("external request", Map.of(
"traceId", "custom-trace-abc123",
"endpoint", "/api/users"
));
Auralog.init(AuralogConfig.builder()
.apiKey("aura_...")
.traceId("my-custom-trace-id")
.build());

In the Log Viewer, logs with a trace ID show a trace icon. Click it to filter the view to all logs sharing that trace ID, displayed in chronological order. You can also search by trace ID:

trace:abc123