Over a million developers have joined DZone.

Enhancements to Distributed Tracing in Microservices

DZone 's Guide to

Enhancements to Distributed Tracing in Microservices

A discussion of the latest improvements to this open source tool, and some Java, XML, and Dockerfile code to get you started.

· Microservices Zone ·
Free Resource

A quick roundup of a few of things you can try in the current Open Liberty development builds:

Enhancements to Distributed Tracing (MicroProfile OpenTracing 1.2)

Distributed tracing enables users to see the flow of requests between microservices, including seeing which microservices have high latency and seeing the hierarchy of calls between applications and their dependent microservices.

In MicroProfile OpenTracing 1.2, you can now also:

  • Skip tracing of JAX-RS requests by specifying a regular expression that matches UriInfo.getPath()
  • Use an alternative format for span names. The new format is <http method>:/@Path value of endpoint’s class>/<@Path value of endpoint’s methodFor example, GET:/inventory/list

Enable the two new functions by defining two keys using MicroProfile Config (e.g. in server.xml or bootstrap.properties):

  • mp.opentracing.server.skip-pattern
  • mp.opentracing.server.operation-name-provider

See also:

Package Server TAR Files for Simpler Dockerfiles

Liberty’s server package tool now supports packaging to .tar and .tar.gz files. The package tool has long supported generating to .zip and .jar files (and on z/OS .pax) but, until now, the most common packaging format on Linux hasn’t been an option.

So why now? It all relates to making Liberty work better with Docker. Docker’s ADD command has built-in support for extracting .tar files. Adding a server package to your Dockerfile is now really simple.

Instead of doing this:

   FROM open-liberty
   COPY defaultServer.zip /tmp/defaultServer.zip
   EXEC apt-get update && apt-get install unzip && unzip /tmp/defaultServer.zip /opt/ol/ && apt-get remove -y unzip && rm -rf /var/lib/apt/lists/*

You can now simply write:

 FROM open-liberty
   ADD defaultServer.tar.gz /opt/ol/

Support for Sharding in Java 11 (JDBC 4.3)

We’re currently working on Java 11 support for Open Liberty and it mostly works but isn’t complete yet.

If your JDBC driver supports the 4.3 specification level, the JDBC 4.3 feature enables you to take advantage of new capabilities in JDBC 4.3, including requesting connections and support for sharding. This feature requires Java 11.

It is now possible to request connections for a specific sharding key and optionally, super sharding key, if your database supports sharding and provides a JDBC 4.3 compliant driver.

Enable the feature in your server configuration (server.xml):


Configure one or more data sources in the server.xml as you would with the prior version JDBC features. For example:

<dataSource jndiName="jdbc/43datasource">
  <properties databaseName="sampledb" serverName="host1.rchland.ibm.com" portNumber="1234"/>
  <containerAuthData user="user1" password="pwd1"/>

Use the data source from your application in your app:

@Resource(lookup = "jdbc/43datasource")
DataSource datasource;
// Always cache sharding keys to ensure that matching of pooled connections can be successful.
// The JDBC spec does not require an .equals implementation.
ShardingKey key1, key2;
public void init(ServletConfig config) throws ServletException {
    try {
        key1 = datasource.createShardingKeyBuilder().subkey("key1", JDBCType.VARCHAR).build();
        key2 = datasource.createShardingKeyBuilder().subkey("key2", JDBCType.VARCHAR).build();
    } catch (SQLException x) {
        throw new ServletException(x);
try (Connection con = datasource.createConnectionBuilder().shardingKey(key1).build()) {
    // use connection

See also:

Try it Now in Development Builds of Open Liberty

Take a look at the latest Open Liberty development builds.

microservices ,tutorial ,distributed tracing ,sharding

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}