ddtrace 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +1 -1
- data/CHANGELOG.md +248 -0
- data/README.md +62 -48
- data/Rakefile +7 -0
- data/docs/GettingStarted.md +1 -1
- data/gemfiles/contrib.gemfile +1 -1
- data/lib/ddtrace/contrib/rack/middlewares.rb +30 -8
- data/lib/ddtrace/contrib/rails/action_controller.rb +9 -11
- data/lib/ddtrace/contrib/rails/action_view.rb +5 -1
- data/lib/ddtrace/contrib/rails/active_record.rb +7 -3
- data/lib/ddtrace/contrib/rails/active_support.rb +6 -2
- data/lib/ddtrace/contrib/rails/core_extensions.rb +245 -218
- data/lib/ddtrace/contrib/rails/middlewares.rb +7 -2
- data/lib/ddtrace/contrib/rails/railtie.rb +4 -1
- data/lib/ddtrace/contrib/rails/utils.rb +12 -0
- data/lib/ddtrace/ext/http.rb +1 -0
- data/lib/ddtrace/patcher.rb +32 -10
- data/lib/ddtrace/version.rb +1 -1
- metadata +3 -2
@@ -22,8 +22,13 @@ module Datadog
|
|
22
22
|
# SignalException::Interrupt would still bubble up.
|
23
23
|
rescue Exception => e
|
24
24
|
tracer = Datadog.configuration[:rails][:tracer]
|
25
|
-
span = tracer.active_span
|
26
|
-
|
25
|
+
span = tracer.active_span
|
26
|
+
unless span.nil?
|
27
|
+
# Only set error if it's supposed to be flagged as such
|
28
|
+
# e.g. we don't want to flag 404s.
|
29
|
+
# You can add custom errors via `config.action_dispatch.rescue_responses`
|
30
|
+
span.set_error(e) if Utils.exception_is_error?(e)
|
31
|
+
end
|
27
32
|
raise e
|
28
33
|
end
|
29
34
|
end
|
@@ -6,7 +6,10 @@ module Datadog
|
|
6
6
|
# Railtie class initializes
|
7
7
|
class Railtie < Rails::Railtie
|
8
8
|
config.app_middleware.insert_before(0, Datadog::Contrib::Rack::TraceMiddleware)
|
9
|
-
|
9
|
+
# Insert right after Rails exception handling middleware, because if it's before,
|
10
|
+
# it catches and swallows the error. If it's too far after, custom middleware can find itself
|
11
|
+
# between, and raise exceptions that don't end up getting tagged on the request properly (e.g lost stack trace.)
|
12
|
+
config.app_middleware.insert_after(ActionDispatch::ShowExceptions, Datadog::Contrib::Rails::ExceptionMiddleware)
|
10
13
|
|
11
14
|
config.after_initialize do
|
12
15
|
Datadog::Contrib::Rails::Framework.setup
|
@@ -72,6 +72,18 @@ module Datadog
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
def self.exception_is_error?(exception)
|
76
|
+
if defined?(::ActionDispatch::ExceptionWrapper)
|
77
|
+
# Gets the equivalent status code for the exception (not all are 5XX)
|
78
|
+
# You can add custom errors via `config.action_dispatch.rescue_responses`
|
79
|
+
status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
|
80
|
+
# Only 5XX exceptions are actually errors (e.g. don't flag 404s)
|
81
|
+
status.to_s.starts_with?('5')
|
82
|
+
else
|
83
|
+
true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
75
87
|
private_class_method :connection_config
|
76
88
|
end
|
77
89
|
end
|
data/lib/ddtrace/ext/http.rb
CHANGED
data/lib/ddtrace/patcher.rb
CHANGED
@@ -1,18 +1,40 @@
|
|
1
1
|
module Datadog
|
2
2
|
# Defines some useful patching methods for integrations
|
3
3
|
module Patcher
|
4
|
-
|
4
|
+
def self.included(base)
|
5
|
+
base.send(:extend, CommonMethods)
|
6
|
+
base.send(:include, CommonMethods)
|
7
|
+
end
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# Defines some common methods for patching, that can be used
|
10
|
+
# at the instance, class, or module level.
|
11
|
+
module CommonMethods
|
12
|
+
def without_warnings
|
13
|
+
# This is typically used when monkey patching functions such as
|
14
|
+
# intialize, which Ruby advices you not to. Use cautiously.
|
15
|
+
v = $VERBOSE
|
16
|
+
$VERBOSE = nil
|
17
|
+
begin
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
$VERBOSE = v
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def do_once(key = nil)
|
25
|
+
# If already done, don't do again
|
26
|
+
@done_once ||= {}
|
27
|
+
return @done_once[key] if @done_once.key?(key)
|
28
|
+
|
29
|
+
# Otherwise 'do'
|
30
|
+
yield.tap do
|
31
|
+
# Then add the key so we don't do again.
|
32
|
+
@done_once[key] = true
|
33
|
+
end
|
15
34
|
end
|
16
35
|
end
|
36
|
+
|
37
|
+
# Extend the common methods so they're available as a module function.
|
38
|
+
extend(CommonMethods)
|
17
39
|
end
|
18
40
|
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.11.
|
4
|
+
version: 0.11.3
|
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-
|
11
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- ".rubocop.yml"
|
223
223
|
- ".yardopts"
|
224
224
|
- Appraisals
|
225
|
+
- CHANGELOG.md
|
225
226
|
- Gemfile
|
226
227
|
- LICENSE
|
227
228
|
- README.md
|