Skip to content

MicroProfile: OpenTracing

kgibm edited this page Mar 21, 2018 · 32 revisions

MicroProfile OpenTracing

The Eclipse MicroProfile project is an open collaboration between developers, the community, and vendors to create a programming model for microservices applications which is complementary to JEE.

The Eclipse MicroProfile OpenTracing project (MP OpenTracing) defines the specification and an API for tracing JAX-RS web service operations as they flow into, within, between, and out of servers. This trace information can be fed to OpenTracing-compliant distributed tracing systems such as Zipkin. Then, the distributed tracing systems may be used to display each JAX-RS call and how long it took, track performance, diagnose problems, feed load distribution algorithms, etc. This is particularly useful in a microservices architecture because such architectures often have many separate JVMs tied together with JAX-RS calls.

The MP OpenTracing project is largely a wrapper around the OpenTracing project which provides a vendor-neutral open standard for distributed tracing and uses parts of version 0.30.0 of its Java implementation.

Version 1.0 of MP OpenTracing was delivered as part of version 1.3 of the overall MicroProfile.

Important links:

MP OpenTracing in OpenLiberty

OpenLiberty contains two features to support OpenTracing: opentracing-1.0 and mpOpenTracing-1.0. opentracing-1.0 was delivered before the MP OpenTracing 1.0 specification was finalized, and mpOpenTracing-1.0 delivered the full specification compliance with OpenTracing 1.0. Therefore, unless a user is on a version of Liberty before mpOpenTracing-1.0 was released, users should just use mpOpenTracing-1.0 which a superset of opentracing-1.0 and implicitly enables it.

To use MP OpenTracing in OpenLiberty, the user must create a user feature with an io.opentracing.Tracer implementation. IBM has created sample code for a user feature that connects to Zipkin. After the Tracer implementation has been properly installed as a user feature, mpOpenTracing-1.0 and the user feature must be enabled as features in server.xml. For example:

<featureManager>
  <feature>mpOpenTracing-1.0</feature>
  <feature>usr:opentracingZipkin-0.30</feature>
</featureManager>

Additional configuration in server.xml may be needed for the particular user feature.

The way the user feature works is that it uses an OpenLiberty SPI through OpentracingTracerFactory to provider the Tracer implementation.

In addition to automatically tracing JAX-RS endpoints and clients, an application may additionally trace arbitrary Java classes used within a JAX-RS call, and/or disable or change the operation name of particular JAX-RS endpoints using an injected Tracer and/or the @Traced annotation, respectively.

MP OpenTracing Development

Important links:

Clone this wiki locally