Skip to content

Tracing

Mark Paluch edited this page Jul 3, 2020 · 5 revisions

Tracing gives insights about individual Redis commands sent to Redis to trace their frequency, duration and to trace of which commands a particular activity consists. Lettuce provides a tracing SPI to avoid mandatory tracing library dependencies. Lettuce ships a default implementation for Brave which can be configured through client resources.

Brave

With Brave tracing enabled, Lettuce creates a span for each Redis command. The following options can be configured:

  • serviceName (defaults to redis).

  • Endpoint customizer. This option can be used together with a custom SocketAddressResolver to attach custom endpoint details.

  • Span customizer. Allows for customization of spans based on the actual Redis Command object.

  • Inclusion/Exclusion of all command arguments in a span. By default, all arguments are included.

Prerequisites

Lettuce requires the Brave dependency (at least 5.1) to provide Tracing functionality. Make sure to include that dependency on your classpath.

If using Maven, add the following dependency to your pom.xml:

<dependency>
    <groupId>io.zipkin.brave</groupId>
    <artifactId>brave</artifactId>
</dependency>

The following example shows how to configure tracing through ClientResources:

brave.Tracing clientTracing = …;

BraveTracing tracing = BraveTracing.builder().tracing(clientTracing)
    .excludeCommandArgsFromSpanTags()
    .serviceName("custom-service-name-goes-here")
    .spanCustomizer((command, span) -> span.tag("cmd", command.getType().name()))
    .build();

ClientResources resources = ClientResources.builder().tracing(tracing).build();

Lettuce ships with a Tracing SPI in io.lettuce.core.tracing that allows custom tracer implementations.

Clone this wiki locally