-
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.
Merge pull request #544 from DataDog/refactor/upgrade_to_integration_…
…configuration Upgrade to integrations to new configuration API
- Loading branch information
Showing
174 changed files
with
2,711 additions
and
1,274 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
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
23 changes: 23 additions & 0 deletions
23
lib/ddtrace/contrib/active_model_serializers/configuration/settings.rb
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,23 @@ | ||
require 'ddtrace/contrib/configuration/settings' | ||
require 'ddtrace/contrib/active_model_serializers/ext' | ||
|
||
module Datadog | ||
module Contrib | ||
module ActiveModelSerializers | ||
module Configuration | ||
# Custom settings for the ActiveModelSerializers integration | ||
class Settings < Contrib::Configuration::Settings | ||
option :service_name, default: Ext::SERVICE_NAME | ||
option :tracer, default: Datadog.tracer do |value| | ||
(value || Datadog.tracer).tap do |v| | ||
# Make sure to update tracers of all subscriptions | ||
Events.subscriptions.each do |subscription| | ||
subscription.tracer = v | ||
end | ||
end | ||
end | ||
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
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,17 @@ | ||
module Datadog | ||
module Contrib | ||
module ActiveModelSerializers | ||
# ActiveModelSerializers integration constants | ||
module Ext | ||
APP = 'active_model_serializers'.freeze | ||
SERVICE_NAME = 'active_model_serializers'.freeze | ||
|
||
SPAN_RENDER = 'active_model_serializers.render'.freeze | ||
SPAN_SERIALIZE = 'active_model_serializers.serialize'.freeze | ||
|
||
TAG_ADAPTER = 'active_model_serializers.adapter'.freeze | ||
TAG_SERIALIZER = 'active_model_serializers.serializer'.freeze | ||
end | ||
end | ||
end | ||
end |
39 changes: 39 additions & 0 deletions
39
lib/ddtrace/contrib/active_model_serializers/integration.rb
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,39 @@ | ||
require 'ddtrace/contrib/integration' | ||
require 'ddtrace/contrib/active_model_serializers/configuration/settings' | ||
require 'ddtrace/contrib/active_model_serializers/patcher' | ||
|
||
module Datadog | ||
module Contrib | ||
module ActiveModelSerializers | ||
# Description of ActiveModelSerializers integration | ||
class Integration | ||
include Contrib::Integration | ||
|
||
register_as :active_model_serializers | ||
|
||
def self.version | ||
Gem.loaded_specs['active_model_serializers'] \ | ||
&& Gem.loaded_specs['active_model_serializers'].version | ||
end | ||
|
||
def self.present? | ||
super && defined?(::ActiveModel::Serializer) | ||
end | ||
|
||
def self.compatible? | ||
super \ | ||
&& defined?(::ActiveSupport::Notifications) \ | ||
&& version >= Gem::Version.new('0.9.0') | ||
end | ||
|
||
def default_configuration | ||
Configuration::Settings.new | ||
end | ||
|
||
def patcher | ||
Patcher | ||
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
Oops, something went wrong.