Tracing cache calls
Caches such as Redis and Memcached are a special class of databases and are covered by database semantic conventions too. Instrumenting cache calls according to conventions is beneficial as it helps you to stay consistent across all services and to get the most out of your tracing backends in terms of visualization and analysis.
So, let’s instrument Redis according to database conventions and add cache-specific context. There is nothing specifically defined in OpenTelemetry for caches, so let’s design something of our own.
Note
Auto-instrumentation for the StackExchange.Redis
client is available in the OpenTelemetry.Instrumentation.StackExchangeRedis
NuGet package.
When it comes to tracing, we want to know typical things: how long a call took, whether there was an error, and what operation was attempted. Cache-specific things include an indication whether an item was retrieved from the cache or the expiration strategy (if it’s conditional...