Quarkus and Instana: Lightspeed Monitoring for Supersonic Java

This blog post was co-authored by Christoph Engelbert and Tim Riemer.

Guest Author Tim Riemer Tim Riemer works as Senior Solution Architect at Vorwerk Group and has over 20 years of Java experience.
He is fascinated by the JVM, the languages available on it, and open source in general.
In addition to his job, he also deals with current topics around software architecture, Spring Boot, Build-Automation and Kotlin.
Tim is co-founder of the Kotlin User Group Dusseldorf, the first non-Java User Group in the iJUG e.V. umbrella organizations in Germany.

 

Once in awhile a new technology emerges to disrupt the industry. Sometimes it is a container technology, sometimes a ride platform or, like this time, a new microservices framework for the Java ecosystem. Quarkus, released in March of this year, not only provides a fast, intuitive API to build microservices, but also provides support for Oracle Labs’ GraalVM and, therefore, native builds.

Native executables written in Java are not really new though, Excelsior Jet provides the possibility to have native compilation to the Java ecosystem for years, however, Graal offers native builds for free.

Quark Us

Anyway, back to Quarkus. If by accident or on purpose, Quarks are the smallest particles in the universe, as your microservices are the smallest logical elements of your distributed system.

Quarkus strives to make Java the leading platform in the Kubernetes and serverless environments. To achieve that, it provides developers with a full-stack framework, offering a unified experience, with both reactive and imperative APIs.

On top, Quarkus, thanks to GraalVM support, delivers fast but small containers for quick deployment and boot times compared to standard Java applications with a more traditional cloud stack approach.


Comparison of size and speed Quarkus vs. traditional cloud stack
Figure 1: Comparison of size and speed Quarkus vs. traditional cloud stack, source: quarkus.io

Supersonic Java

With the focus on developer productivity, Quarkus offers a set of very cool features, such as unified configuration, no matter where you deploy. In the best case it runs without any configuration at all, bringing zero configuration to environments like Kubernetes.

Furthermore it tries to minimize the necessary code base for the most common cases, making it as easy as the following code snippets to write a REST service.

@Inject
SayService say;

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
  return say.hello();
}

The biggest benefit, however, is the support of generating native images using GraalVM’s ahead-of-time compiler, which is completely integrated into Quarkus’ build process.

Native image means that the Java program is compiled down to a fully self-sustaining native executable. For execution, no Java Runtime environment is required to be installed on the machine. All required components are compiled straight into the executable, leaving out unnecessary parts of the runtime to minimize size. In this sense it’s very similar to how Go executables are designed.

All the efficiency, productivity and speed benefits delivered through Quarkus are combined into the slogan “Supersonic Java”; bring Java based services to the next level of velocity without any hassle in the process.

Lightspeed Monitoring

When writing production services or applications though, developers need monitoring to gather insight into their work – delivering not only basic metrics but full distributed tracing throughout the infrastructure and request flow.

With Quarkus running on the standard Java platform, Instana can use its AutoTrace technology to dynamically instrument the application and add tracings and metrics on-the-fly. When being compiled into a native image though, dynamic instrumentation using a Java agent is not possible anymore.

That said, we need a different way to gather the necessary information. Quarkus to the rescue though, as it includes a built-in OpenTracing/Jaeger module and therefore does the important bits already.

Instana, with the Quarkus OpenTracing module, is able to capture traces right away. We only need to point the quarkus.opentracing.endpoint (or the JAEGER_ENDPOINT environment variable) to our Instana agent. A single setting (http://instana-agent:42699/com.instana.plugin.jaeger.trace) and we’re good to go with tracing of the native Quarkus service.

In addition, however, it is recommended to add the Instana Java OpenTracing artifact to your dependency build and initialize the tracer as mentioned in the README. This enables Instana to not only gather the traces, but also merge them with process metrics gathered on the operating system level and map the process into the infrastructure view.


Quarkus based service (waterservice), built as a native image with GraalVM integrated in an Instana trace
Figure 2: Quarkus based service (waterservice), built as a native image with GraalVM integrated in an Instana trace

The really cool thing is though, afterwards we get all the other nice metrics and benefits from Instana out of the box, right with it. We capture the error rates, average or min/max latencies; all the goodies we love about Instana.


Additional metrics about our Quarkus service
Figure 3: Additional metrics about our Quarkus service

Right to Ludicrous Speed

The power and existing knowledge of the Java platform that exists with a large group of developers, the speed and startup times of native compilation, and the insight gathered by Instana are an exceptional combination.

To try it out today, jump right into the Quarkus Getting Started guide and sign up for a 14-day free trial of Instana, if you don’t have a subscription yet.

And always remember, if Lightspeed is not fast enough, go right to Ludicrous Speed as a wise man once said. Oh and don’t forget to trust Mr. Coffee! 🙂

via Giphy

Start your FREE TRIAL today!

Full Stack Visibility in 5 minutes! Instana makes it easy to
manage the performance of your applications.

Free Trial

See how Instana's technology works!

Maximum Understanding, Minimum Effort! Check out
how Instana can help you managing your applications.

How Instana Works