Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackExchangeRedis support for uniquely instrumenting multiple Redis connections #1997

Closed
YayBurritos opened this issue Aug 6, 2024 · 2 comments
Labels
comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis enhancement New feature or request

Comments

@YayBurritos
Copy link

Component

OpenTelemetry.Instrumentation.StackExchangeRedis

Is your feature request related to a problem?

We have an application that uses a single Redis server for multiple purposes (e.g. caching and SignalR). If we try to call .AddRedisInstrumentation for each of our different Redis connections, we end up with duplicate spans in our traces.

The ActivityName and ActivitySource in StackExchangeRedisConnectionInstrumentation are the same for all Redis connections that are instrumented, rather than being able to support unique names/sources per Redis connection.

Being able to support "unique" instrumentation per Redis connection would prevent the duplicate spans we're currently experiencing. Further, it would allow us to specify different options (e.g. Enrich actions) for each connection as needed.

What is the expected behavior?

Ideally, each call to .AddRedisInstrumentation could effectively configure instrumentation that is unique per Redis connection if the consumer of the OpenTelemetry.Instrumentation.StackExchangeRedis library chooses to go this route.

The default behavior (all Redis connections are instrumented the same) would still be an option. This per-connection instrumentation I'm requesting would simply be optional.

Which alternative solutions or features have you considered?

I tried different instrumentation approaches using the library, but was unable to get the desired result. I either ended up with traces that seemed to be missing spans for calls related to certain Redis connections/commands, or traces with duplicate spans for a given Redis command.

Additional context

I've messed around with the code a bit to try to get a working PoC. I do have it working, but there may be a more elegant way to provide this support.

I'm happy to submit a PR for this and have folks much more familiar with the code to have a look.

@YayBurritos YayBurritos added the enhancement New feature or request label Aug 6, 2024
@github-actions github-actions bot added the comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis label Aug 6, 2024
@YayBurritos
Copy link
Author

Hopefully this helps illustrate what we're seeing.

On the left is a trace showing duplicate Redis-related spans (two HMGET calls in green and two GET calls in blue). Each pair is associated with a different Redis connection.

On the right is a trace with my updated code showing a single HMGET call in green and single GET call in blue. The green and blue spans are associated with different Redis connections.

redis-dup-spans-annotations

@Kielek
Copy link
Contributor

Kielek commented Sep 19, 2024

Closing per #2001 (comment)

@Kielek Kielek closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.stackexchangeredis Things related to OpenTelemetry.Instrumentation.StackExchangeRedis enhancement New feature or request
Projects
None yet
2 participants