|
| 1 | +[[redis.observability]] |
| 2 | += Observability |
| 3 | + |
| 4 | +Getting insights from an application component about its operations, timing and relation to application code is crucial to understand latency. |
| 5 | +Spring Data Redis ships with a Micrometer integration through the Lettuce driver to collect observations during Redis interaction. |
| 6 | +Once the integration is set up, Micrometer will create meters and spans (for distributed tracing) for each Redis command. |
| 7 | + |
| 8 | +To enable the integration, apply the following configuration to `LettuceClientConfiguration`: |
| 9 | + |
| 10 | +[source,java] |
| 11 | +---- |
| 12 | +@Configuration |
| 13 | +class ObservabilityConfiguration { |
| 14 | +
|
| 15 | + @Bean |
| 16 | + public ClientResources clientResources(ObservationRegistry observationRegistry) { |
| 17 | +
|
| 18 | + return ClientResources.builder() |
| 19 | + .tracing(new MicrometerTracingAdapter(observationRegistry, "my-redis-cache")) |
| 20 | + .build(); |
| 21 | + } |
| 22 | +
|
| 23 | + @Bean |
| 24 | + public LettuceConnectionFactory lettuceConnectionFactory(ClientResources clientResources) { |
| 25 | +
|
| 26 | + LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder() |
| 27 | + .clientResources(clientResources).build(); |
| 28 | + RedisConfiguration redisConfiguration = …; |
| 29 | + return new LettuceConnectionFactory(redisConfiguration, clientConfig); |
| 30 | + } |
| 31 | +} |
| 32 | +---- |
| 33 | + |
| 34 | +See also https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/database/#redis[OpenTelemetry Semantic Conventions] for further reference. |
| 35 | + |
| 36 | +[[observability-metrics]] |
| 37 | +== Observability - Metrics |
| 38 | + |
| 39 | +Below you can find a list of all metrics declared by this project. |
| 40 | + |
| 41 | +[[observability-metrics-redis-command-observation]] |
| 42 | +== Redis Command Observation |
| 43 | + |
| 44 | +____ |
| 45 | +Timer created around a Redis command execution. |
| 46 | +____ |
| 47 | + |
| 48 | +**Metric name** `spring.data.redis`. **Type** `timer` and **base unit** `seconds`. |
| 49 | + |
| 50 | +Fully qualified name of the enclosing class `org.springframework.data.redis.connection.lettuce.observability.RedisObservation`. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +.Low cardinality Keys |
| 55 | +[cols="a,a"] |
| 56 | +|=== |
| 57 | +|Name | Description |
| 58 | +|`db.operation`|Redis command value. |
| 59 | +|`db.redis.database_index`|Redis database index. |
| 60 | +|`db.system`|Database system. |
| 61 | +|`db.user`|Redis user. |
| 62 | +|`net.peer.name`|Name of the database host. |
| 63 | +|`net.peer.port`|Logical remote port number. |
| 64 | +|`net.sock.peer.addr`|Mongo peer address. |
| 65 | +|`net.sock.peer.port`|Mongo peer port. |
| 66 | +|`net.transport`|Network transport. |
| 67 | +|=== |
| 68 | + |
| 69 | +.High cardinality Keys |
| 70 | +[cols="a,a"] |
| 71 | +|=== |
| 72 | +|Name | Description |
| 73 | +|`db.statement`|Redis statement. |
| 74 | +|`spring.data.redis.command.error`|Redis error response. |
| 75 | +|=== |
| 76 | + |
| 77 | +[[observability-spans]] |
| 78 | +== Observability - Spans |
| 79 | + |
| 80 | +Below you can find a list of all spans declared by this project. |
| 81 | + |
| 82 | +[[observability-spans-redis-command-observation]] |
| 83 | +== Redis Command Observation Span |
| 84 | + |
| 85 | +> Timer created around a Redis command execution. |
| 86 | + |
| 87 | +**Span name** `spring.data.redis`. |
| 88 | + |
| 89 | +Fully qualified name of the enclosing class `org.springframework.data.redis.connection.lettuce.observability.RedisObservation`. |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +.Tag Keys |
| 94 | +|=== |
| 95 | +|Name | Description |
| 96 | +|`db.operation`|Redis command value. |
| 97 | +|`db.redis.database_index`|Redis database index. |
| 98 | +|`db.statement`|Redis statement. |
| 99 | +|`db.system`|Database system. |
| 100 | +|`db.user`|Redis user. |
| 101 | +|`net.peer.name`|Name of the database host. |
| 102 | +|`net.peer.port`|Logical remote port number. |
| 103 | +|`net.sock.peer.addr`|Mongo peer address. |
| 104 | +|`net.sock.peer.port`|Mongo peer port. |
| 105 | +|`net.transport`|Network transport. |
| 106 | +|`spring.data.redis.command.error`|Redis error response. |
| 107 | +|=== |
0 commit comments