-
Notifications
You must be signed in to change notification settings - Fork 600
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 specification: https://github.com/eclipse/microprofile-opentracing/blob/master/spec/src/main/asciidoc/microprofile-opentracing.asciidoc
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 Service Provider Interface through OpentracingTracerFactory to provide 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.
Important links:
- Main development hub: https://github.com/eclipse/microprofile-opentracing/
- Real time development chat on Gitter: https://gitter.im/eclipse/microprofile-opentracing
- MicroProfile mailing list: https://groups.google.com/forum/#!forum/microprofile
- Google Calendar which may show periodic "Open Tracing hangout" meetings: https://calendar.google.com/calendar/embed?src=gbnbc373ga40n0tvbl88nkc3r4%40group.calendar.google.com
MP OpenTracing has a Technology Compatibility Toolkit (TCK) that's used to confirm that a Microprofile OpenTracing implementation (such as OpenLiberty) implements the MP OpenTracing specification.
The TCK tests are in OpentracingClientTests. The tests use @RunAsClient
so that they're run in the TCK runner harness and they make JAX-RS calls to various web services deployed into OpenLiberty (example). Each test then makes a call to the getTracer web service which assumes that the Tracer implementation is a MockTracer. The getTracer
web service reads all of the accumulated spans from the MockTracer
, converts them to a tree of POJOs, and sends them back to the TCK runner which then compares the tree to an expected tree of spans and asserts the tree is correct.