Skip to content

Commit b55af8a

Browse files
authored
Use public prepend, include, and extend methods (#1509)
1 parent 88d321b commit b55af8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+129
-129
lines changed

lib/ddtrace/configuration/base.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module Configuration
66
# Basic configuration behavior
77
module Base
88
def self.included(base)
9-
base.send(:extend, Datadog::Environment::Helpers)
10-
base.send(:include, Datadog::Environment::Helpers)
11-
base.send(:include, Options)
9+
base.extend(Datadog::Environment::Helpers)
10+
base.include(Datadog::Environment::Helpers)
11+
base.include(Options)
1212

13-
base.send(:extend, ClassMethods)
14-
base.send(:include, InstanceMethods)
13+
base.extend(ClassMethods)
14+
base.include(InstanceMethods)
1515
end
1616

1717
# Class methods for configuration

lib/ddtrace/configuration/options.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module Configuration
77
# Behavior for a configuration object that has options
88
module Options
99
def self.included(base)
10-
base.send(:extend, ClassMethods)
11-
base.send(:include, InstanceMethods)
10+
base.extend(ClassMethods)
11+
base.include(InstanceMethods)
1212
end
1313

1414
# Class behavior for a configuration object with options

lib/ddtrace/contrib/action_cable/event.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module ActionCable
88
# Defines basic behaviors for an event.
99
module Event
1010
def self.included(base)
11-
base.send(:include, ActiveSupport::Notifications::Event)
12-
base.send(:extend, ClassMethods)
11+
base.include(ActiveSupport::Notifications::Event)
12+
base.extend(ClassMethods)
1313
end
1414

1515
# Class methods for events.
@@ -34,8 +34,8 @@ def configuration
3434
# but to start a fresh tracing context.
3535
module RootContextEvent
3636
def self.included(base)
37-
base.send(:include, ActiveSupport::Notifications::Event)
38-
base.send(:extend, ClassMethods)
37+
base.include(ActiveSupport::Notifications::Event)
38+
base.extend(ClassMethods)
3939
end
4040

4141
# Class methods for events.

lib/ddtrace/contrib/action_pack/action_controller/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def target_version
1616
end
1717

1818
def patch
19-
::ActionController::Metal.send(:prepend, ActionController::Instrumentation::Metal)
19+
::ActionController::Metal.prepend(ActionController::Instrumentation::Metal)
2020
end
2121
end
2222
end

lib/ddtrace/contrib/action_view/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module ActionView
66
# Defines basic behavior for an ActionView event.
77
module Event
88
def self.included(base)
9-
base.send(:include, ActiveSupport::Notifications::Event)
10-
base.send(:extend, ClassMethods)
9+
base.include(ActiveSupport::Notifications::Event)
10+
base.extend(ClassMethods)
1111
end
1212

1313
# Class methods for ActionView events.

lib/ddtrace/contrib/action_view/patcher.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ def patch_renderer
3131
# Rendering events are not nested in this version, creating
3232
# render_partial spans outside of the parent render_template span.
3333
# We fall back to manual patching instead.
34-
::ActionView::TemplateRenderer.send(:prepend, Instrumentation::TemplateRenderer::RailsLessThan4)
35-
::ActionView::PartialRenderer.send(:prepend, Instrumentation::PartialRenderer::RailsLessThan4)
34+
::ActionView::TemplateRenderer.prepend(Instrumentation::TemplateRenderer::RailsLessThan4)
35+
::ActionView::PartialRenderer.prepend(Instrumentation::PartialRenderer::RailsLessThan4)
3636
elsif defined?(::ActionView::Rendering) && defined?(::ActionView::Partials::PartialRenderer)
3737
# NOTE: Rails < 3.1 compatibility: different classes are used
38-
::ActionView::Rendering.send(:prepend, Instrumentation::TemplateRenderer::Rails30)
39-
::ActionView::Partials::PartialRenderer.send(:prepend, Instrumentation::PartialRenderer::RailsLessThan4)
38+
::ActionView::Rendering.prepend(Instrumentation::TemplateRenderer::Rails30)
39+
::ActionView::Partials::PartialRenderer.prepend(Instrumentation::PartialRenderer::RailsLessThan4)
4040
else
4141
Datadog.logger.debug('Expected Template/Partial classes not found; template rendering disabled')
4242
end

lib/ddtrace/contrib/active_model_serializers/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module ActiveModelSerializers
99
# Defines basic behaviors for an ActiveModelSerializers event.
1010
module Event
1111
def self.included(base)
12-
base.send(:include, ActiveSupport::Notifications::Event)
13-
base.send(:extend, ClassMethods)
12+
base.include(ActiveSupport::Notifications::Event)
13+
base.extend(ClassMethods)
1414
end
1515

1616
# Class methods for ActiveModelSerializers events.

lib/ddtrace/contrib/active_record/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module ActiveRecord
66
# Defines basic behaviors for an ActiveRecord event.
77
module Event
88
def self.included(base)
9-
base.send(:include, ActiveSupport::Notifications::Event)
10-
base.send(:extend, ClassMethods)
9+
base.include(ActiveSupport::Notifications::Event)
10+
base.extend(ClassMethods)
1111
end
1212

1313
# Class methods for ActiveRecord events.

lib/ddtrace/contrib/active_support/cache/patcher.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,37 @@ def cache_store_class(meth)
3030
end
3131

3232
def patch_cache_store_read
33-
cache_store_class(:read).send(:prepend, Cache::Instrumentation::Read)
33+
cache_store_class(:read).prepend(Cache::Instrumentation::Read)
3434
end
3535

3636
def patch_cache_store_read_multi
37-
cache_store_class(:read_multi).send(:prepend, Cache::Instrumentation::ReadMulti)
37+
cache_store_class(:read_multi).prepend(Cache::Instrumentation::ReadMulti)
3838
end
3939

4040
def patch_cache_store_fetch
41-
cache_store_class(:fetch).send(:prepend, Cache::Instrumentation::Fetch)
41+
cache_store_class(:fetch).prepend(Cache::Instrumentation::Fetch)
4242
end
4343

4444
def patch_cache_store_fetch_multi
4545
klass = cache_store_class(:fetch_multi)
4646
return unless klass.public_method_defined?(:fetch_multi)
4747

48-
klass.send(:prepend, Cache::Instrumentation::FetchMulti)
48+
klass.prepend(Cache::Instrumentation::FetchMulti)
4949
end
5050

5151
def patch_cache_store_write
52-
cache_store_class(:write).send(:prepend, Cache::Instrumentation::Write)
52+
cache_store_class(:write).prepend(Cache::Instrumentation::Write)
5353
end
5454

5555
def patch_cache_store_write_multi
5656
klass = cache_store_class(:write_multi)
5757
return unless klass.public_method_defined?(:write_multi)
5858

59-
klass.send(:prepend, Cache::Instrumentation::WriteMulti)
59+
klass.prepend(Cache::Instrumentation::WriteMulti)
6060
end
6161

6262
def patch_cache_store_delete
63-
cache_store_class(:delete).send(:prepend, Cache::Instrumentation::Delete)
63+
cache_store_class(:delete).prepend(Cache::Instrumentation::Delete)
6464
end
6565
end
6666
end

lib/ddtrace/contrib/active_support/notifications/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module Notifications
1010
# invoke Event.subscribe! to more easily subscribe to an event.
1111
module Event
1212
def self.included(base)
13-
base.send(:include, Subscriber)
14-
base.send(:extend, ClassMethods)
13+
base.include(Subscriber)
14+
base.extend(ClassMethods)
1515
base.send(:on_subscribe) { base.subscribe }
1616
end
1717

lib/ddtrace/contrib/active_support/notifications/subscriber.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Notifications
99
# Creates subscriptions that are wrapped with tracing.
1010
module Subscriber
1111
def self.included(base)
12-
base.send(:extend, ClassMethods)
12+
base.extend(ClassMethods)
1313
end
1414

1515
# Class methods that are implemented in the inheriting class.

lib/ddtrace/contrib/auto_instrument.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Contrib
66
# AutoInstrumentation enables all integration
77
module AutoInstrument
88
def self.extended(base)
9-
base.send(:extend, Patch)
9+
base.extend(Patch)
1010
end
1111

1212
# Patch adds method for invoking auto_instrumentation

lib/ddtrace/contrib/concurrent_ruby/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def patch
2020

2121
# Propagate tracing context in Concurrent::Future
2222
def patch_future
23-
::Concurrent::Future.send(:include, FuturePatch)
23+
::Concurrent::Future.include(FuturePatch)
2424
end
2525
end
2626
end

lib/ddtrace/contrib/configurable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Contrib
1010
# fallback.
1111
module Configurable
1212
def self.included(base)
13-
base.send(:include, InstanceMethods)
13+
base.include(InstanceMethods)
1414
end
1515

1616
# Configurable instance behavior for integrations

lib/ddtrace/contrib/cucumber/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Cucumber
66
# Instrumentation for Cucumber
77
module Instrumentation
88
def self.included(base)
9-
base.send(:prepend, InstanceMethods)
9+
base.prepend(InstanceMethods)
1010
end
1111

1212
# Instance methods for configuration

lib/ddtrace/contrib/cucumber/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def target_version
1515
end
1616

1717
def patch
18-
::Cucumber::Runtime.send(:include, Instrumentation)
18+
::Cucumber::Runtime.include(Instrumentation)
1919
end
2020
end
2121
end

lib/ddtrace/contrib/dalli/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Dalli
1010
# Instruments every interaction with the memcached server
1111
module Instrumentation
1212
def self.included(base)
13-
base.send(:prepend, InstanceMethods)
13+
base.prepend(InstanceMethods)
1414
end
1515

1616
# InstanceMethods - implementing instrumentation

lib/ddtrace/contrib/dalli/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def target_version
1717
end
1818

1919
def patch
20-
::Dalli::Server.send(:include, Instrumentation)
20+
::Dalli::Server.include(Instrumentation)
2121
end
2222
end
2323
end

lib/ddtrace/contrib/ethon/easy_patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Ethon
1111
# Ethon EasyPatch
1212
module EasyPatch
1313
def self.included(base)
14-
base.send(:prepend, InstanceMethods)
14+
base.prepend(InstanceMethods)
1515
end
1616

1717
# InstanceMethods - implementing instrumentation

lib/ddtrace/contrib/ethon/multi_patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Ethon
1111
module MultiPatch
1212
def self.included(base)
1313
# No need to prepend here since add method is included into Multi class
14-
base.send(:include, InstanceMethods)
14+
base.include(InstanceMethods)
1515
end
1616

1717
# InstanceMethods - implementing instrumentation

lib/ddtrace/contrib/ethon/patcher.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def patch
1616
require 'ddtrace/contrib/ethon/easy_patch'
1717
require 'ddtrace/contrib/ethon/multi_patch'
1818

19-
::Ethon::Easy.send(:include, EasyPatch)
20-
::Ethon::Multi.send(:include, MultiPatch)
19+
::Ethon::Easy.include(EasyPatch)
20+
::Ethon::Multi.include(MultiPatch)
2121
end
2222
end
2323
end

lib/ddtrace/contrib/extensions.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module Contrib
77
# Adds registry, configuration access for integrations.
88
module Extensions
99
def self.extended(base)
10-
Datadog.send(:extend, Helpers)
11-
Datadog.send(:extend, Configuration)
12-
Datadog::Configuration::Settings.send(:include, Configuration::Settings)
10+
Datadog.extend(Helpers)
11+
Datadog.extend(Configuration)
12+
Datadog::Configuration::Settings.include(Configuration::Settings)
1313
end
1414

1515
# Helper methods for Datadog module.

lib/ddtrace/contrib/faraday/patcher.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def add_default_middleware!
3434
::Faraday.default_connection.use(:ddtrace)
3535

3636
# Patch new connection instances (e.g. +Faraday.new+)
37-
::Faraday::Connection.send(:prepend, Connection)
37+
::Faraday::Connection.prepend(Connection)
3838
else
3939
# Patch the default connection (e.g. +Faraday.get+)
4040
#
@@ -44,7 +44,7 @@ def add_default_middleware!
4444
::Faraday.default_connection.builder.insert(idx, Middleware)
4545

4646
# Patch new connection instances (e.g. +Faraday.new+)
47-
::Faraday::RackBuilder.send(:prepend, RackBuilder)
47+
::Faraday::RackBuilder.prepend(RackBuilder)
4848
end
4949
end
5050
end

lib/ddtrace/contrib/grape/instrumentation.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Grape
44
# Instrumentation for Grape::Endpoint
55
module Instrumentation
66
def self.included(base)
7-
base.singleton_class.send(:prepend, ClassMethods)
8-
base.send(:prepend, InstanceMethods)
7+
base.singleton_class.prepend(ClassMethods)
8+
base.prepend(InstanceMethods)
99
end
1010

1111
# ClassMethods - implementing instrumentation

lib/ddtrace/contrib/grape/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def target_version
2020

2121
def patch
2222
# Patch endpoints
23-
::Grape::Endpoint.send(:include, Instrumentation)
23+
::Grape::Endpoint.include(Instrumentation)
2424

2525
# Subscribe to ActiveSupport events
2626
Datadog::Contrib::Grape::Endpoint.subscribe

lib/ddtrace/contrib/grpc/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def patch
2424

2525
def prepend_interceptor
2626
::GRPC::InterceptionContext
27-
.send(:prepend, Datadog::Contrib::GRPC::InterceptWithDatadog)
27+
.prepend(Datadog::Contrib::GRPC::InterceptWithDatadog)
2828
end
2929
end
3030
end

lib/ddtrace/contrib/http/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module HTTP
1414
# Instrumentation for Net::HTTP
1515
module Instrumentation
1616
def self.included(base)
17-
base.send(:prepend, InstanceMethods)
17+
base.prepend(InstanceMethods)
1818
end
1919

2020
# Span hook invoked after request is completed.

lib/ddtrace/contrib/http/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def target_version
1818

1919
# patch applies our patch if needed
2020
def patch
21-
::Net::HTTP.send(:include, Instrumentation)
21+
::Net::HTTP.include(Instrumentation)
2222
end
2323
end
2424
end

lib/ddtrace/contrib/httpclient/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Httpclient
1212
# Instrumentation for Httpclient
1313
module Instrumentation
1414
def self.included(base)
15-
base.send(:prepend, InstanceMethods)
15+
base.prepend(InstanceMethods)
1616
end
1717

1818
# Instance methods for configuration

lib/ddtrace/contrib/httpclient/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def target_version
2626
def patch
2727
PATCH_ONLY_ONCE.run do
2828
begin
29-
::HTTPClient.send(:include, Instrumentation)
29+
::HTTPClient.include(Instrumentation)
3030
rescue StandardError => e
3131
Datadog::Logger.error("Unable to apply httpclient integration: #{e}")
3232
end

lib/ddtrace/contrib/httprb/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Httprb
1212
# Instrumentation for Httprb
1313
module Instrumentation
1414
def self.included(base)
15-
base.send(:prepend, InstanceMethods)
15+
base.prepend(InstanceMethods)
1616
end
1717

1818
# Instance methods for configuration

lib/ddtrace/contrib/httprb/patcher.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def target_version
2626
def patch
2727
PATCH_ONLY_ONCE.run do
2828
begin
29-
::HTTP::Client.send(:include, Instrumentation)
29+
::HTTP::Client.include(Instrumentation)
3030
rescue StandardError => e
3131
Datadog::Logger.error("Unable to apply httprb integration: #{e}")
3232
end

lib/ddtrace/contrib/integration.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module Contrib
77
# Base provides features that are shared across all integrations
88
module Integration
99
def self.included(base)
10-
base.send(:include, Configurable)
11-
base.send(:include, Patchable)
12-
base.send(:include, Registerable)
10+
base.include(Configurable)
11+
base.include(Patchable)
12+
base.include(Registerable)
1313
end
1414
end
1515
end

0 commit comments

Comments
 (0)