ddtrace 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Appraisals +38 -19
- data/README.md +13 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -11
- data/ddtrace.gemspec +1 -0
- data/docs/GettingStarted.md +96 -6
- data/gemfiles/rails30_postgres.gemfile +10 -0
- data/gemfiles/rails30_postgres_sidekiq.gemfile +11 -0
- data/gemfiles/{rails3_mysql2.gemfile → rails32_mysql2.gemfile} +0 -0
- data/gemfiles/{rails3_postgres.gemfile → rails32_postgres.gemfile} +0 -0
- data/gemfiles/{rails3_postgres_redis.gemfile → rails32_postgres_redis.gemfile} +0 -0
- data/gemfiles/{rails3_postgres_sidekiq.gemfile → rails32_postgres_sidekiq.gemfile} +1 -1
- data/lib/ddtrace/buffer.rb +1 -26
- data/lib/ddtrace/context.rb +145 -0
- data/lib/ddtrace/contrib/active_record/patcher.rb +2 -2
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +4 -4
- data/lib/ddtrace/contrib/http/patcher.rb +36 -9
- data/lib/ddtrace/contrib/rack/middlewares.rb +53 -12
- data/lib/ddtrace/contrib/rails/action_controller.rb +14 -5
- data/lib/ddtrace/contrib/rails/action_view.rb +3 -3
- data/lib/ddtrace/contrib/rails/active_record.rb +1 -1
- data/lib/ddtrace/contrib/rails/active_support.rb +2 -2
- data/lib/ddtrace/contrib/rails/core_extensions.rb +45 -20
- data/lib/ddtrace/contrib/rails/framework.rb +11 -0
- data/lib/ddtrace/distributed.rb +38 -0
- data/lib/ddtrace/ext/distributed.rb +10 -0
- data/lib/ddtrace/pin.rb +6 -4
- data/lib/ddtrace/provider.rb +16 -0
- data/lib/ddtrace/span.rb +54 -22
- data/lib/ddtrace/tracer.rb +120 -64
- data/lib/ddtrace/utils.rb +9 -2
- data/lib/ddtrace/version.rb +2 -2
- data/lib/ddtrace/workers.rb +1 -2
- data/lib/ddtrace/writer.rb +0 -1
- metadata +43 -27
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmE4OWFjODQ4NjI1ZDY5MzQyNWQxODg0MjhmNzczODNhOWEzZWE2Yg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 32267c0f9a646b5c68fec68446808b0338aee9fe
|
4
|
+
data.tar.gz: fe7fb33d51a89cc592aa83c6b52c0b5347d35d68
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjJmMjNmODllNmVkNDFjYTUyOTZiMmVjZTM0MjlmZDE5YzRhOGI2NWM1MTMx
|
11
|
-
OTQyZjVmMDM2ZWM1MDY1NDNjNTdiMDY0YWU3NTYwYjViNTZiNjQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YzYwYmRlODlhY2YxY2E2NjJmOWI2N2M1MTQ4YTQzN2JhMWE2NTE5ODIwZDk1
|
14
|
-
ODNiNzk4ZTU2ZGY1ZGQyZmI3YjhkMzUyNzNjNDQyNThhZDY3YTM5MzFjMzk3
|
15
|
-
ZjNhNjkxMjk4Yjc4YTRmZWY5YjRiYTdiMTA0NDAyMTA1MDEzZDM=
|
6
|
+
metadata.gz: 477f468fb2959ad9d5e48485ec3688d8c2368ce11784903ae76c820748b1772df99f50b25818647320ae4cad7dc7811847616c551092daa18a0fdc9fae883320
|
7
|
+
data.tar.gz: 777c16f17819d7d32f2c4d8544761690344ddac5473bd5ac0b2af45d6428d80c4db7bbbd7129a85780d1bb6fbb6cc60d9abe402dc60d8030fdaf2796643bc18f
|
data/Appraisals
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
if RUBY_VERSION < '2.4.0'
|
1
|
+
if RUBY_VERSION < '2.4.0' && RUBY_PLATFORM != 'java'
|
2
2
|
if RUBY_VERSION >= '1.9.1'
|
3
|
-
appraise '
|
3
|
+
appraise 'rails32-mysql2' do
|
4
4
|
gem 'test-unit'
|
5
5
|
gem 'rails', '3.2.22.5'
|
6
6
|
gem 'mysql2', '0.3.21', platform: :ruby
|
@@ -10,27 +10,46 @@ if RUBY_VERSION < '2.4.0'
|
|
10
10
|
end
|
11
11
|
|
12
12
|
if RUBY_VERSION >= '1.9.1'
|
13
|
-
appraise '
|
13
|
+
appraise 'rails30-postgres' do
|
14
14
|
gem 'test-unit'
|
15
|
-
gem 'rails', '3.
|
15
|
+
gem 'rails', '3.0.20'
|
16
16
|
gem 'pg', '0.15.1', platform: :ruby
|
17
17
|
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
if RUBY_VERSION < '2.2.2'
|
21
|
+
appraise 'rails30-postgres-sidekiq' do
|
22
|
+
gem 'test-unit'
|
23
|
+
gem 'rails', '3.0.20'
|
24
|
+
gem 'pg', '0.15.1', platform: :ruby
|
25
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
26
|
+
gem 'sidekiq', '4.0.0'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
appraise 'rails32-postgres' do
|
21
31
|
gem 'test-unit'
|
22
32
|
gem 'rails', '3.2.22.5'
|
23
33
|
gem 'pg', '0.15.1', platform: :ruby
|
24
34
|
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
25
|
-
gem 'redis-rails'
|
26
35
|
end
|
27
36
|
|
28
|
-
appraise '
|
37
|
+
appraise 'rails32-postgres-redis' do
|
29
38
|
gem 'test-unit'
|
30
39
|
gem 'rails', '3.2.22.5'
|
31
40
|
gem 'pg', '0.15.1', platform: :ruby
|
32
41
|
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
33
|
-
gem '
|
42
|
+
gem 'redis-rails'
|
43
|
+
end
|
44
|
+
|
45
|
+
if RUBY_VERSION < '2.2.2'
|
46
|
+
appraise 'rails32-postgres-sidekiq' do
|
47
|
+
gem 'test-unit'
|
48
|
+
gem 'rails', '3.2.22.5'
|
49
|
+
gem 'pg', '0.15.1', platform: :ruby
|
50
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
51
|
+
gem 'sidekiq', '4.0.0'
|
52
|
+
end
|
34
53
|
end
|
35
54
|
end
|
36
55
|
|
@@ -53,17 +72,9 @@ if RUBY_VERSION < '2.4.0'
|
|
53
72
|
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
54
73
|
gem 'redis-rails'
|
55
74
|
end
|
56
|
-
|
57
|
-
appraise 'rails4-postgres-sidekiq' do
|
58
|
-
gem 'rails', '4.2.7.1'
|
59
|
-
gem 'pg', platform: :ruby
|
60
|
-
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
61
|
-
gem 'sidekiq'
|
62
|
-
gem 'activejob'
|
63
|
-
end
|
64
75
|
end
|
65
76
|
|
66
|
-
if RUBY_VERSION >= '2.2.2'
|
77
|
+
if RUBY_VERSION >= '2.2.2'
|
67
78
|
appraise 'rails5-mysql2' do
|
68
79
|
gem 'rails', '5.0.1'
|
69
80
|
gem 'mysql2', platform: :ruby
|
@@ -84,12 +95,20 @@ if RUBY_VERSION < '2.4.0'
|
|
84
95
|
gem 'rails', '5.0.1'
|
85
96
|
gem 'pg', platform: :ruby
|
86
97
|
gem 'sidekiq'
|
87
|
-
gem
|
98
|
+
gem 'activejob'
|
99
|
+
end
|
100
|
+
|
101
|
+
appraise 'rails4-postgres-sidekiq' do
|
102
|
+
gem 'rails', '4.2.7.1'
|
103
|
+
gem 'pg', platform: :ruby
|
104
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
105
|
+
gem 'sidekiq'
|
106
|
+
gem 'activejob'
|
88
107
|
end
|
89
108
|
end
|
90
109
|
end
|
91
110
|
|
92
|
-
if RUBY_VERSION >= '2.2.2'
|
111
|
+
if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
|
93
112
|
appraise 'contrib' do
|
94
113
|
gem 'elasticsearch-transport'
|
95
114
|
gem 'grape'
|
data/README.md
CHANGED
@@ -84,6 +84,19 @@ you can activate it. The example above would become:
|
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
87
|
+
This will automatically trace any app inherited from `Sinatra::Application`.
|
88
|
+
To trace apps inherited from `Sinatra::Base`, you should manually register
|
89
|
+
the tracer inside your class.
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
require "ddtrace"
|
93
|
+
require "ddtrace/contrib/sinatra/tracer"
|
94
|
+
|
95
|
+
class App < Sinatra::Base
|
96
|
+
register Datadog::Contrib::Sinatra::Tracer
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
87
100
|
To know if a given framework or lib is supported by our client,
|
88
101
|
please consult our [integrations][contrib] list.
|
89
102
|
|
data/Rakefile
CHANGED
@@ -123,10 +123,9 @@ task :ci do
|
|
123
123
|
# check: https://circleci.com/docs/parallel-manual-setup/#env-splitting
|
124
124
|
case ENV['CIRCLE_NODE_INDEX'].to_i
|
125
125
|
when 0
|
126
|
-
sh 'rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS --verbose do rake test:main'
|
126
|
+
sh 'rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS,$JRUBY_VERSIONS --verbose do rake test:main'
|
127
127
|
sh 'rvm $LAST_STABLE --verbose do rake benchmark'
|
128
128
|
when 1
|
129
|
-
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:monkey'
|
130
129
|
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:elasticsearch'
|
131
130
|
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:http'
|
132
131
|
sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:redis'
|
@@ -142,16 +141,17 @@ task :ci do
|
|
142
141
|
sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:rack'
|
143
142
|
sh 'rvm $SIDEKIQ_OLD_VERSIONS --verbose do appraisal contrib-old rake test:sidekiq'
|
144
143
|
when 2
|
145
|
-
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal
|
146
|
-
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal
|
147
|
-
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal
|
144
|
+
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal rails30-postgres rake test:rails'
|
145
|
+
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal rails32-mysql2 rake test:rails'
|
146
|
+
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal rails32-postgres rake test:rails'
|
147
|
+
sh 'rvm $RAILS3_VERSIONS --verbose do appraisal rails32-postgres-redis rake test:railsredis'
|
148
148
|
sh 'rvm $RAILS4_VERSIONS --verbose do appraisal rails4-mysql2 rake test:rails'
|
149
149
|
sh 'rvm $RAILS4_VERSIONS --verbose do appraisal rails4-postgres rake test:rails'
|
150
150
|
sh 'rvm $RAILS4_VERSIONS --verbose do appraisal rails4-postgres-redis rake test:railsredis'
|
151
|
-
|
152
|
-
sh 'rvm $
|
153
|
-
sh 'rvm $
|
154
|
-
sh 'rvm $
|
151
|
+
sh 'rvm $RAILS3_SIDEKIQ_VERSIONS --verbose do appraisal rails30-postgres-sidekiq rake test:railssidekiq'
|
152
|
+
sh 'rvm $RAILS3_SIDEKIQ_VERSIONS --verbose do appraisal rails32-postgres-sidekiq rake test:railssidekiq'
|
153
|
+
sh 'rvm $RAILS4_SIDEKIQ_VERSIONS --verbose do appraisal rails4-postgres-sidekiq rake test:railssidekiq'
|
154
|
+
sh 'rvm $RAILS4_SIDEKIQ_VERSIONS --verbose do appraisal rails4-postgres-sidekiq rake test:railsactivejob'
|
155
155
|
sh 'rvm $RAILS5_VERSIONS --verbose do appraisal rails5-mysql2 rake test:rails'
|
156
156
|
sh 'rvm $RAILS5_VERSIONS --verbose do appraisal rails5-postgres rake test:rails'
|
157
157
|
sh 'rvm $RAILS5_VERSIONS --verbose do appraisal rails5-postgres-redis rake test:railsredis'
|
data/circle.yml
CHANGED
@@ -2,15 +2,17 @@ machine:
|
|
2
2
|
services:
|
3
3
|
- docker
|
4
4
|
environment:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
MRI_VERSIONS: 2.4.0,2.3.3,2.2.6
|
5
|
+
LAST_STABLE: 2.4.1
|
6
|
+
EARLY_STABLE: 2.2.7
|
7
|
+
MRI_VERSIONS: 2.4.1,2.3.4,2.2.7
|
9
8
|
MRI_OLD_VERSIONS: 2.1.10,2.0.0,1.9.3
|
10
9
|
SIDEKIQ_OLD_VERSIONS: 2.1.10,2.0.0
|
11
|
-
RAILS3_VERSIONS: 2.3.
|
12
|
-
RAILS4_VERSIONS: 2.3.
|
13
|
-
RAILS5_VERSIONS: 2.3.
|
10
|
+
RAILS3_VERSIONS: 2.3.4,2.2.7,2.1.10,2.0.0,1.9.3
|
11
|
+
RAILS4_VERSIONS: 2.3.4,2.2.7,2.1.10
|
12
|
+
RAILS5_VERSIONS: 2.3.4,2.2.7
|
13
|
+
RAILS3_SIDEKIQ_VERSIONS: 2.1.10,2.0.0
|
14
|
+
RAILS4_SIDEKIQ_VERSIONS: 2.3.4,2.2.7
|
15
|
+
JRUBY_VERSIONS: jruby-9.1.5.0
|
14
16
|
AGENT_BUILD_PATH: "/home/ubuntu/agent"
|
15
17
|
TEST_DATADOG_INTEGRATION: 1
|
16
18
|
|
@@ -30,11 +32,12 @@ dependencies:
|
|
30
32
|
- bundle install
|
31
33
|
# configure Ruby interpreters
|
32
34
|
- rvm get head
|
33
|
-
- rvm install $MRI_VERSIONS
|
35
|
+
- rvm install $MRI_VERSIONS,$MRI_OLD_VERSIONS,$JRUBY_VERSIONS
|
34
36
|
override:
|
35
|
-
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS --verbose do gem update --system=2.6.11
|
36
|
-
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS --verbose do gem install bundler
|
37
|
-
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS --verbose do bundle install
|
37
|
+
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS,$JRUBY_VERSIONS --verbose do gem update --system=2.6.11
|
38
|
+
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS,$JRUBY_VERSIONS --verbose do gem install bundler
|
39
|
+
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS,$JRUBY_VERSIONS --verbose do bundle install
|
40
|
+
# [FIXME] appraisal does not work with jruby (problem with native ext, eg sqlite3)
|
38
41
|
- rvm $MRI_VERSIONS,$MRI_OLD_VERSIONS --verbose do appraisal install
|
39
42
|
|
40
43
|
test:
|
data/ddtrace.gemspec
CHANGED
data/docs/GettingStarted.md
CHANGED
@@ -160,6 +160,18 @@ To start using the middleware in your generic Rack application, add it to your `
|
|
160
160
|
|
161
161
|
run app
|
162
162
|
|
163
|
+
Experimental distributed tracing support is available for this library.
|
164
|
+
You need to set the ``:distributed_tracing_enabled`` option to true, for example:
|
165
|
+
|
166
|
+
use Datadog::Contrib::Rack::TraceMiddleware, distributed_tracing_enabled: true
|
167
|
+
|
168
|
+
app = proc do |env|
|
169
|
+
# trace and read 'x-datadog-trace-id' and 'x-datadog-parent-id'
|
170
|
+
[ 200, {'Content-Type' => 'text/plain'}, "OK" ]
|
171
|
+
end
|
172
|
+
|
173
|
+
See [distributed tracing](#Distributed_Tracing) for details.
|
174
|
+
|
163
175
|
#### Configure the tracer
|
164
176
|
|
165
177
|
To modify the default middleware configuration, you can use middleware options as follows:
|
@@ -256,6 +268,31 @@ Net::HTTP module.
|
|
256
268
|
|
257
269
|
content = Net::HTTP.get(URI('http://127.0.0.1/index.html'))
|
258
270
|
|
271
|
+
Experimental distributed tracing support is available for this library.
|
272
|
+
By default, this is disabled. You need to enable it, either on a per-connection basis,
|
273
|
+
by setting the ``:distributed_tracing_enabled`` config entry to ``true`` using
|
274
|
+
the ``Pin`` object attached to the client. Example:
|
275
|
+
|
276
|
+
require 'net/http'
|
277
|
+
require 'ddtrace'
|
278
|
+
|
279
|
+
Datadog::Monkey.patch_module(:http) # explicitly patch it
|
280
|
+
|
281
|
+
client = Net::HTTP.new(host, port)
|
282
|
+
Datadog::Pin.get_from(client).config = { distributed_tracing_enabled: true }
|
283
|
+
response = client.get('foo') # trace and send 'x-datadog-trace-id' and 'x-datadog-parent-id'
|
284
|
+
|
285
|
+
Or, by enabling distributed tracing for all HTTP calls:
|
286
|
+
|
287
|
+
require 'net/http'
|
288
|
+
require 'ddtrace'
|
289
|
+
|
290
|
+
Datadog::Monkey.patch_module(:http) # explicitly patch it
|
291
|
+
|
292
|
+
Datadog::Contrib::HTTP.distributed_tracing_enabled = true
|
293
|
+
|
294
|
+
See [distributed tracing](#Distributed_Tracing) for details.
|
295
|
+
|
259
296
|
### Redis
|
260
297
|
|
261
298
|
The Redis integration will trace simple calls as well as pipelines.
|
@@ -350,12 +387,17 @@ to trace requests to the home page:
|
|
350
387
|
|
351
388
|
# add some attributes and metrics
|
352
389
|
span.set_tag('http.method', request.request_method)
|
353
|
-
span.
|
390
|
+
span.set_tag('posts.count', @posts.length)
|
354
391
|
|
355
392
|
# trace the template rendering
|
356
393
|
tracer.trace('template.render') do
|
357
394
|
erb :index
|
358
395
|
end
|
396
|
+
|
397
|
+
# trace using start_span (fine-grain control, requires explicit call to finish)
|
398
|
+
child = tracer.start_span('child', child_of: span)
|
399
|
+
# do something
|
400
|
+
child.finish
|
359
401
|
end
|
360
402
|
end
|
361
403
|
|
@@ -440,7 +482,7 @@ You can use this object to instrument your own code:
|
|
440
482
|
class MyWebSite
|
441
483
|
def initialize
|
442
484
|
pin = Datadog::Pin.new('my-web-site', app_type: Datadog::Ext::AppTypes::WEB)
|
443
|
-
|
485
|
+
pin.onto(self)
|
444
486
|
end
|
445
487
|
|
446
488
|
def serve(something)
|
@@ -479,6 +521,20 @@ for the first time:
|
|
479
521
|
Remember that the debug mode may affect your application performance and so it must not be used
|
480
522
|
in a production environment.
|
481
523
|
|
524
|
+
### Using a custom logger
|
525
|
+
|
526
|
+
By default, all logs are processed by the default Ruby logger.
|
527
|
+
Typically, when using Rails, you should see the messages in your application log file.
|
528
|
+
Datadog client log messages are marked with ``[ddtrace]`` so you should be able
|
529
|
+
to isolate them from other messages.
|
530
|
+
|
531
|
+
Additionally, it is possible to override the default logger and replace it by a
|
532
|
+
custom one. This is done using the ``log`` attribute of the tracer.
|
533
|
+
|
534
|
+
f = File.new("my-custom.log", "w+") # Log messages should go there
|
535
|
+
Datadog::Tracer.log = Logger.new(f) # Overriding the default tracer
|
536
|
+
Datadog::Tracer.log.info { "this is typically called by tracing code" }
|
537
|
+
|
482
538
|
### Environment and tags
|
483
539
|
|
484
540
|
By default, the trace agent (not this library, but the program running in
|
@@ -537,8 +593,8 @@ On the client:
|
|
537
593
|
|
538
594
|
Datadog.tracer.trace('web.call') do |span|
|
539
595
|
req = Net::HTTP::Get.new(uri)
|
540
|
-
req['x-
|
541
|
-
req['x-
|
596
|
+
req['x-datadog-trace-id'] = span.trace_id.to_s
|
597
|
+
req['x-datadog-parent-id'] = span.span_id.to_s
|
542
598
|
|
543
599
|
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
544
600
|
http.request(req)
|
@@ -556,8 +612,8 @@ On the server:
|
|
556
612
|
# require 'ddtrace/contrib/sinatra/tracer'
|
557
613
|
|
558
614
|
get '/' do
|
559
|
-
parent_trace_id = request.env['
|
560
|
-
parent_span_id = request.env['
|
615
|
+
parent_trace_id = request.env['HTTP_X_DATADOG_TRACE_ID']
|
616
|
+
parent_span_id = request.env['HTTP_X_DATADOG_PARENT_ID']
|
561
617
|
|
562
618
|
Datadog.tracer.trace('web.work') do |span|
|
563
619
|
if parent_trace_id && parent_span_id
|
@@ -569,6 +625,40 @@ On the server:
|
|
569
625
|
end
|
570
626
|
end
|
571
627
|
|
628
|
+
[Rack](#Rack) and [Net/HTTP](#Net_HTTP) have experimental support for this, they
|
629
|
+
can send and receive these headers automatically and tie spans together automatically,
|
630
|
+
provided you pass a ``:distributed_tracing_enabled`` option set to ``true``.
|
631
|
+
|
632
|
+
This is disabled by default.
|
633
|
+
|
634
|
+
### Troubleshooting
|
635
|
+
|
636
|
+
#### Logs
|
637
|
+
|
638
|
+
Your application log should contain informations and report problems
|
639
|
+
such as agent not being up and running. All logs generated by this
|
640
|
+
library should contain ``[ddtrace]``. Also see [how to use a custom logger](#Using_a_custom_logger)
|
641
|
+
to redirect these messages elsewhere.
|
642
|
+
|
643
|
+
The [Datadog Trace Agent](https://github.com/DataDog/datadog-trace-agent)
|
644
|
+
should by default be listening for traces on port 8126.
|
645
|
+
|
646
|
+
#### Hello World
|
647
|
+
|
648
|
+
Sometimes, setting up a complete application is complex, so in doubt,
|
649
|
+
try the small program below, which should be able to report traces
|
650
|
+
for a ``tracegen`` service:
|
651
|
+
|
652
|
+
require 'ddtrace'
|
653
|
+
|
654
|
+
loop do
|
655
|
+
Datadog.tracer.trace('hello-world') do |span|
|
656
|
+
span.service = 'tracegen'
|
657
|
+
span.resource = 'ruby'
|
658
|
+
sleep 1
|
659
|
+
end
|
660
|
+
end
|
661
|
+
|
572
662
|
### Supported Versions
|
573
663
|
|
574
664
|
#### Ruby interpreters
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "test-unit"
|
6
|
+
gem "rails", "3.0.20"
|
7
|
+
gem "pg", "0.15.1", platform: :ruby
|
8
|
+
gem "activerecord-jdbcpostgresql-adapter", platform: :jruby
|
9
|
+
gem "sidekiq", "4.0.0"
|
10
|
+
|
11
|
+
gemspec path: "../"
|
File without changes
|
File without changes
|
File without changes
|
data/lib/ddtrace/buffer.rb
CHANGED
@@ -1,31 +1,6 @@
|
|
1
1
|
require 'thread'
|
2
2
|
|
3
3
|
module Datadog
|
4
|
-
# Buffer used to store active spans
|
5
|
-
class SpanBuffer
|
6
|
-
# ensure that a new SpanBuffer clears the thread spans
|
7
|
-
def initialize
|
8
|
-
Thread.current[:datadog_span] = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
# Set the current active span.
|
12
|
-
def set(span)
|
13
|
-
Thread.current[:datadog_span] = span
|
14
|
-
end
|
15
|
-
|
16
|
-
# Return the current active span or nil.
|
17
|
-
def get
|
18
|
-
Thread.current[:datadog_span]
|
19
|
-
end
|
20
|
-
|
21
|
-
# Pop the current active span.
|
22
|
-
def pop
|
23
|
-
span = get()
|
24
|
-
set(nil)
|
25
|
-
span
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
4
|
# Trace buffer that stores application traces. The buffer has a maximum size and when
|
30
5
|
# the buffer is full, a random trace is discarded. This class is thread-safe and is used
|
31
6
|
# automatically by the ``Tracer`` instance when a ``Span`` is finished.
|
@@ -65,7 +40,7 @@ module Datadog
|
|
65
40
|
end
|
66
41
|
end
|
67
42
|
|
68
|
-
# Stored traces are returned and the local buffer is reset
|
43
|
+
# Stored traces are returned and the local buffer is reset.
|
69
44
|
def pop
|
70
45
|
@mutex.synchronize do
|
71
46
|
traces = @traces
|