-
Notifications
You must be signed in to change notification settings - Fork 601
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
Add support for redis-clustering gem #2720
Changes from all commits
7b0293e
2b4c2ff
ac86f4b
bcf6c90
1ad495e
75e08b9
b317fa4
aea52de
ee711e0
902eef0
e4a95b4
695ef0f
982c3d2
46bfca5
337f888
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
module NewRelic::Agent::Instrumentation | ||
module RedisClient | ||
module ClusterMiddleware | ||
include NewRelic::Agent::Instrumentation::Redis | ||
|
||
# Until we decide to move our Redis instrumentation entirely off patches | ||
# keep the middleware instrumentation for the call and connect methods | ||
# limited to the redis-clustering instrumentation. | ||
# | ||
# Redis's middleware option does not capture errors as high in the stack | ||
# as our patches. Leaving the patches for call and connect on the main | ||
# Redis gem limits the feature disparity our customers experience. | ||
Comment on lines
+10
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this as a way to have a clean break for new Redis instrumentation. However, it does provide an inferior experience for error handling. We can look more closely into monkey-patching these methods, but we'll need to patch methods differently than we do for the main Redis gem. |
||
def call(*args, &block) | ||
call_with_tracing(args[0]) { super } | ||
end | ||
|
||
def connect(*args, &block) | ||
connect_with_tracing { super } | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ def test_records_metrics_for_connect | |
end | ||
|
||
def test_records_connect_tt_node_within_call_that_triggered_it | ||
skip_for_redis_clustering_gem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the end, it seemed the least intrusive to add skips for the six tests that are not compatible with redis-clustering instrumentation:
Open to further discussion to take a different approach! |
||
|
||
in_transaction do | ||
redis = Redis.new | ||
redis.get('foo') | ||
|
@@ -277,6 +279,8 @@ def test_records_instance_parameters_on_tt_node_for_get | |
end | ||
|
||
def test_records_hostname_on_tt_node_for_get_with_unix_domain_socket | ||
skip_for_redis_clustering_gem | ||
|
||
redis = Redis.new | ||
redis.send(client).stubs(:path).returns('/tmp/redis.sock') | ||
|
||
|
@@ -309,6 +313,8 @@ def test_records_instance_parameters_on_tt_node_for_multi | |
end | ||
|
||
def test_records_hostname_on_tt_node_for_multi_with_unix_domain_socket | ||
skip_for_redis_clustering_gem | ||
|
||
redis = Redis.new | ||
redis.send(client).stubs(:path).returns('/tmp/redis.sock') | ||
|
||
|
@@ -327,6 +333,8 @@ def test_records_hostname_on_tt_node_for_multi_with_unix_domain_socket | |
end | ||
|
||
def test_records_unknown_unknown_metric_when_error_gathering_instance_data | ||
skip_for_redis_clustering_gem | ||
|
||
redis = Redis.new | ||
redis.send(client).stubs(:path).raises(StandardError.new) | ||
in_transaction do | ||
|
@@ -347,6 +355,8 @@ def simulate_read_error | |
end | ||
|
||
def test_noticed_error_at_segment_and_txn_on_error | ||
skip_for_redis_clustering_gem | ||
|
||
txn = nil | ||
begin | ||
in_transaction do |redis_txn| | ||
|
@@ -362,6 +372,8 @@ def test_noticed_error_at_segment_and_txn_on_error | |
end | ||
|
||
def test_noticed_error_only_at_segment_on_error | ||
skip_for_redis_clustering_gem | ||
|
||
txn = nil | ||
in_transaction do |redis_txn| | ||
begin | ||
|
@@ -472,4 +484,8 @@ def either_hostname | |
[NewRelic::Agent::Hostname.get, 'redis'] | ||
end | ||
end | ||
|
||
def skip_for_redis_clustering_gem | ||
skip 'Incompatible with redis-clustering' if defined?(Redis::Cluster::Client) | ||
end | ||
end |
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.
redis-clustering doesn't need
prepend
norchain
instrumentation, those methods are instrumented in theClusterMiddleware
.