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

Observability

Getting insights from an application component about its operations, timing and relation to application code is crucial to understand latency. Spring Data Redis ships with a Micrometer integration through the Lettuce driver 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 MicrometerTracingAdapter(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);
  }
}

See also OpenTelemetry Semantic Conventions for further reference.spring-doc.cn

Observability - Metrics

Below you can find a list of all metrics declared by this project.spring-doc.cn

Redis Command Observation

Timer created around a Redis command execution.spring-doc.cn

Metric name spring.data.redis. Type timer and base unit seconds.spring-doc.cn

Fully qualified name of the enclosing class org.springframework.data.redis.connection.lettuce.observability.RedisObservation.spring-doc.cn

Table 1. Low cardinality Keys

Descriptionspring-doc.cn

db.operationspring-doc.cn

Redis command value.spring-doc.cn

db.redis.database_indexspring-doc.cn

Redis database index.spring-doc.cn

db.systemspring-doc.cn

Database system.spring-doc.cn

db.userspring-doc.cn

Redis user.spring-doc.cn

net.peer.namespring-doc.cn

Name of the database host.spring-doc.cn

net.peer.portspring-doc.cn

Logical remote port number.spring-doc.cn

net.sock.peer.addrspring-doc.cn

Mongo peer address.spring-doc.cn

net.sock.peer.portspring-doc.cn

Mongo peer port.spring-doc.cn

net.transportspring-doc.cn

Network transport.spring-doc.cn

Table 2. High cardinality Keys

Descriptionspring-doc.cn

db.statementspring-doc.cn

Redis statement.spring-doc.cn

spring.data.redis.command.errorspring-doc.cn

Redis error response.spring-doc.cn

Observability - Spans

Below you can find a list of all spans declared by this project.spring-doc.cn

Redis Command Observation Span

Timer created around a Redis command execution.spring-doc.cn

Span name spring.data.redis.spring-doc.cn

Fully qualified name of the enclosing class org.springframework.data.redis.connection.lettuce.observability.RedisObservation.spring-doc.cn

Table 3. Tag Keys

Namespring-doc.cn

Descriptionspring-doc.cn

db.operationspring-doc.cn

Redis command value.spring-doc.cn

db.redis.database_indexspring-doc.cn

Redis database index.spring-doc.cn

db.statementspring-doc.cn

Redis statement.spring-doc.cn

db.systemspring-doc.cn

Database system.spring-doc.cn

db.userspring-doc.cn

Redis user.spring-doc.cn

net.peer.namespring-doc.cn

Name of the database host.spring-doc.cn

net.peer.portspring-doc.cn

Logical remote port number.spring-doc.cn

net.sock.peer.addrspring-doc.cn

Mongo peer address.spring-doc.cn

net.sock.peer.portspring-doc.cn

Mongo peer port.spring-doc.cn

net.transportspring-doc.cn

Network transport.spring-doc.cn

spring.data.redis.command.errorspring-doc.cn

Redis error response.spring-doc.cn