-
Notifications
You must be signed in to change notification settings - Fork 283
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
[Instrumentation.StackExchangeRedis] Use different source names for connections #2001
[Instrumentation.StackExchangeRedis] Use different source names for connections #2001
Conversation
@YayBurritos - Please sign the CLA so that the PR can be reviewed. |
@vishweshbankwar : Yes, I'm working on getting the signature from my client. We had some folks out of the office last week. I apologize for the delay on this. I'm anxious to keep this moving along! |
@vishweshbankwar, @matt-hensley: FYI - CLA has been signed. Thanks for your patience! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I do not like the idea of this PR. The source name should be constant for the given library.
You can distinguish/decorate attributes using Enrich
on the options:
Consider something like:
x.Enrich = (activity, command) => activity.AddTag("your-custom-connection-attribute-name", "your-custom-connection-name")
Agree with @Kielek, dynamic ActivitySource naming is unusual. I believe the use case can be handled by named configurations /connections. |
@Kielek , @matt-hensley : Totally understand your concerns on this PR. The issue I'm trying to address is duplicate activities/spans being created when you attempt to instrument different Redis connection multiplexers. Enriching doesn't solve this problem. In our testing, if we have Connection A and Connection B, and there's an HMGET call for Connection A, we see two spans for the HMGET (since there are two multiplexers that are instrumented) rather than one. This is the behavior I'm trying to address here. This solution (while it may be "unusual") simply provides an option to instrument the connections independently - with the main goal of avoiding duplicate span creation. Users can continue to do things the old/standard way if they prefer. This is simply an additional option that can be used (not a required approach for anyone). Also, regarding ActivitySource naming (from https://opentelemetry.io/docs/languages/net/instrumentation/#setting-up-an-activitysource)...
If there's a better solution, I'm open to that so feel free to provide recommendations. But the library as-is seems to have an issue for our particular scenario. |
@YayBurritos, You should not call AddRedisInstrumentation twice. There is a dedicated way to add additional connection to the instrumentation. EDIT: If it does not help, could you please provide Minimal, Reproducible Example. There is a chance that we will be able to advice better solution for managing the connections. |
Hi @Kielek - Thanks for the reply! I did try the approach shown in #1193 (comment), but in my testing, that resulted in no Redis-related spans being produced. I was quite surprised by that result. I can look to provide an MRE. That will help me better understand if there's something odd/unusual with our application, or if we still see the same behavior with the library. |
@YayBurritos, any updated about MRE? |
HI @Kielek! I don't yet have an MRE to share, but I have been working on some reorg within our code and I may (still need to do more testing) have resolved our duplicate span issue without requiring any changes to the Again, still need to test a bit to prove that theory, but that's the path I'm heading down at the moment. Will let you know when I have some results. |
@Kielek : Upon further testing, it does appear that our duplicate span issue for Redis-related activity was the result of our overzealous use of exporters. I updated our application to only use one exporter (chained after the first instrumented Redis connection), but continue to call |
Great to hear that. Feel free to create issues or prs if you see any place for improvements. Especially PRs are.more than welcomed :) |
Fixes #1997
Changes
Use existing
name
parameter ofTracerProviderBuilderExtensions -> AddRedisInstrumentation
to create a uniqueActivitySource
for the Redis connection.Instrumenting multiple Redis connections
If
name
isn't provided, the prior (default) behavior will be respected.Default Behavior
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes