ddtrace 0.12.1 → 0.13.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env +11 -21
- data/.rubocop.yml +1 -4
- data/Appraisals +75 -439
- data/CHANGELOG.md +16 -19
- data/Rakefile +89 -259
- data/circle.yml +69 -0
- data/ddtrace.gemspec +6 -6
- data/docker-compose.yml +37 -222
- data/docs/GettingStarted.md +260 -19
- data/gemfiles/contrib.gemfile +5 -0
- data/gemfiles/contrib_old.gemfile +4 -1
- data/gemfiles/rails30_postgres.gemfile +0 -1
- data/gemfiles/rails30_postgres_sidekiq.gemfile +0 -1
- data/gemfiles/rails32_mysql2.gemfile +0 -1
- data/gemfiles/rails32_postgres.gemfile +0 -1
- data/gemfiles/rails32_postgres_redis.gemfile +0 -1
- data/gemfiles/rails32_postgres_sidekiq.gemfile +0 -1
- data/gemfiles/rails5_mysql2.gemfile +1 -1
- data/gemfiles/rails5_postgres.gemfile +1 -1
- data/gemfiles/rails5_postgres_redis.gemfile +1 -1
- data/gemfiles/rails5_postgres_sidekiq.gemfile +1 -1
- data/lib/ddtrace.rb +6 -0
- data/lib/ddtrace/configuration.rb +2 -2
- data/lib/ddtrace/contrib/active_model_serializers/event.rb +57 -0
- data/lib/ddtrace/contrib/active_model_serializers/events.rb +30 -0
- data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +32 -0
- data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +35 -0
- data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +62 -0
- data/lib/ddtrace/contrib/active_record/event.rb +30 -0
- data/lib/ddtrace/contrib/active_record/events.rb +30 -0
- data/lib/ddtrace/contrib/active_record/events/instantiation.rb +51 -0
- data/lib/ddtrace/contrib/active_record/events/sql.rb +48 -0
- data/lib/ddtrace/contrib/active_record/patcher.rb +3 -73
- data/lib/ddtrace/contrib/active_record/utils.rb +1 -15
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +62 -0
- data/lib/ddtrace/contrib/aws/instrumentation.rb +2 -2
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +2 -2
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +8 -40
- data/lib/ddtrace/contrib/excon/middleware.rb +140 -0
- data/lib/ddtrace/contrib/excon/patcher.rb +50 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +65 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +49 -0
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +66 -0
- data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +49 -0
- data/lib/ddtrace/contrib/grpc/patcher.rb +62 -0
- data/lib/ddtrace/contrib/http/patcher.rb +16 -18
- data/lib/ddtrace/contrib/racecar/event.rb +61 -0
- data/lib/ddtrace/contrib/racecar/events.rb +30 -0
- data/lib/ddtrace/contrib/racecar/events/batch.rb +27 -0
- data/lib/ddtrace/contrib/racecar/events/message.rb +27 -0
- data/lib/ddtrace/contrib/racecar/patcher.rb +6 -52
- data/lib/ddtrace/contrib/rack/middlewares.rb +65 -11
- data/lib/ddtrace/contrib/rack/patcher.rb +16 -0
- data/lib/ddtrace/contrib/rack/request_queue.rb +34 -0
- data/lib/ddtrace/contrib/rails/action_view.rb +65 -0
- data/lib/ddtrace/contrib/rails/active_support.rb +8 -9
- data/lib/ddtrace/contrib/rails/core_extensions.rb +115 -74
- data/lib/ddtrace/contrib/rake/instrumentation.rb +70 -0
- data/lib/ddtrace/contrib/rake/patcher.rb +53 -0
- data/lib/ddtrace/contrib/sequel/database.rb +58 -0
- data/lib/ddtrace/contrib/sequel/dataset.rb +59 -0
- data/lib/ddtrace/contrib/sequel/patcher.rb +56 -0
- data/lib/ddtrace/contrib/sequel/utils.rb +28 -0
- data/lib/ddtrace/ext/distributed.rb +5 -0
- data/lib/ddtrace/ext/grpc.rb +7 -0
- data/lib/ddtrace/ext/http.rb +35 -5
- data/lib/ddtrace/propagation/grpc_propagator.rb +54 -0
- data/lib/ddtrace/quantization/hash.rb +89 -0
- data/lib/ddtrace/tracer.rb +1 -4
- data/lib/ddtrace/utils.rb +4 -10
- data/lib/ddtrace/utils/database.rb +21 -0
- data/lib/ddtrace/version.rb +3 -3
- metadata +38 -13
- data/.circleci/config.yml +0 -456
- data/.circleci/images/primary/Dockerfile-1.9.3 +0 -69
- data/.circleci/images/primary/Dockerfile-2.0.0 +0 -69
- data/.circleci/images/primary/Dockerfile-2.1.10 +0 -69
- data/.circleci/images/primary/Dockerfile-2.2.10 +0 -69
- data/.circleci/images/primary/Dockerfile-2.3.7 +0 -73
- data/.circleci/images/primary/Dockerfile-2.4.4 +0 -73
- data/lib/ddtrace/contrib/rails/action_controller_patch.rb +0 -77
data/gemfiles/contrib.gemfile
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "pry-nav", git: "https://github.com/nixme/pry-nav.git", branch: "master"
|
6
|
+
gem "active_model_serializers", ">= 0.10.0"
|
6
7
|
gem "elasticsearch-transport"
|
8
|
+
gem "excon"
|
7
9
|
gem "mongo", "< 2.5"
|
8
10
|
gem "graphql"
|
9
11
|
gem "grape"
|
12
|
+
gem "grpc"
|
10
13
|
gem "rack"
|
11
14
|
gem "rack-test"
|
12
15
|
gem "redis", "< 4.0"
|
@@ -14,10 +17,12 @@ gem "hiredis"
|
|
14
17
|
gem "sinatra"
|
15
18
|
gem "sqlite3"
|
16
19
|
gem "activerecord", "< 5.1.5"
|
20
|
+
gem "sequel"
|
17
21
|
gem "sidekiq"
|
18
22
|
gem "aws-sdk"
|
19
23
|
gem "sucker_punch"
|
20
24
|
gem "dalli"
|
25
|
+
gem "rake"
|
21
26
|
gem "resque", "< 2.0"
|
22
27
|
gem "racecar", ">= 0.3.5"
|
23
28
|
gem "mysql2", "< 0.5", platform: :ruby
|
@@ -3,20 +3,23 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "pry-nav", git: "https://github.com/nixme/pry-nav.git", branch: "master"
|
6
|
+
gem "active_model_serializers", "~> 0.9.0"
|
6
7
|
gem "elasticsearch-transport"
|
8
|
+
gem "excon"
|
7
9
|
gem "mongo", "< 2.5"
|
8
10
|
gem "redis", "< 4.0"
|
9
11
|
gem "hiredis"
|
10
12
|
gem "rack", "1.4.7"
|
11
13
|
gem "rack-test", "0.7.0"
|
12
|
-
gem "rack-cache", "1.7.1"
|
13
14
|
gem "sinatra", "1.4.5"
|
14
15
|
gem "sqlite3"
|
16
|
+
gem "sequel", "~> 4.0", "< 4.37"
|
15
17
|
gem "activerecord", "3.2.22.5"
|
16
18
|
gem "sidekiq", "4.0.0"
|
17
19
|
gem "aws-sdk", "~> 2.0"
|
18
20
|
gem "sucker_punch"
|
19
21
|
gem "dalli"
|
22
|
+
gem "rake", "< 12.3"
|
20
23
|
gem "resque", "< 2.0"
|
21
24
|
gem "mysql2", "0.3.21", platform: :ruby
|
22
25
|
gem "activerecord-mysql-adapter", platform: :ruby
|
data/lib/ddtrace.rb
CHANGED
@@ -4,6 +4,7 @@ require 'ddtrace/registry'
|
|
4
4
|
require 'ddtrace/pin'
|
5
5
|
require 'ddtrace/tracer'
|
6
6
|
require 'ddtrace/error'
|
7
|
+
require 'ddtrace/quantization/hash'
|
7
8
|
require 'ddtrace/quantization/http'
|
8
9
|
require 'ddtrace/pipeline'
|
9
10
|
require 'ddtrace/configuration'
|
@@ -56,18 +57,23 @@ end
|
|
56
57
|
require 'ddtrace/contrib/base'
|
57
58
|
require 'ddtrace/contrib/rack/patcher'
|
58
59
|
require 'ddtrace/contrib/rails/patcher'
|
60
|
+
require 'ddtrace/contrib/active_model_serializers/patcher'
|
59
61
|
require 'ddtrace/contrib/active_record/patcher'
|
62
|
+
require 'ddtrace/contrib/sequel/patcher'
|
60
63
|
require 'ddtrace/contrib/elasticsearch/patcher'
|
61
64
|
require 'ddtrace/contrib/faraday/patcher'
|
62
65
|
require 'ddtrace/contrib/grape/patcher'
|
63
66
|
require 'ddtrace/contrib/graphql/patcher'
|
67
|
+
require 'ddtrace/contrib/grpc/patcher'
|
64
68
|
require 'ddtrace/contrib/redis/patcher'
|
65
69
|
require 'ddtrace/contrib/http/patcher'
|
66
70
|
require 'ddtrace/contrib/aws/patcher'
|
67
71
|
require 'ddtrace/contrib/sucker_punch/patcher'
|
68
72
|
require 'ddtrace/contrib/mongodb/patcher'
|
69
73
|
require 'ddtrace/contrib/dalli/patcher'
|
74
|
+
require 'ddtrace/contrib/rake/patcher'
|
70
75
|
require 'ddtrace/contrib/resque/patcher'
|
71
76
|
require 'ddtrace/contrib/racecar/patcher'
|
72
77
|
require 'ddtrace/contrib/sidekiq/patcher'
|
78
|
+
require 'ddtrace/contrib/excon/patcher'
|
73
79
|
require 'ddtrace/monkey'
|
@@ -9,11 +9,11 @@ module Datadog
|
|
9
9
|
|
10
10
|
def initialize(options = {})
|
11
11
|
@registry = options.fetch(:registry, Datadog.registry)
|
12
|
-
@wrapped_registry = {}
|
13
12
|
end
|
14
13
|
|
15
14
|
def [](integration_name)
|
16
|
-
|
15
|
+
integration = fetch_integration(integration_name)
|
16
|
+
Proxy.new(integration)
|
17
17
|
end
|
18
18
|
|
19
19
|
def use(integration_name, options = {})
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'ddtrace/contrib/active_support/notifications/event'
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Contrib
|
5
|
+
module ActiveModelSerializers
|
6
|
+
# Defines basic behaviors for an ActiveModelSerializers event.
|
7
|
+
module Event
|
8
|
+
def self.included(base)
|
9
|
+
base.send(:include, ActiveSupport::Notifications::Event)
|
10
|
+
base.send(:extend, ClassMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Class methods for ActiveModelSerializers events.
|
14
|
+
# Note, they share the same process method and before_trace method.
|
15
|
+
module ClassMethods
|
16
|
+
def span_options
|
17
|
+
{ service: configuration[:service_name] }
|
18
|
+
end
|
19
|
+
|
20
|
+
def tracer
|
21
|
+
configuration[:tracer]
|
22
|
+
end
|
23
|
+
|
24
|
+
def configuration
|
25
|
+
Datadog.configuration[:active_model_serializers]
|
26
|
+
end
|
27
|
+
|
28
|
+
def process(span, event, _id, payload)
|
29
|
+
span.service = configuration[:service_name]
|
30
|
+
|
31
|
+
# Set the resource name and serializer name
|
32
|
+
res = resource(payload[:serializer])
|
33
|
+
span.resource = res
|
34
|
+
span.set_tag('active_model_serializers.serializer', res)
|
35
|
+
|
36
|
+
span.span_type = Datadog::Ext::HTTP::TEMPLATE
|
37
|
+
|
38
|
+
# Will be nil in 0.9
|
39
|
+
span.set_tag('active_model_serializers.adapter', payload[:adapter].class) unless payload[:adapter].nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def resource(serializer)
|
45
|
+
# Depending on the version of ActiveModelSerializers
|
46
|
+
# serializer will be a string or an object.
|
47
|
+
if serializer.respond_to?(:name)
|
48
|
+
serializer.name
|
49
|
+
else
|
50
|
+
serializer
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'ddtrace/contrib/active_model_serializers/events/render'
|
2
|
+
require 'ddtrace/contrib/active_model_serializers/events/serialize'
|
3
|
+
|
4
|
+
module Datadog
|
5
|
+
module Contrib
|
6
|
+
module ActiveModelSerializers
|
7
|
+
# Defines collection of instrumented ActiveModelSerializers events
|
8
|
+
module Events
|
9
|
+
ALL = [
|
10
|
+
Events::Render,
|
11
|
+
Events::Serialize
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def all
|
17
|
+
self::ALL
|
18
|
+
end
|
19
|
+
|
20
|
+
def subscriptions
|
21
|
+
all.collect(&:subscriptions).collect(&:to_a).flatten
|
22
|
+
end
|
23
|
+
|
24
|
+
def subscribe!
|
25
|
+
all.each(&:subscribe!)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ddtrace/contrib/active_model_serializers/event'
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Contrib
|
5
|
+
module ActiveModelSerializers
|
6
|
+
module Events
|
7
|
+
# Defines instrumentation for render.active_model_serializers event
|
8
|
+
module Render
|
9
|
+
include ActiveModelSerializers::Event
|
10
|
+
|
11
|
+
EVENT_NAME = 'render.active_model_serializers'.freeze
|
12
|
+
SPAN_NAME = 'active_model_serializers.render'.freeze
|
13
|
+
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def supported?
|
17
|
+
Gem.loaded_specs['active_model_serializers'] \
|
18
|
+
&& Gem.loaded_specs['active_model_serializers'].version >= Gem::Version.new('0.10')
|
19
|
+
end
|
20
|
+
|
21
|
+
def event_name
|
22
|
+
self::EVENT_NAME
|
23
|
+
end
|
24
|
+
|
25
|
+
def span_name
|
26
|
+
self::SPAN_NAME
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ddtrace/contrib/active_model_serializers/event'
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Contrib
|
5
|
+
module ActiveModelSerializers
|
6
|
+
module Events
|
7
|
+
# Defines instrumentation for !serialize.active_model_serializers event
|
8
|
+
module Serialize
|
9
|
+
include ActiveModelSerializers::Event
|
10
|
+
|
11
|
+
EVENT_NAME = '!serialize.active_model_serializers'.freeze
|
12
|
+
SPAN_NAME = 'active_model_serializers.serialize'.freeze
|
13
|
+
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def supported?
|
17
|
+
Gem.loaded_specs['active_model_serializers'] \
|
18
|
+
&& ( \
|
19
|
+
Gem.loaded_specs['active_model_serializers'].version >= Gem::Version.new('0.9') \
|
20
|
+
&& Gem.loaded_specs['active_model_serializers'].version < Gem::Version.new('0.10') \
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def event_name
|
25
|
+
self::EVENT_NAME
|
26
|
+
end
|
27
|
+
|
28
|
+
def span_name
|
29
|
+
self::SPAN_NAME
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'ddtrace/ext/app_types'
|
2
|
+
require 'ddtrace/ext/http'
|
3
|
+
require 'ddtrace/contrib/active_model_serializers/events'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module Contrib
|
7
|
+
module ActiveModelSerializers
|
8
|
+
# Provides instrumentation for ActiveModelSerializers through ActiveSupport instrumentation signals
|
9
|
+
module Patcher
|
10
|
+
include Base
|
11
|
+
|
12
|
+
VERSION_REQUIRED = Gem::Version.new('0.9.0')
|
13
|
+
|
14
|
+
register_as :active_model_serializers
|
15
|
+
|
16
|
+
option :service_name, default: 'active_model_serializers'
|
17
|
+
option :tracer, default: Datadog.tracer do |value|
|
18
|
+
(value || Datadog.tracer).tap do |v|
|
19
|
+
# Make sure to update tracers of all subscriptions
|
20
|
+
Events.subscriptions.each do |subscription|
|
21
|
+
subscription.tracer = v
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def patch
|
28
|
+
return patched? if patched? || !compatible?
|
29
|
+
|
30
|
+
# Subscribe to ActiveModelSerializers events
|
31
|
+
Events.subscribe!
|
32
|
+
|
33
|
+
# Set service info
|
34
|
+
configuration[:tracer].set_service_info(
|
35
|
+
configuration[:service_name],
|
36
|
+
'active_model_serializers',
|
37
|
+
Ext::AppTypes::WEB
|
38
|
+
)
|
39
|
+
|
40
|
+
@patched = true
|
41
|
+
end
|
42
|
+
|
43
|
+
def patched?
|
44
|
+
return @patched if defined?(@patched)
|
45
|
+
@patched = false
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def configuration
|
51
|
+
Datadog.configuration[:active_model_serializers]
|
52
|
+
end
|
53
|
+
|
54
|
+
def compatible?
|
55
|
+
Gem.loaded_specs['active_model_serializers'] && Gem.loaded_specs['activesupport'] \
|
56
|
+
&& Gem.loaded_specs['active_model_serializers'].version >= VERSION_REQUIRED
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'ddtrace/contrib/active_support/notifications/event'
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Contrib
|
5
|
+
module ActiveRecord
|
6
|
+
# Defines basic behaviors for an ActiveRecord event.
|
7
|
+
module Event
|
8
|
+
def self.included(base)
|
9
|
+
base.send(:include, ActiveSupport::Notifications::Event)
|
10
|
+
base.send(:extend, ClassMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Class methods for ActiveRecord events.
|
14
|
+
module ClassMethods
|
15
|
+
def span_options
|
16
|
+
{ service: configuration[:service_name] }
|
17
|
+
end
|
18
|
+
|
19
|
+
def tracer
|
20
|
+
configuration[:tracer]
|
21
|
+
end
|
22
|
+
|
23
|
+
def configuration
|
24
|
+
Datadog.configuration[:active_record]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|