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.
To enable the integration, apply the following configuration to LettuceClientConfiguration
:
@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.
Redis Command Observation
Timer created around a Redis command execution.
Metric name spring.data.redis
. Type timer
and base unit seconds
.
Fully qualified name of the enclosing class org.springframework.data.redis.connection.lettuce.observability.RedisObservation
.
Name |
Description |
|
Redis command value. |
|
Redis database index. |
|
Database system. |
|
Redis user. |
|
Name of the database host. |
|
Logical remote port number. |
|
Mongo peer address. |
|
Mongo peer port. |
|
Network transport. |
Name |
Description |
|
Redis statement. |
|
Redis error response. |
Redis Command Observation Span
Timer created around a Redis command execution.
Span name spring.data.redis
.
Fully qualified name of the enclosing class org.springframework.data.redis.connection.lettuce.observability.RedisObservation
.
Name |
Description |
|
Redis command value. |
|
Redis database index. |
|
Redis statement. |
|
Database system. |
|
Redis user. |
|
Name of the database host. |
|
Logical remote port number. |
|
Mongo peer address. |
|
Mongo peer port. |
|
Network transport. |
|
Redis error response. |