This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Data Redis 3.4.4!spring-doc.cn

Observability

Getting insights from an application component about its operations, timing and relation to application code is crucial to understand latency. Lettuce ships with a Micrometer integration to collect observations during Redis interaction. Once the integration is set up, Micrometer will create meters and spans (for distributed tracing) for each Redis command.spring-doc.cn

To enable the integration, apply the following configuration to LettuceClientConfiguration:spring-doc.cn

@Configuration
class ObservabilityConfiguration {

  @Bean
  public ClientResources clientResources(ObservationRegistry observationRegistry) {

    return ClientResources.builder()
              .tracing(new MicrometerTracing(observationRegistry, "my-redis-cache"))
              .build();
  }

  @Bean
  public LettuceConnectionFactory lettuceConnectionFactory(ClientResources clientResources) {

    LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
                                                .clientResources(clientResources).build();
    RedisConfiguration redisConfiguration = …;
    return new LettuceConnectionFactory(redisConfiguration, clientConfig);
  }
}