Instrumentation.StackExchangeRedis Should Resolve IConnectionMultiplexer from DI
See original GitHub issueFeature Request
I have registered IConnectionMultiplexer
in my DI container for health checks, a Redis implementation of IDistributedCache
and other reasons. It would be nice if OpenTelemetry.Instrumentation.StackExchangeRedis
contained an overload for the AddRedisInstrumentation
function that allows you to resolve IConnectionMultiplexer
from DI:
public static TracerProviderBuilder AddRedisInstrumentation(
this TracerProviderBuilder builder,
Func<IConnectionMultiplexer, IServiceBuilder> getConnection,
Action<StackExchangeRedisCallsInstrumentationOptions> configureOptions = null);
Another overload that assumes that IConnectionMultiplexer
is registered in DI would also be helpful:
public static TracerProviderBuilder AddRedisInstrumentation(
this TracerProviderBuilder builder,
Action<StackExchangeRedisCallsInstrumentationOptions> configureOptions = null);
Is your feature request related to a problem?
I have to create a new connection specifically for Open Telemetry.
Describe the solution you’d like:
I would like to reuse the connection I’m using elsewhere.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Redis Cache Calls In OpenTelemetry in DotNet
So the solution is to create it explicitly and pass and register in DI (if needed). So the code will be next: IConnectionMultiplexer...
Read more >StackExchange.Redis.Extensions
In a basic console app when DI resolves in constructor a error log raised: "Redis connection error restored." It comes from ConnectionRestored in ......
Read more >Dependency Injected StackExchange.Redis Client
I could not figure out how to add IDatabase to services. My CacheClient looks like this: public class CacheClient : ICacheClient { private ......
Read more >OpenTelemetry.Instrumentation.StackExchangeRedis 1.0.0 ...
This is a prerelease version of OpenTelemetry.Instrumentation.StackExchangeRedis. .NET CLI; Package Manager; PackageReference; Paket CLI ...
Read more >Handling Transient Failures in Azure Using Polly
In my experience I have found that these Redis timeout failures do resolve with in 1 or 2 retries. If retry strategy is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@trejjam it’s still possible, just a bit different, for rc4 you can do this:
Though I agree it’s a bit more cumbersome and the previous approach was better.
We’re trying to do something here! It is tricky because we’re supporting .NET Framework where
IServiceCollection
probably isn’t being used. The reason the API changed is we introduced this thing calledIDeferredTracerProviderBuilder
. Right now it is part of SDK. We’re trying to figure out how to get it into API. Once it is there, it should be possible to add an extension like this in OpenTelemetry.Instrumentation.StackExchangeRedis:That would allow it to automatically resolve
IConnectionMultiplexer
(& options) automatically through theIServiceProvider
and users won’t need to use the more cumbersome syntax shown above!