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

Update Redis instrumentation to support v5 #1611

Merged
merged 7 commits into from
Nov 11, 2022
Merged

Conversation

kaylareopelle
Copy link
Contributor

@kaylareopelle kaylareopelle commented Nov 9, 2022

Co-authored-by: hramadan hramadan@newrelic.com

Redis gem 5.x comprises a major structural refactor for the library.

  • Calls to methods like get and set are no longer routed through call, but through a method named call_v
  • The methods we instrument have been moved into a new library, redis-client, a dependency of the redis gem.
  • Prepending onto the new library's class (::RedisClient) for the call_v and connect methods maintains consistent reporting behavior with earlier versions of Redis.
  • The location, behavior, and arguments of pipelined and multi methods changed.
  • In previous versions, pipeline and multi calls were routed through a method named call_pipeline. There is a similar method in Redis 5.x named call_pipelined. However, this method is not defined in ::RedisClient, preventing our prepend instrumentation from working. ::RedisClient defines multi and pipelined methods, but they do not have access to the NoSQL statement as an argument or other instance variable/method on the caller.
  • For call_pipelined, we now leverage Redis 5.x's new instrumentation API, ::RedisClient.register(module_name).
  • This process introduces instrumentation too late to capture errors at the segment level. Despite this shortcoming, this strategy is used for pipelined and multi calls because it has access to the NoSQL statement

Closes: #1361

P.S. Test coverage is very high for Redis instrumentation, so we could rely on the existing test suite to inform us of the gaps with this new major version.

Co-authored-by: hramadan <hramadan@newrelic.com>

Redis gem 5.x comprises a major structural refactor for the library.

* Calls to methods like get and set are no longer routed through `call`,
but through a method named `call_v`
* The methods we instrument have been moved into a new library,
redis-client, a dependency of the redis gem.
* Prepending onto the new library's class (::RedisClient) for the
`call_v` and connect methods maintains consistent reporting behavior
with earlier versions of Redis.
* The location, behavior, and arguments of pipelined and multi
methods changed.
* In previous versions, pipeline and multi calls were routed through a
method named `call_pipeline`. There is a similar method in Redis 5.x
named `call_pipelined`. However, this method is not defined in
::RedisClient, preventing our prepend instrumentation from working.
::RedisClient defines `multi` and `pipelined` methods, but they do not
have access to the NoSQL statement as an argument or other instance
variable/method on the caller.
* For `call_pipelined`, we now leverage Redis 5.x's new instrumentation
API, `::RedisClient.register(module_name)`.
* This process introduces instrumentation too late to capture errors at
the segment level. Despite this shortcoming, this strategy is used for
`pipelined` and `multi` calls because it has access to the NoSQL
statement
@kaylareopelle kaylareopelle marked this pull request as ready for review November 9, 2022 21:34
tannalynn
tannalynn previously approved these changes Nov 11, 2022
Copy link
Contributor

@tannalynn tannalynn left a comment

Choose a reason for hiding this comment

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

🎉

@github-actions
Copy link

SimpleCov Report

Coverage Threshold
Line 93.27% 93%
Branch 84.27% 84%

@@ -336,8 +336,8 @@ def simulated_error_class
end

def simulate_read_error
redis = Redis.new(:host => redis_host)
redis.send(client).stubs("establish_connection").raises(simulated_error_class, "Error connecting to Redis")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The stubbed method was changed to connect because establish_connection does not exist in Redis 5.0

@stevenou
Copy link

stevenou commented Nov 16, 2022

@kaylareopelle hi, I stumbled upon this PR because I am using redis-client with newrelic_rpm and am now encountering undefined method 'db' for #<RedisClient>

I am unclear on whether redis-client is even supported by newrelic_rpm or only redis...? I made the switch because sidekiq since version 7 now uses redis-client instead of redis.

Wondering if you can provide any guidance and/or whether this is something that is on your radar to address?

Using redis-client 0.11.1 and newrelic_rpm 8.13.0

@kaylareopelle
Copy link
Contributor Author

Hi @stevenou, thanks for bringing this to our attention. We're taking a look at the problem and hope to have more info for you soon.

@angelatan2
Copy link
Contributor

angelatan2 commented Nov 16, 2022

Hello @stevenou, thanks for sharing these findings so quickly. You can follow our development in this ticket #1639. I believe they are similar issues.

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.

CI: Introduce redis gem v5+ for testing
5 participants