-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Resque integration configuration (#546)
* Changed: ConfigurationHelpers#remove_patch! to work with Integration patchers. * Refactored: Resque to use Datadog::Contrib::Integration.
- Loading branch information
Showing
7 changed files
with
107 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'ddtrace/contrib/configuration/settings' | ||
require 'ddtrace/contrib/resque/ext' | ||
|
||
module Datadog | ||
module Contrib | ||
module Resque | ||
module Configuration | ||
# Custom settings for the Resque integration | ||
class Settings < Contrib::Configuration::Settings | ||
option :service_name, default: Ext::SERVICE_NAME | ||
option :workers, default: [] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Datadog | ||
module Contrib | ||
module Resque | ||
# Resque integration constants | ||
module Ext | ||
APP = 'resque'.freeze | ||
SERVICE_NAME = 'resque'.freeze | ||
|
||
SPAN_JOB = 'resque.job'.freeze | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'ddtrace/contrib/integration' | ||
require 'ddtrace/contrib/resque/configuration/settings' | ||
require 'ddtrace/contrib/resque/patcher' | ||
|
||
module Datadog | ||
module Contrib | ||
module Resque | ||
# Description of Resque integration | ||
class Integration | ||
include Contrib::Integration | ||
|
||
register_as :resque, auto_patch: true | ||
|
||
def self.version | ||
Gem.loaded_specs['resque'] && Gem.loaded_specs['resque'].version | ||
end | ||
|
||
def self.present? | ||
super && defined?(::Resque) | ||
end | ||
|
||
def default_configuration | ||
Configuration::Settings.new | ||
end | ||
|
||
def patcher | ||
Patcher | ||
end | ||
|
||
class << self | ||
# Globally-acccesible reference for pre-forking optimization | ||
attr_accessor :sync_writer | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
module ConfigurationHelpers | ||
def remove_patch!(integration) | ||
Datadog | ||
.registry[integration] | ||
.instance_variable_set('@patched', false) | ||
if Datadog.registry[integration].respond_to?(:patcher) | ||
Datadog.registry[integration].patcher.tap do |patcher| | ||
if patcher.instance_variable_defined?(:@done_once) | ||
patcher.instance_variable_get(:@done_once).delete(integration) | ||
end | ||
end | ||
else | ||
Datadog | ||
.registry[integration] | ||
.instance_variable_set('@patched', false) | ||
end | ||
end | ||
end |