Skip to content

Conversation

@RohanNagar
Copy link
Contributor

@RohanNagar RohanNagar commented Jun 27, 2025

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.

Addresses #3308 to avoid creating a RedisURI object when setting tracing tags. As explained in the issue, the current behavior results in unnecessary CPU usage.

This change caches the necessary information that is added to span tags each time the channel is registered.

This should work as long as the RedisUri attribute attached to the channel doesn't change (is that a correct assumption?).

The alternative is to just extract the information each time from channel.attr(ConnectionBuilder.REDIS_URI).get(). Something like:

        if (channel.hasAttr(ConnectionBuilder.REDIS_URI)) {
            String redisUriStr = channel.attr(ConnectionBuilder.REDIS_URI).get();
            span.tag("server.address", redisUriStr);
            span.tag("db.namespace", extractedDbValueFromRedisUriStr);
            span.tag("user.name", extractedUsernameValueFromRedisUriStr);
        }

Closes #3308

@RohanNagar
Copy link
Contributor Author

Hi @tishun I want to get your thoughts on this change - is it the right direction in order to address issue #3308? Thanks!

@tishun tishun requested review from a-TODO-rov and ggivo November 3, 2025 14:58
@tishun tishun added the type: improvement An improvement to the existing implementation label Nov 3, 2025
@tishun
Copy link
Collaborator

tishun commented Nov 3, 2025

Hey folks, ignore this last submit, I have another idea

@RohanNagar
Copy link
Contributor Author

Looking forward to a fix here!

@tishun tishun force-pushed the commandhandlertracing branch from 8c80d9b to ef08c88 Compare November 4, 2025 11:29
@tishun tishun force-pushed the commandhandlertracing branch from 4934ab7 to 96263de Compare November 4, 2025 12:25
@tishun
Copy link
Collaborator

tishun commented Nov 4, 2025

Spent an unusually long time thinking about this and made a full circle on the solution.

Tracing back our conversation with @ggivo to give some context to everyone reading:

Current solution:

@ggivo ggivo merged commit 5d96c67 into redis:main Nov 6, 2025
15 of 16 checks passed
ggivo pushed a commit that referenced this pull request Nov 6, 2025
ggivo pushed a commit that referenced this pull request Nov 6, 2025
ggivo added a commit that referenced this pull request Nov 6, 2025
…3504)

(cherry picked from commit 5d96c67)

Co-authored-by: Rohan Nagar <[email protected]>
Co-authored-by: Tihomir Mateev <[email protected]>
ggivo added a commit that referenced this pull request Nov 6, 2025
…3505)

(cherry picked from commit 5d96c67)

Co-authored-by: Rohan Nagar <[email protected]>
Co-authored-by: Tihomir Mateev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement An improvement to the existing implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid calling URI.toString when populating tracing span tags

3 participants