Observability

从应用程序组件中获取有关其操作、时间和与应用程序代码的关系的见解对于理解延迟至关重要。Spring Data Redis 通过 Lettuce 驱动程序提供 Micrometer 集成,以在 Redis 交互期间收集观察结果。一旦集成完成,Micrometer 将为每个 Redis 命令创建度量标准和跨度(用于分布式跟踪)。

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.

要启用集成,请将以下配置应用于 LettuceClientConfiguration

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);
  }
}

另请参阅 OpenTelemetry Semantic Conventions 以供参考。

See also OpenTelemetry Semantic Conventions for further reference.

Observability - Metrics

下面您可以找到此项目声明的所有指标的列表。

Below you can find a list of all metrics declared by this project.

Redis Command Observation

围绕 Redis 命令执行创建的计时器。

Timer created around a Redis command execution.

度量名称 spring.data.redis类型 timer基本单位 seconds

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

封闭类 org.springframework.data.redis.connection.lettuce.observability.RedisObservation 的完全限定名称。

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

Table 1. Low cardinality Keys

Name

Description

db.operation

Redis command value.

db.redis.database_index

Redis database index.

db.system

Database system.

db.user

Redis user.

net.peer.name

Name of the database host.

net.peer.port

Logical remote port number.

net.sock.peer.addr

Mongo peer address.

net.sock.peer.port

Mongo peer port.

net.transport

Network transport.

Table 2. High cardinality Keys

Name

Description

db.statement

Redis statement.

spring.data.redis.command.error

Redis error response.

Observability - Spans

下面您可以找到此项目声明的所有 span 的列表。

Below you can find a list of all spans declared by this project.

Redis Command Observation Span

围绕 Redis 命令执行创建的计时器。

Timer created around a Redis command execution.

跨度名称 spring.data.redis

Span name spring.data.redis.

封闭类 org.springframework.data.redis.connection.lettuce.observability.RedisObservation 的完全限定名称。

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

Table 3. Tag Keys

Name

Description

db.operation

Redis command value.

db.redis.database_index

Redis database index.

db.statement

Redis statement.

db.system

Database system.

db.user

Redis user.

net.peer.name

Name of the database host.

net.peer.port

Logical remote port number.

net.sock.peer.addr

Mongo peer address.

net.sock.peer.port

Mongo peer port.

net.transport

Network transport.

spring.data.redis.command.error

Redis error response.