# How do I apply Elastic.Apm.StackExchange.Redis to Microsoft's IDistributedCache?

**URL:** <https://discuss.elastic.co/t/how-do-i-apply-elastic-apm-stackexchange-redis-to-microsofts-idistributedcache/292324>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [December 17, 2021, 2:35pm UTC](https://discuss.elastic.co/t/how-do-i-apply-elastic-apm-stackexchange-redis-to-microsofts-idistributedcache/292324 "2021-12-17T14:35:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skuc-fp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skuc-fp/32/99223_2.png) [@skuc-fp](https://discuss.elastic.co/u/skuc-fp)\
**Post date:** [December 17, 2021, 2:35pm UTC](https://discuss.elastic.co/t/how-do-i-apply-elastic-apm-stackexchange-redis-to-microsofts-idistributedcache/292324/1 "2021-12-17T14:35:17Z")

</div>

Like the title says, how do I apply Elastic.Apm.StackExchange.Redis to Microsoft's IDistributedCache?  
The package exposes an `UseElasticApm` extension method to `IConnectionMultiplexer`, but the `IDistributedCache` creates its own multiplexer, and doesn't expose it.

**APM Agent language and version** : dotnet 1.12.1

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: NuGet

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 7, 2022, 10:35am UTC](https://discuss.elastic.co/t/how-do-i-apply-elastic-apm-stackexchange-redis-to-microsofts-idistributedcache/292324/2 "2022-01-07T10:35:19Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [February 4, 2022, 10:29am UTC](https://discuss.elastic.co/t/how-do-i-apply-elastic-apm-stackexchange-redis-to-microsofts-idistributedcache/292324/3 "2022-02-04T10:29:09Z")

</div>

Unfortunately, it's not possible to get at the underlying `IConnectionMultiplexer` in Microsoft.Extensions.Caching.StackExchangeRedis 5.x.

It is however [possible in 6.x](https://www.nuget.org/packages/Microsoft.Extensions.Caching.StackExchangeRedis/6.0.1), using `RedisCacheOptions.ConnectionMultiplexerFactory`:

> <https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCacheOptions.cs#L31>
