ddtrace 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/lib/ddtrace/contrib/active_record/events/sql.rb +1 -1
- data/lib/ddtrace/contrib/active_record/patcher.rb +0 -2
- data/lib/ddtrace/contrib/active_record/utils.rb +30 -7
- data/lib/ddtrace/version.rb +1 -1
- metadata +2 -3
- data/lib/ddtrace/contrib/active_record/patches/abstract_adapter.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40d91156b9aa968ec8412ffaea02b727deb47660
|
4
|
+
data.tar.gz: f45dd35b50a8f8b9db17a0421d88ae5b50e4fbd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f122ec820458d5fd1f0fe4502846a9ce84f725a24d749118e63d67f16aae5a0408c2101eab79c5f30e97850e7530a15fd4af384c4ebcdd170704a501fd24ac09
|
7
|
+
data.tar.gz: a5e0d439791bca6b6c48caeb54db0bc113875e97dc3a2c7c4c9ee3e05041578b204cc0fae21b4e8ea7cc71ca117d9b877417d9f4d732d8fa265b23f26437e9a8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@
|
|
4
4
|
|
5
5
|
## [Unreleased (beta)]
|
6
6
|
|
7
|
+
## [0.18.1] - 2018-12-20
|
8
|
+
|
9
|
+
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.18.1
|
10
|
+
|
11
|
+
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.18.0...v0.18.1
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- ActiveRecord `SystemStackError` with some 3rd party libraries. (@EpiFouloux, @tjgrathwell, @guizmaii)
|
16
|
+
|
7
17
|
## [0.18.0] - 2018-12-18
|
8
18
|
|
9
19
|
Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.18.0
|
@@ -594,8 +604,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
|
|
594
604
|
|
595
605
|
Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
|
596
606
|
|
597
|
-
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.
|
598
|
-
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.
|
607
|
+
[Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.1...master
|
608
|
+
[Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.1...0.19-dev
|
609
|
+
[0.18.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.18.0...v0.18.1
|
599
610
|
[0.18.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.17.3...v0.18.0
|
600
611
|
[0.17.3]: https://github.com/DataDog/dd-trace-rb/compare/v0.17.2...v0.17.3
|
601
612
|
[0.17.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.17.1...v0.17.2
|
@@ -24,7 +24,7 @@ module Datadog
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def process(span, event, _id, payload)
|
27
|
-
config = Utils.connection_config(payload[:connection])
|
27
|
+
config = Utils.connection_config(payload[:connection], payload[:connection_id])
|
28
28
|
settings = Datadog.configuration[:active_record, config]
|
29
29
|
adapter_name = Datadog::Utils::Database.normalize_vendor(config[:adapter])
|
30
30
|
service_name = if settings.service_name != Datadog::Utils::Database::VENDOR_DEFAULT
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'ddtrace/contrib/patcher'
|
2
|
-
require 'ddtrace/contrib/active_record/patches/abstract_adapter'
|
3
2
|
require 'ddtrace/contrib/active_record/events'
|
4
3
|
|
5
4
|
module Datadog
|
@@ -18,7 +17,6 @@ module Datadog
|
|
18
17
|
def patch
|
19
18
|
do_once(:active_record) do
|
20
19
|
begin
|
21
|
-
::ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Patches::AbstractAdapter)
|
22
20
|
Events.subscribe!
|
23
21
|
rescue StandardError => e
|
24
22
|
Datadog::Tracer.log.error("Unable to apply Active Record integration: #{e}")
|
@@ -21,14 +21,37 @@ module Datadog
|
|
21
21
|
connection_config[:port]
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
# In newer Rails versions, the `payload` contains both the `connection` and its `object_id` named `connection_id`.
|
25
|
+
#
|
26
|
+
# So, if rails is recent we'll have a direct access to the connection.
|
27
|
+
# Else, we'll find it thanks to the passed `connection_id`.
|
28
|
+
#
|
29
|
+
# See this PR for more details: https://github.com/rails/rails/pull/34602
|
30
|
+
#
|
31
|
+
def self.connection_config(connection = nil, connection_id = nil)
|
32
|
+
return default_connection_config if connection.nil? && connection_id.nil?
|
33
|
+
|
34
|
+
conn = if !connection.nil?
|
35
|
+
connection
|
36
|
+
# Rails 3.0 - 3.2
|
37
|
+
elsif Gem.loaded_specs['activerecord'].version < Gem::Version.new('4.0')
|
38
|
+
::ActiveRecord::Base
|
39
|
+
.connection_handler
|
40
|
+
.connection_pools
|
41
|
+
.values
|
42
|
+
.flat_map(&:connections)
|
43
|
+
.find { |c| c.object_id == connection_id }
|
44
|
+
# Rails 4.2+
|
45
|
+
else
|
46
|
+
::ActiveRecord::Base
|
47
|
+
.connection_handler
|
48
|
+
.connection_pool_list
|
49
|
+
.flat_map(&:connections)
|
50
|
+
.find { |c| c.object_id == connection_id }
|
51
|
+
end
|
27
52
|
|
28
|
-
|
29
|
-
|
30
|
-
if connection.instance_variable_defined?(:@config)
|
31
|
-
connection.instance_variable_get(:@config)
|
53
|
+
if conn.instance_variable_defined?(:@config)
|
54
|
+
conn.instance_variable_get(:@config)
|
32
55
|
else
|
33
56
|
EMPTY_CONFIG
|
34
57
|
end
|
data/lib/ddtrace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -312,7 +312,6 @@ files:
|
|
312
312
|
- lib/ddtrace/contrib/active_record/ext.rb
|
313
313
|
- lib/ddtrace/contrib/active_record/integration.rb
|
314
314
|
- lib/ddtrace/contrib/active_record/patcher.rb
|
315
|
-
- lib/ddtrace/contrib/active_record/patches/abstract_adapter.rb
|
316
315
|
- lib/ddtrace/contrib/active_record/utils.rb
|
317
316
|
- lib/ddtrace/contrib/active_support/notifications/event.rb
|
318
317
|
- lib/ddtrace/contrib/active_support/notifications/subscriber.rb
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'ddtrace/augmentation/shim'
|
3
|
-
|
4
|
-
module Datadog
|
5
|
-
module Contrib
|
6
|
-
module ActiveRecord
|
7
|
-
# Defines basic behaviors for an ActiveRecord event.
|
8
|
-
module Patches
|
9
|
-
# Adds patch to AbstractAdapter to make it pass more information through
|
10
|
-
# ActiveSupport notifications, for better instrumentation.
|
11
|
-
module AbstractAdapter
|
12
|
-
def self.included(base)
|
13
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
|
14
|
-
base.class_eval do
|
15
|
-
alias_method :log_without_datadog, :log
|
16
|
-
remove_method :log
|
17
|
-
include InstanceMethods
|
18
|
-
end
|
19
|
-
else
|
20
|
-
base.send(:prepend, InstanceMethods)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Compatibility shim for Rubies not supporting `.prepend`
|
25
|
-
module InstanceMethodsCompatibility
|
26
|
-
def log(*args, &block)
|
27
|
-
log_without_datadog(*args, &block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# InstanceMethods - implementing instrumentation
|
32
|
-
module InstanceMethods
|
33
|
-
include InstanceMethodsCompatibility unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0.0')
|
34
|
-
|
35
|
-
EVENT_ACTIVERECORD_SQL = 'sql.active_record'.freeze
|
36
|
-
|
37
|
-
# Override #log since sometimes connections are initialized prior
|
38
|
-
# to when the patch is applied; this will allow existing connections
|
39
|
-
# to receive the Shim as well.
|
40
|
-
def log(*args, &block)
|
41
|
-
insert_shim! unless shim_inserted?
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def shim_inserted?
|
48
|
-
instance_variable_defined?(:@instrumenter) \
|
49
|
-
&& Datadog::Shim.shim?(@instrumenter)
|
50
|
-
end
|
51
|
-
|
52
|
-
def insert_shim!
|
53
|
-
@instrumenter = Datadog::Shim.new(@instrumenter) do |shim|
|
54
|
-
connection = self
|
55
|
-
|
56
|
-
shim.override_method!(:instrument) do |*args, &block|
|
57
|
-
# Inject connection into arguments
|
58
|
-
if args[0] == EVENT_ACTIVERECORD_SQL && args[1].is_a?(Hash)
|
59
|
-
args[1][:connection] ||= connection
|
60
|
-
end
|
61
|
-
|
62
|
-
# Call original
|
63
|
-
shim_target.instrument(*args, &block)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|