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

Propagate database number, user, and RedisURI into Tracing #3005

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thachlp
Copy link
Contributor

@thachlp thachlp commented Oct 3, 2024

Issue: #2232

Make sure that:

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

Copy link
Collaborator

@tishun tishun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @thachlp , thanks for the contribution!

Did you try this code out in a live environment?

@@ -478,6 +482,13 @@ private void attachTracing(ChannelHandlerContext ctx, RedisCommand<?, ?, ?> comm
Tracer.Span span = tracer.nextSpan(context);
span.name(command.getType().name());

String redisUriStr = ctx.channel().attr(ConnectionBuilder.REDIS_URI).get();
RedisURI redisURI = RedisURI.create(redisUriStr);
span.tag("db.uri", redisURI.toString());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on how you chose the attribute names?
I had a quick look at the semantic conventions for Redis and seems the recommendations are different? Not an expert myself though, so I may also be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just set the tag using parameters from RedisURI.
I think it is better to follow the semantic convention, thanks for pointing it.
By the way, the user is missing from semantic conventions for Redis, so I removed it, What do you think?

@@ -478,6 +482,13 @@ private void attachTracing(ChannelHandlerContext ctx, RedisCommand<?, ?, ?> comm
Tracer.Span span = tracer.nextSpan(context);
span.name(command.getType().name());

String redisUriStr = ctx.channel().attr(ConnectionBuilder.REDIS_URI).get();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there is a chance that the attribute is missing, so it would be good to make this whole logic conditional, e.g.

        if (channel.hasAttr(ConnectionBuilder.REDIS_URI)) {
           ...
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense, I updated 🙇

@thachlp
Copy link
Contributor Author

thachlp commented Oct 7, 2024

Hey @thachlp , thanks for the contribution!

Did you try this code out in a live environment?

Not yet, I just updated to verify the update.

@thachlp thachlp requested a review from tishun October 7, 2024 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants