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

Change the Redis client patch to use prepend #1743

Merged
merged 1 commit into from
Oct 28, 2021
Merged

Change the Redis client patch to use prepend #1743

merged 1 commit into from
Oct 28, 2021

Conversation

justinhoward
Copy link
Contributor

The current Redis patch uses alias_method which can cause conflicts with other libraries that use prepend to patch the same methods. This change moves the existing implementation to a separate Implementation module and uses prepend to patch methods instead of alias_method.

Fixes #1686

The current Redis patch uses alias_method which can cause conflicts with
other libraries that use prepend to patch the same methods. This change
moves the existing implementation to a separate Implementation module
and uses prepend to patch methods instead of alias_method.

Fixes #1686
@justinhoward justinhoward requested a review from a team October 27, 2021 22:52
end

# InstanceMethods - implementing instrumentation
module InstanceMethods
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 code in this module was moved verbatim from the patcher module except for the changes:

  • replaced "without" method calls with super
  • removed calls to alias_method and remove_method

module Contrib
module Redis
# Instrumentation for Redis
module Instrumentation
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 pattern for this module and the patcher module are copied from the http patcher.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fine.


RSpec.describe Datadog::Contrib::Redis::Patcher do
describe '.patch' do
it 'adds Instrumentation methods to ancestors of Redis class' do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This spec pattern is from the ethon patch

@codecov-commenter
Copy link

Codecov Report

Merging #1743 (f87dde8) into master (6180c0e) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1743      +/-   ##
==========================================
- Coverage   98.18%   98.18%   -0.01%     
==========================================
  Files         934      935       +1     
  Lines       45196    45191       -5     
==========================================
- Hits        44374    44369       -5     
  Misses        822      822              
Impacted Files Coverage Δ
lib/ddtrace/contrib/redis/instrumentation.rb 100.00% <100.00%> (ø)
lib/ddtrace/contrib/redis/patcher.rb 100.00% <100.00%> (ø)
spec/ddtrace/contrib/redis/patcher_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6180c0e...f87dde8. Read the comment docs.

Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Seems like a pretty straightforward change. Mirrors our other prepend implementations, tests are passing. Looks fine to me!

Thanks for sharing this!

module Contrib
module Redis
# Instrumentation for Redis
module Instrumentation
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fine.

@delner delner added community Was opened by a community member integrations Involves tracing integrations dev/refactor Involves refactoring existing components bug Involves a bug labels Oct 28, 2021
@delner delner added this to the 0.54.0 milestone Oct 28, 2021
@marcotc
Copy link
Member

marcotc commented Oct 28, 2021

Thank you again, @justinhoward! 🙇

@marcotc marcotc merged commit e84cdfa into DataDog:master Oct 28, 2021
@justinhoward
Copy link
Contributor Author

👍 Thanks for the review and merge @marcotc and @delner

@marcotc
Copy link
Member

marcotc commented Nov 18, 2021

👋 Thank you again @justinhoward, https://github.com/DataDog/dd-trace-rb/releases/tag/v0.54.0 was just released, including this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member dev/refactor Involves refactoring existing components integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redis stack level too deep
4 participants