3 minutes
End-of-Life Technology: How to Drive Innovation Without Compromising Stability
When legacy systems approach end-of-life (EOL), enterprise IT teams typically face the choice of moving forward at all costs […]
In today’s complex, distributed applications, pinpointing performance issues and understanding the flow of requests can be a hard task. Payara Server’s Request Tracing Service provides a reliable toolset for tracing requests across various protocols and components. This blog post looks at request tracing in Payara Server, offering a quick guide to its features, configuration and best practices.
Before diving in, let’s take a look at a breakdown of the essential terminology:
At its core, the Request Tracing Service does the following:
Payara Server’s Request Tracing Service covers a wide range of requests:
Payara Server recognizes the significance of these standards and prioritises OpenTelemetry while still providing support for legacy systems:
If you are starting a new project or considering a switch, OpenTelemetry is the recommended choice for its expanded capabilities, broader scope and active development community. Payara’s focus on OpenTelemetry reflects the industry shift towards this comprehensive observability standard.
Payara Server provides multiple ways to manage its Request Tracing Service:
For ease of use, Payara automatically traces several common request types:
When you need finer-grained control over your tracing, you have two primary options:
@RequestScoped
public class MyJaxRsResource {
@Traced // Traces the entire method
@GET
@Path("/items")
public List<Item> getItems() {
// ... your item retrieval logic ...
}
@Traced(operationName = "processItem") // Custom operation name
private Item processItem(Item rawItem) {
// ... your item processing logic ...
}
}
In this example:
Tracer Class:
Obtain an instance of the io.opentracing.Tracer class through @Inject, then use the Tracer to create and manage tracing spans for more customized tracking.
Example:
@RequestScoped
public class MyServiceBean {
@Inject
Tracer tracer;
public void doSomeWork() {
try (Span span = tracer.buildSpan("myCustomSpan").startActive(true)) {
// ... code to be traced within the span ...
span.setTag("dataProcessed", "importantData"); // Add a tag
span.log("Processing step completed"); // Add a log
}
}
}
In this example:
For basic tracing of most common components, automatic tracing often suffices.
If you need specific tracing behavior, customizing which operations are traced or adding additional data to traces, the @Traced annotation or the Tracer class will be your tools of choice.
Method-level control: Add the @Traced(false) annotation directly to specific methods or classes you wish to exclude from tracing.
Example:
@Traced(false)
@GET
public Response getHealthStatus() {
// ... health check logic
return Response.ok("Healthy!").build();
}
@Traced(false) // Disables tracing for all methods in the class
public class InternalService {
// ...
}
Pattern-based control: Define skip patterns using regular expressions within MicroProfile Config properties. This allows you to disable tracing for sets of resources that match the pattern.
Example (in your MicroProfile config file):
mp.opentracing.server.skip-pattern=/health.*
This pattern would disable tracing for any JAX-RS resource paths starting with “/health”.
Note that:
Unlock the power of Payara Server’s Request Tracing Service to debug issues, optimize performance and understand how your distributed applications work. Combine it with metrics and logging for a complete picture of your system’s health. This approach will streamline troubleshooting, enhance user experience and help you build more reliable applications. Download Payara Community today and explore the Request Tracing documentation to get started. Happy Coding!
Share:
3 minutes
When legacy systems approach end-of-life (EOL), enterprise IT teams typically face the choice of moving forward at all costs […]
5 minutes
November has been one of the busiest months of the year for the Java and Jakarta EE ecosystem. With […]
3 minutes
Working with enterprise Java databases can sometimes feel like swimming upstream. Jakarta EE 11’s Jakarta Data helps developers glide […]
What are the differences between configuring via CMD (enableRequestTracing) and using asadmin?