ddtrace 0.8.1 → 0.8.2
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/docs/GettingStarted.md +8 -1
- data/gemfiles/contrib_old.gemfile +1 -1
- data/lib/ddtrace.rb +1 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +10 -1
- data/lib/ddtrace/contrib/rails/action_controller.rb +1 -5
- data/lib/ddtrace/contrib/rails/action_view.rb +2 -14
- data/lib/ddtrace/contrib/rails/active_support.rb +1 -7
- data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -11
- data/lib/ddtrace/error.rb +37 -0
- data/lib/ddtrace/ext/errors.rb +1 -0
- data/lib/ddtrace/provider.rb +5 -0
- data/lib/ddtrace/span.rb +6 -5
- data/lib/ddtrace/tracer.rb +1 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc0133019cee5e3bf12a664792a40ae95f320f7
|
4
|
+
data.tar.gz: 43f7412b5613d8fffc74ddd204bec29c81ac5118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9739cdc4f56336a81e6366b30658fa0f6670c403e7d5d2dd6014a3545f69fb4b3188acd0fb8b499a3a15e211f97ac3d50a81e5f3cc76cb9b8f612eb2778b18ac
|
7
|
+
data.tar.gz: 7b8c1ea6173c53e988548aca2a487357bf0022f23279e94c84097880c9a22866c3d0b9ef83ef34e18abfe85bdc12aa9760e55031b5ccd01020594ec78a2aa1a6
|
data/Appraisals
CHANGED
data/docs/GettingStarted.md
CHANGED
@@ -112,7 +112,7 @@ If you wish to disable all Rails auto-instrumentation, you need to set the env v
|
|
112
112
|
|
113
113
|
Eg, within Ruby:
|
114
114
|
|
115
|
-
ENV['DISABLE_DATADOG_RAILS'] = 1 # this must be done before ddtrace is included at all
|
115
|
+
ENV['DISABLE_DATADOG_RAILS'] = "1" # this must be done before ddtrace is included at all
|
116
116
|
require 'ddtrace'
|
117
117
|
|
118
118
|
Or, shell syntax, before launching Rails:
|
@@ -167,6 +167,8 @@ retrieved at the Rack level.
|
|
167
167
|
To start using the middleware in your generic Rack application, add it to your ``config.ru``:
|
168
168
|
|
169
169
|
# config.ru example
|
170
|
+
require 'ddtrace/contrib/rack/middlewares'
|
171
|
+
|
170
172
|
use Datadog::Contrib::Rack::TraceMiddleware
|
171
173
|
|
172
174
|
app = proc do |env|
|
@@ -178,6 +180,9 @@ To start using the middleware in your generic Rack application, add it to your `
|
|
178
180
|
Experimental distributed tracing support is available for this library.
|
179
181
|
You need to set the ``:distributed_tracing_enabled`` option to true, for example:
|
180
182
|
|
183
|
+
# config.ru example
|
184
|
+
require 'ddtrace/contrib/rack/middlewares'
|
185
|
+
|
181
186
|
use Datadog::Contrib::Rack::TraceMiddleware, distributed_tracing_enabled: true
|
182
187
|
|
183
188
|
app = proc do |env|
|
@@ -192,6 +197,8 @@ See [distributed tracing](#Distributed_Tracing) for details.
|
|
192
197
|
To modify the default middleware configuration, you can use middleware options as follows:
|
193
198
|
|
194
199
|
# config.ru example
|
200
|
+
require 'ddtrace/contrib/rack/middlewares'
|
201
|
+
|
195
202
|
Datadog.tracer.configure(
|
196
203
|
enabled: true,
|
197
204
|
hostname: localhost,
|
data/lib/ddtrace.rb
CHANGED
@@ -40,7 +40,7 @@ module Datadog
|
|
40
40
|
|
41
41
|
def configure
|
42
42
|
# ensure that the configuration is executed only once
|
43
|
-
return if @tracer && @service
|
43
|
+
return clean_context if @tracer && @service
|
44
44
|
|
45
45
|
# retrieve the current tracer and service
|
46
46
|
@tracer = @options.fetch(:tracer)
|
@@ -135,6 +135,15 @@ module Datadog
|
|
135
135
|
|
136
136
|
[status, headers, response]
|
137
137
|
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
# TODO: Remove this once we change how context propagation works. This
|
142
|
+
# ensures we clean thread-local variables on each HTTP request avoiding
|
143
|
+
# memory leaks.
|
144
|
+
def clean_context
|
145
|
+
@tracer.provider.context = Datadog::Context.new
|
146
|
+
end
|
138
147
|
end
|
139
148
|
end
|
140
149
|
end
|
@@ -66,11 +66,7 @@ module Datadog
|
|
66
66
|
else
|
67
67
|
status = '500'
|
68
68
|
end
|
69
|
-
if status.starts_with?('5')
|
70
|
-
span.status = 1
|
71
|
-
span.set_tag(Datadog::Ext::Errors::TYPE, error[0])
|
72
|
-
span.set_tag(Datadog::Ext::Errors::MSG, error[1])
|
73
|
-
end
|
69
|
+
span.set_error(error) if status.starts_with?('5')
|
74
70
|
end
|
75
71
|
ensure
|
76
72
|
span.start_time = start
|
@@ -74,13 +74,7 @@ module Datadog
|
|
74
74
|
template_name = Datadog::Contrib::Rails::Utils.normalize_template_name(payload.fetch(:identifier))
|
75
75
|
span.set_tag('rails.template_name', template_name)
|
76
76
|
span.set_tag('rails.layout', payload.fetch(:layout))
|
77
|
-
|
78
|
-
if payload[:exception]
|
79
|
-
error = payload[:exception]
|
80
|
-
span.status = 1
|
81
|
-
span.set_tag(Datadog::Ext::Errors::TYPE, error[0])
|
82
|
-
span.set_tag(Datadog::Ext::Errors::MSG, error[1])
|
83
|
-
end
|
77
|
+
span.set_error(payload[:exception]) if payload[:exception]
|
84
78
|
ensure
|
85
79
|
span.start_time = start
|
86
80
|
span.finish(finish)
|
@@ -102,13 +96,7 @@ module Datadog
|
|
102
96
|
begin
|
103
97
|
template_name = Datadog::Contrib::Rails::Utils.normalize_template_name(payload.fetch(:identifier))
|
104
98
|
span.set_tag('rails.template_name', template_name)
|
105
|
-
|
106
|
-
if payload[:exception]
|
107
|
-
error = payload[:exception]
|
108
|
-
span.status = 1
|
109
|
-
span.set_tag(Datadog::Ext::Errors::TYPE, error[0])
|
110
|
-
span.set_tag(Datadog::Ext::Errors::MSG, error[1])
|
111
|
-
end
|
99
|
+
span.set_error(payload[:exception]) if payload[:exception]
|
112
100
|
ensure
|
113
101
|
span.start_time = start
|
114
102
|
span.finish(finish)
|
@@ -97,13 +97,7 @@ module Datadog
|
|
97
97
|
store, = *Array.wrap(::Rails.configuration.cache_store).flatten
|
98
98
|
span.set_tag('rails.cache.backend', store)
|
99
99
|
span.set_tag('rails.cache.key', payload.fetch(:key))
|
100
|
-
|
101
|
-
if payload[:exception]
|
102
|
-
error = payload[:exception]
|
103
|
-
span.status = 1
|
104
|
-
span.set_tag(Datadog::Ext::Errors::TYPE, error[0])
|
105
|
-
span.set_tag(Datadog::Ext::Errors::MSG, error[1])
|
106
|
-
end
|
100
|
+
span.set_error(payload[:exception]) if payload[:exception]
|
107
101
|
ensure
|
108
102
|
span.start_time = start
|
109
103
|
span.finish(finish)
|
@@ -151,17 +151,7 @@ module Datadog
|
|
151
151
|
span.resource = "#{request.request_method} #{@datadog_route}"
|
152
152
|
span.set_tag('sinatra.route.path', @datadog_route)
|
153
153
|
span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, response.status)
|
154
|
-
|
155
|
-
if response.server_error?
|
156
|
-
span.status = 1
|
157
|
-
|
158
|
-
err = env['sinatra.error']
|
159
|
-
if err
|
160
|
-
span.set_tag(Datadog::Ext::Errors::TYPE, err.class)
|
161
|
-
span.set_tag(Datadog::Ext::Errors::MSG, err.message)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
154
|
+
span.set_error(env['sinatra.error']) if response.server_error?
|
165
155
|
span.finish()
|
166
156
|
ensure
|
167
157
|
@datadog_request_span = nil
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Datadog global namespace
|
2
|
+
module Datadog
|
3
|
+
# Error is a value-object responsible for sanitizing/encapsulating error data
|
4
|
+
class Error
|
5
|
+
attr_reader :type, :message, :backtrace
|
6
|
+
|
7
|
+
def self.build_from(value)
|
8
|
+
case value
|
9
|
+
when Error then value
|
10
|
+
when Array then new(*value)
|
11
|
+
when Exception then new(value.class, value.message, value.backtrace)
|
12
|
+
when ContainsMessage then new(value.class, value.message)
|
13
|
+
else BlankError
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(type = nil, message = nil, backtrace = nil)
|
18
|
+
backtrace = Array(backtrace).join("\n")
|
19
|
+
@type = sanitize(type)
|
20
|
+
@message = sanitize(message)
|
21
|
+
@backtrace = sanitize(backtrace)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def sanitize(value)
|
27
|
+
value = value.to_s
|
28
|
+
|
29
|
+
return value if value.encoding == ::Encoding::UTF_8
|
30
|
+
|
31
|
+
value.encode(::Encoding::UTF_8)
|
32
|
+
end
|
33
|
+
|
34
|
+
BlankError = Error.new
|
35
|
+
ContainsMessage = ->(v) { v.respond_to?(:message) }
|
36
|
+
end
|
37
|
+
end
|
data/lib/ddtrace/ext/errors.rb
CHANGED
data/lib/ddtrace/provider.rb
CHANGED
data/lib/ddtrace/span.rb
CHANGED
@@ -92,11 +92,12 @@ module Datadog
|
|
92
92
|
|
93
93
|
# Mark the span with the given error.
|
94
94
|
def set_error(e)
|
95
|
-
|
96
|
-
|
97
|
-
@
|
98
|
-
|
99
|
-
|
95
|
+
e = Error.build_from(e)
|
96
|
+
|
97
|
+
@status = Ext::Errors::STATUS
|
98
|
+
set_tag(Ext::Errors::TYPE, e.type) unless e.type.empty?
|
99
|
+
set_tag(Ext::Errors::MSG, e.message) unless e.message.empty?
|
100
|
+
set_tag(Ext::Errors::STACK, e.backtrace) unless e.backtrace.empty?
|
100
101
|
end
|
101
102
|
|
102
103
|
# Mark the span finished at the current time and submit it.
|
data/lib/ddtrace/tracer.rb
CHANGED
@@ -18,7 +18,7 @@ module Datadog
|
|
18
18
|
# of these function calls and sub-requests would be encapsulated within a single trace.
|
19
19
|
# rubocop:disable Metrics/ClassLength
|
20
20
|
class Tracer
|
21
|
-
attr_reader :writer, :sampler, :services, :tags
|
21
|
+
attr_reader :writer, :sampler, :services, :tags, :provider
|
22
22
|
attr_accessor :enabled
|
23
23
|
attr_writer :default_service
|
24
24
|
|
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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08
|
11
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/ddtrace/contrib/sinatra/tracer.rb
|
159
159
|
- lib/ddtrace/distributed.rb
|
160
160
|
- lib/ddtrace/encoding.rb
|
161
|
+
- lib/ddtrace/error.rb
|
161
162
|
- lib/ddtrace/ext/app_types.rb
|
162
163
|
- lib/ddtrace/ext/cache.rb
|
163
164
|
- lib/ddtrace/ext/distributed.rb
|
@@ -199,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
200
|
version: '0'
|
200
201
|
requirements: []
|
201
202
|
rubyforge_project:
|
202
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.4.5.2
|
203
204
|
signing_key:
|
204
205
|
specification_version: 4
|
205
206
|
summary: Datadog tracing code for your Ruby applications
|