Redis Client Tracing in Java

In the field of information technology (IT), "observability" is the ability to comprehend the internal state of a system by monitoring the outputs it produces. There are three so-called “pillars” of observability: logs, metrics, and tracing. In tracing, IT teams track how a request or transaction moves throughout a complex or distributed system from start to finish.

Redis Tracing

Redis is an open-source, in-memory data structure store that is frequently used to implement NoSQL databases, caches, and message brokers. Many of these Redis use cases require high performance and high availability. As such, tracing can be a valuable technique in assessing the performance of a Redis deployment and identifying any issues or errors.

For example, OpenTelemetry, an open-source framework for IT observability, helps developers and operations teams extract telemetry and instrumentation data from applications and infrastructure. Users can perform tracing in Redis by using OpenTelemetry or another Redis client that supports instrumentation. The OpenTelemetry platform may be configured to add metadata to Redis requests and responses, which can then be used to generate a trace of each request.

Redis Java Tracing With Redisson

While Redis has many widely applicable use cases, it also has its share of drawbacks. For one, Redis isn’t compatible with the Java programming language out of the box. Instead, developers who want to use Redis with Java can use a third-party Redis Java framework such as Redisson.

Redisson is a Redis Java client featuring implementations of many familiar Java data structures, services, and components. The Redisson library can dramatically lower the learning curve for any Java programmers using Redis.

Among the features and functionality of Redisson PRO is the ability to integrate with two tracing libraries — OpenTelemetry and OpenZipkin Brave — using the Micrometer Observation API and Micrometer Tracing framework.

OpenZipkin Brave is an open-source library for distributed tracing instrumentation and is part of the Zipkin project. With Brave, users collect timing data to help gather trace contexts, which are then sent to the Zipkin server for processing. Below is a code example of how to configure Redis tracing using OpenZipkin Brave:

OkHttpSender sender = OkHttpSender.create("http://localhost:9411/api/v2/spans");

AsyncZipkinSpanHandler zipkinSpanHandler = AsyncZipkinSpanHandler.create(sender);

StrictCurrentTraceContext braveCurrentTraceContext = StrictCurrentTraceContext.create();

Tracing tracing = Tracing.newBuilder()






config.setTracingProvider(new BraveTracingProvider(tracing));

Using Redis with Redisson PRO and OpenZipkin Brave requires the following dependencies:

groupId: io.zipkin.reporter2, artifactId: zipkin-sender-okhttp3

groupId: io.zipkin.reporter2, artifactId: zipkin-reporter-brave

Redisson PRO’s Redis tracing feature lets users collect additional statistics about the Redisson methods that have been called, including their name, arguments, invocation path, and frequency. The configuration metrics per Redis tracing event are:

  • invocation: The Redisson method with arguments.

  • object_name: The Redisson object name.

  • address: The Redisson server address.

  • username: The username used to connect to the Redis server.

To learn more about how Redisson PRO can help with Redis client tracing in Java, including a code demonstration of Redis tracing with OpenTelemetry, check out the Redisson documentation.

Similar articles