StackExchange.Redis
可以通过引用 Elastic.Apm.StackExchange.Redis
包并在 IConnectionMultiplexer
上调用 Elastic.Apm.StackExchange.Redis
中定义的 UseElasticApm()
扩展方法来为 StackExchange.Redis
启用检测。
// using Elastic.Apm.StackExchange.Redis;
var connection = await ConnectionMultiplexer.ConnectAsync("<redis connection>");
connection.UseElasticApm();
在 IConnectionMultiplexer
中注册了一个回调,为每个事务和 Span 提供分析会话,这些会话会捕获使用 IConnectionMultiplexer
发送的 Redis 命令。