ddtrace 0.3.1 → 0.4.0
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 +52 -48
- data/README.md +6 -6
- data/Rakefile +29 -26
- data/circle.yml +28 -25
- data/ddtrace.gemspec +3 -4
- data/docs/GettingStarted +94 -49
- data/gemfiles/rails5_mysql2.gemfile +1 -1
- data/gemfiles/rails5_postgres.gemfile +1 -1
- data/gemfiles/rails5_postgres_redis.gemfile +1 -1
- data/lib/ddtrace.rb +15 -13
- data/lib/ddtrace/contrib/elasticsearch/core.rb +4 -2
- data/lib/ddtrace/contrib/http/patcher.rb +131 -0
- data/lib/ddtrace/contrib/rails/action_view.rb +3 -0
- data/lib/ddtrace/contrib/rails/active_record.rb +3 -0
- data/lib/ddtrace/contrib/rails/active_support.rb +3 -0
- data/lib/ddtrace/contrib/rails/core_extensions.rb +17 -0
- data/lib/ddtrace/contrib/rails/framework.rb +17 -16
- data/lib/ddtrace/contrib/redis/patcher.rb +83 -3
- data/lib/ddtrace/contrib/sinatra/tracer.rb +181 -0
- data/lib/ddtrace/monkey.rb +15 -1
- data/lib/ddtrace/pin.rb +2 -2
- data/lib/ddtrace/span.rb +2 -2
- data/lib/ddtrace/transport.rb +1 -0
- data/lib/ddtrace/version.rb +2 -2
- metadata +11 -24
- data/lib/ddtrace/contrib/redis/core.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: 82af04eeea1caa84867aaa757ad13417edc2023e
|
4
|
+
data.tar.gz: 2f08f3addafedcdb596eaa5745085373172b3c53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a4f8c8a1c8e105adf40b1d47cc7504ca8b247eb7763f560ed6a86718e5213a1cd44c07f82ff2a73625d586490e5e81df49d6d1f143cc27681ad7b541fa8028
|
7
|
+
data.tar.gz: e9bb6304e1e375050d9203601881b50b9422aa53c64ba8938c5b75d052946e12ae1384be6dd5364c94df01839fffc4e2986f37d5880d52ca720b742add8dd0ad
|
data/Appraisals
CHANGED
@@ -1,65 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
appraise "rails4-postgres" do
|
9
|
-
gem "rails", "4.2.7.1"
|
10
|
-
gem "pg", platform: :ruby
|
11
|
-
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
12
|
-
end
|
13
|
-
|
14
|
-
appraise "rails3-mysql2" do
|
15
|
-
gem "test-unit"
|
16
|
-
gem "rails", "3.2.22.5"
|
17
|
-
gem "mysql2", "0.3.21", platform: :ruby
|
18
|
-
gem "activerecord-mysql-adapter", platform: :ruby
|
19
|
-
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
20
|
-
end
|
21
|
-
|
22
|
-
appraise "rails4-mysql2" do
|
23
|
-
gem "rails", "4.2.7.1"
|
24
|
-
gem "mysql2", platform: :ruby
|
25
|
-
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
26
|
-
end
|
27
|
-
|
28
|
-
appraise "rails3-postgres-redis" do
|
29
|
-
gem "test-unit"
|
30
|
-
gem "rails", "3.2.22.5"
|
31
|
-
gem "pg", platform: :ruby
|
32
|
-
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
33
|
-
gem "redis-rails"
|
34
|
-
end
|
35
|
-
|
36
|
-
appraise "rails4-postgres-redis" do
|
37
|
-
gem "rails", "4.2.7.1"
|
38
|
-
gem "pg", platform: :ruby
|
39
|
-
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
40
|
-
gem "redis-rails"
|
41
|
-
end
|
1
|
+
if RUBY_VERSION < "2.4.0"
|
2
|
+
appraise "rails3-postgres" do
|
3
|
+
gem "test-unit"
|
4
|
+
gem "rails", "3.2.22.5"
|
5
|
+
gem "pg", platform: :ruby
|
6
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
7
|
+
end
|
42
8
|
|
43
|
-
|
44
|
-
|
45
|
-
gem "rails", "5.0.0.1"
|
9
|
+
appraise "rails4-postgres" do
|
10
|
+
gem "rails", "4.2.7.1"
|
46
11
|
gem "pg", platform: :ruby
|
12
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise "rails3-mysql2" do
|
16
|
+
gem "test-unit"
|
17
|
+
gem "rails", "3.2.22.5"
|
18
|
+
gem "mysql2", "0.3.21", platform: :ruby
|
19
|
+
gem "activerecord-mysql-adapter", platform: :ruby
|
20
|
+
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
47
21
|
end
|
48
22
|
|
49
|
-
appraise "
|
50
|
-
gem "rails", "
|
23
|
+
appraise "rails4-mysql2" do
|
24
|
+
gem "rails", "4.2.7.1"
|
51
25
|
gem "mysql2", platform: :ruby
|
26
|
+
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
52
27
|
end
|
53
28
|
|
54
|
-
appraise "
|
55
|
-
gem "
|
29
|
+
appraise "rails3-postgres-redis" do
|
30
|
+
gem "test-unit"
|
31
|
+
gem "rails", "3.2.22.5"
|
56
32
|
gem "pg", platform: :ruby
|
33
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
57
34
|
gem "redis-rails"
|
58
35
|
end
|
36
|
+
|
37
|
+
appraise "rails4-postgres-redis" do
|
38
|
+
gem "rails", "4.2.7.1"
|
39
|
+
gem "pg", platform: :ruby
|
40
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
41
|
+
gem "redis-rails"
|
42
|
+
end
|
43
|
+
|
44
|
+
if RUBY_VERSION >= "2.2.2" && RUBY_PLATFORM != "java"
|
45
|
+
appraise "rails5-postgres" do
|
46
|
+
gem "rails", "5.0.1"
|
47
|
+
gem "pg", platform: :ruby
|
48
|
+
end
|
49
|
+
|
50
|
+
appraise "rails5-mysql2" do
|
51
|
+
gem "rails", "5.0.1"
|
52
|
+
gem "mysql2", platform: :ruby
|
53
|
+
end
|
54
|
+
|
55
|
+
appraise "rails5-postgres-redis" do
|
56
|
+
gem "rails", "5.0.1"
|
57
|
+
gem "pg", platform: :ruby
|
58
|
+
gem "redis-rails"
|
59
|
+
end
|
60
|
+
end
|
59
61
|
end
|
60
62
|
|
61
63
|
appraise "contrib" do
|
62
64
|
gem "elasticsearch-transport"
|
63
65
|
gem "redis"
|
64
66
|
gem "hiredis"
|
67
|
+
gem "rack-test"
|
68
|
+
gem "sinatra"
|
65
69
|
end
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ to trace requests to the home page:
|
|
58
58
|
### Monkey patching
|
59
59
|
|
60
60
|
By default, our monkey-patching is not active, you need to
|
61
|
-
explicitly activate it by calling `Datadog::Monkey.patch_all`
|
61
|
+
explicitly activate it by calling `Datadog::Monkey.patch_all`
|
62
62
|
or `Datadog::Monkey.patch_module`
|
63
63
|
|
64
64
|
This ultimately allows you to enable or disable tracing on a per-library basis.
|
@@ -87,12 +87,12 @@ Configure your environment through:
|
|
87
87
|
$ bundle install
|
88
88
|
$ appraisal install
|
89
89
|
|
90
|
-
You can launch
|
90
|
+
You can launch tests using the following rake command:
|
91
91
|
|
92
|
-
$ rake test # tracer tests
|
93
|
-
$ appraisal rails<version>-<database>rake rails # tests Rails matrix
|
94
|
-
$ appraisal contrib rake
|
95
|
-
$ appraisal contrib rake monkey # tests monkey patching
|
92
|
+
$ rake test:main # tracer tests
|
93
|
+
$ appraisal rails<version>-<database>rake test:rails # tests Rails matrix
|
94
|
+
$ appraisal contrib rake test:redis # tests Redis integration
|
95
|
+
$ appraisal contrib rake test:monkey # tests monkey patching
|
96
96
|
|
97
97
|
Available appraisals are:
|
98
98
|
|
data/Rakefile
CHANGED
@@ -4,39 +4,42 @@ require 'rake/testtask'
|
|
4
4
|
require 'rdoc/task'
|
5
5
|
require 'appraisal'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
path.include?('
|
7
|
+
namespace :test do
|
8
|
+
task all: [:main, :rails, :railsredis, :elasticsearch, :http, :redis, :sinatra, :monkey]
|
9
|
+
|
10
|
+
Rake::TestTask.new(:main) do |t|
|
11
|
+
t.libs << %w(test lib)
|
12
|
+
t.test_files = FileList['test/**/*_test.rb'].reject do |path|
|
13
|
+
path.include?('contrib') ||
|
14
|
+
path.include?('benchmark') ||
|
15
|
+
path.include?('redis') ||
|
16
|
+
path.include?('monkey_test.rb')
|
17
|
+
end
|
14
18
|
end
|
15
|
-
end
|
16
19
|
|
17
|
-
Rake::TestTask.new(:rails) do |t|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
Rake::TestTask.new(:rails) do |t|
|
21
|
+
t.libs << %w(test lib)
|
22
|
+
t.test_files = FileList['test/contrib/rails/**/*_test.rb'].reject do |path|
|
23
|
+
path.include?('redis')
|
24
|
+
end
|
21
25
|
end
|
22
|
-
end
|
23
26
|
|
24
|
-
Rake::TestTask.new(:railsredis) do |t|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
27
|
+
Rake::TestTask.new(:railsredis) do |t|
|
28
|
+
t.libs << %w(test lib)
|
29
|
+
t.test_files = FileList['test/contrib/rails/**/*redis*_test.rb']
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
[:elasticsearch, :http, :redis, :sinatra].each do |contrib|
|
33
|
+
Rake::TestTask.new(contrib) do |t|
|
34
|
+
t.libs << %w(test lib)
|
35
|
+
t.test_files = FileList["test/contrib/#{contrib}/*_test.rb"]
|
36
|
+
end
|
34
37
|
end
|
35
|
-
end
|
36
38
|
|
37
|
-
Rake::TestTask.new(:monkey) do |t|
|
38
|
-
|
39
|
-
|
39
|
+
Rake::TestTask.new(:monkey) do |t|
|
40
|
+
t.libs << %w(test lib)
|
41
|
+
t.test_files = FileList['test/monkey_test.rb']
|
42
|
+
end
|
40
43
|
end
|
41
44
|
|
42
45
|
Rake::TestTask.new(:benchmark) do |t|
|
data/circle.yml
CHANGED
@@ -2,10 +2,11 @@ machine:
|
|
2
2
|
services:
|
3
3
|
- docker
|
4
4
|
environment:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
LAST_STABLE: 2.4.0
|
6
|
+
EARLY_STABLE: 2.1.10
|
7
|
+
MRI_VERSIONS: 2.4.0,2.3.3,2.2.6,2.1.10
|
8
|
+
RAILS_VERSIONS: 2.3.3,2.2.6,2.1.10
|
9
|
+
RAILS5_VERSIONS: 2.3.3,2.2.6
|
9
10
|
AGENT_BUILD_PATH: "/home/ubuntu/agent"
|
10
11
|
TEST_DATADOG_INTEGRATION: 1
|
11
12
|
|
@@ -23,34 +24,38 @@ dependencies:
|
|
23
24
|
- bundle install
|
24
25
|
- rvm get head
|
25
26
|
- rvm install $MRI_VERSIONS
|
26
|
-
- rvm install $JRUBY_VERSIONS
|
27
27
|
# prepare and run the trace agent
|
28
28
|
# TODO[manu]: remove this part when everything will be open source
|
29
29
|
- git clone git@github.com:DataDog/datadog-trace-agent.git $AGENT_BUILD_PATH
|
30
30
|
- cd $AGENT_BUILD_PATH && docker build -t datadog/trace-agent .
|
31
31
|
- docker run -d -e DD_API_KEY=invalid_key_but_this_is_fine -e DD_BIND_HOST=0.0.0.0 -p 127.0.0.1:7777:7777 datadog/trace-agent
|
32
32
|
override:
|
33
|
-
- rvm $MRI_VERSIONS
|
34
|
-
- rvm $MRI_VERSIONS
|
35
|
-
- rvm $MRI_VERSIONS
|
33
|
+
- rvm $MRI_VERSIONS --verbose do gem update --system
|
34
|
+
- rvm $MRI_VERSIONS --verbose do gem install bundler
|
35
|
+
- rvm $MRI_VERSIONS --verbose do bundle install
|
36
|
+
- rvm $MRI_VERSIONS --verbose do appraisal install
|
36
37
|
|
37
38
|
test:
|
38
39
|
override:
|
39
|
-
- rvm
|
40
|
-
|
41
|
-
|
42
|
-
- rvm $MRI_VERSIONS
|
43
|
-
- rvm $MRI_VERSIONS
|
44
|
-
- rvm $MRI_VERSIONS
|
45
|
-
- rvm $
|
46
|
-
- rvm $
|
47
|
-
- rvm $MRI_VERSIONS
|
48
|
-
- rvm $
|
49
|
-
- rvm $
|
50
|
-
- rvm $
|
51
|
-
- rvm $
|
52
|
-
- rvm
|
53
|
-
- rvm
|
40
|
+
- rvm $EARLY_STABLE --verbose do rake rubocop
|
41
|
+
# Disabled $JRUBY_VERSIONS tests because of a Java incompatibility
|
42
|
+
# TODO: integration tests should run with the master branch of the agent
|
43
|
+
- rvm $MRI_VERSIONS --verbose do rake test:main
|
44
|
+
- rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:monkey
|
45
|
+
- rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:elasticsearch
|
46
|
+
- rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:http
|
47
|
+
- rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:redis
|
48
|
+
- rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:sinatra
|
49
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails3-postgres rake test:rails
|
50
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails3-mysql2 rake test:rails
|
51
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails4-postgres rake test:rails
|
52
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails4-mysql2 rake test:rails
|
53
|
+
- rvm $RAILS5_VERSIONS --verbose do appraisal rails5-postgres rake test:rails
|
54
|
+
- rvm $RAILS5_VERSIONS --verbose do appraisal rails5-mysql2 rake test:rails
|
55
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails3-postgres-redis rake test:railsredis
|
56
|
+
- rvm $RAILS_VERSIONS --verbose do appraisal rails4-postgres-redis rake test:railsredis
|
57
|
+
- rvm $RAILS5_VERSIONS --verbose do appraisal rails5-postgres-redis rake test:railsredis
|
58
|
+
- rvm $LAST_STABLE --verbose do rake benchmark
|
54
59
|
|
55
60
|
deployment:
|
56
61
|
develop:
|
@@ -64,5 +69,3 @@ deployment:
|
|
64
69
|
tag: /v[0-9]+(\.[0-9]+)*/
|
65
70
|
commands:
|
66
71
|
- S3_DIR=trace rake release:docs
|
67
|
-
- S3_DIR=trace VERSION_SUFFIX= rake release:gem
|
68
|
-
- cp -r ./rubygems/* $CIRCLE_ARTIFACTS
|
data/ddtrace.gemspec
CHANGED
@@ -33,9 +33,8 @@ EOS
|
|
33
33
|
|
34
34
|
spec.add_dependency "msgpack"
|
35
35
|
|
36
|
-
spec.add_development_dependency "
|
37
|
-
spec.add_development_dependency "
|
38
|
-
spec.add_development_dependency "
|
39
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
37
|
+
spec.add_development_dependency "rubocop", "~> 0.47"
|
38
|
+
spec.add_development_dependency "minitest", "~> 5.10"
|
40
39
|
spec.add_development_dependency "appraisal", "~> 2.1"
|
41
40
|
end
|
data/docs/GettingStarted
CHANGED
@@ -7,19 +7,21 @@ databases and microservices so that developers have great visiblity into bottlen
|
|
7
7
|
|
8
8
|
Install the tracer with the +gem+ command, but point to Datadog's gems repository:
|
9
9
|
|
10
|
-
$ gem install ddtrace
|
10
|
+
$ gem install ddtrace
|
11
11
|
|
12
12
|
On the other hand, if you're using +Bundler+, just update your +Gemfile+ as follows:
|
13
13
|
|
14
14
|
source 'https://rubygems.org'
|
15
15
|
|
16
16
|
# tracing gem
|
17
|
-
gem 'ddtrace'
|
17
|
+
gem 'ddtrace'
|
18
|
+
|
19
|
+
If you're using the Ruby on Rails framework, you need to configure the auto-instrumentation with an {extra step}[#label-Auto+Instrumentation].
|
18
20
|
|
19
21
|
== Quickstart (Auto Instrumentation)
|
20
22
|
|
21
23
|
If you are on a {supported integration}[#label-Integrations], you should be able to generate traffic and view
|
22
|
-
metrics in your
|
24
|
+
metrics listed in your service list.
|
23
25
|
|
24
26
|
== Quickstart (Manual Instrumentation)
|
25
27
|
|
@@ -74,33 +76,23 @@ The \Rails integration will trace requests, database calls, templates rendering
|
|
74
76
|
operations. The integration makes use of the Active Support Instrumentation, listening to the Notification API
|
75
77
|
so that any operation instrumented by the API is traced.
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
* \Rails 3.2 (MRI interpreter, JRuby is experimental)
|
80
|
-
* \Rails 4.2 (MRI interpreter, JRuby is experimental)
|
81
|
-
* \Rails 5.0 (MRI interpreter)
|
82
|
-
|
83
|
-
The currently supported web server are:
|
84
|
-
* Puma 2.16+ and 3.6+
|
85
|
-
* Unicorn 4.8+ and 5.1+
|
86
|
-
* Passenger 5.0 (experimental)
|
87
|
-
|
88
|
-
==== Installation
|
79
|
+
==== Auto Instrumentation
|
89
80
|
|
90
81
|
Add the tracer gem to your +Gemfile+:
|
91
82
|
|
92
|
-
gem 'ddtrace'
|
83
|
+
gem 'ddtrace'
|
93
84
|
|
94
|
-
|
85
|
+
To enable the Rails auto-instrumentation, you must create an initializer file in your +config/+ folder:
|
95
86
|
|
96
87
|
# config/initializers/datadog-tracer.rb
|
97
88
|
|
98
89
|
Rails.configuration.datadog_trace = {
|
99
|
-
|
90
|
+
auto_instrument: true,
|
91
|
+
auto_instrument_redis: true,
|
92
|
+
default_service: 'my-rails-app'
|
100
93
|
}
|
101
94
|
|
102
|
-
If you're using \Rails 3 or higher,
|
103
|
-
is required. Your application will be listed as +my-rails-app+ in your {dashboard}[https://app.datadoghq.com/trace].
|
95
|
+
If you're using \Rails 3 or higher, your application will be listed as +my-rails-app+ in your service list.
|
104
96
|
|
105
97
|
==== Custom Instrumentation
|
106
98
|
|
@@ -133,8 +125,8 @@ of the Datadog tracer, you can override the following defaults:
|
|
133
125
|
|
134
126
|
Rails.configuration.datadog_trace = {
|
135
127
|
enabled: true,
|
136
|
-
auto_instrument:
|
137
|
-
auto_instrument_redis:
|
128
|
+
auto_instrument: false,
|
129
|
+
auto_instrument_redis: false,
|
138
130
|
default_service: 'rails-app',
|
139
131
|
default_cache_service: 'rails-cache',
|
140
132
|
template_base_path: 'views/',
|
@@ -146,13 +138,12 @@ of the Datadog tracer, you can override the following defaults:
|
|
146
138
|
|
147
139
|
The available settings are:
|
148
140
|
|
149
|
-
* +enabled+: defines if the +tracer+ is enabled or not. If set to +false
|
150
|
-
but no spans are sent to the local trace agent.
|
151
|
-
* +auto_instrument+: if set to
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
still be instrumented but you will not have the detail of low-level \Redis calls.
|
141
|
+
* +enabled+: defines if the +tracer+ is enabled or not. If set to +false+ the code could be still instrumented
|
142
|
+
because of other settings, but no spans are sent to the local trace agent.
|
143
|
+
* +auto_instrument+: if set to +true+ the code will be automatically instrumented. You may change this value
|
144
|
+
with a condition, to enable the auto-instrumentation only for particular environments (production, staging, etc...).
|
145
|
+
* +auto_instrument_redis+: if set to +true+ \Redis calls will be traced as such. Calls to Redis cache may be
|
146
|
+
still instrumented but you will not have the detail of low-level \Redis calls.
|
156
147
|
* +default_service+: set the service name used when tracing application requests. Defaults to +rails-app+
|
157
148
|
* +default_database_service+: set the database service name used when tracing database activity. Defaults to the
|
158
149
|
current adapter name, so if you're using PostgreSQL it will be +postgres+.
|
@@ -165,27 +156,55 @@ The available settings are:
|
|
165
156
|
* +trace_agent_hostname+: set the hostname of the trace agent.
|
166
157
|
* +trace_agent_port+: set the port the trace agent is listening on.
|
167
158
|
|
168
|
-
===
|
159
|
+
=== Sinatra
|
169
160
|
|
170
|
-
The
|
161
|
+
The Sinatra integration traces requests and template rendering. The
|
162
|
+
integration is based on the +Datadog::Contrib::Sinatra::Tracer+ extension.
|
171
163
|
|
172
|
-
|
164
|
+
==== Setup
|
165
|
+
|
166
|
+
Add the tracer gem to your +Gemfile+:
|
167
|
+
|
168
|
+
gem 'ddtrace'
|
169
|
+
|
170
|
+
Make sure you import +ddtrace+ and +ddtrace/contrib/sinatra/tracer+ after
|
171
|
+
either +sinatra+ or +sinatra/base+:
|
172
|
+
|
173
|
+
require 'sinatra'
|
173
174
|
require 'ddtrace'
|
175
|
+
require 'ddtrace/contrib/sinatra/tracer'
|
174
176
|
|
175
|
-
|
177
|
+
The tracing extension will be automatically activated.
|
176
178
|
|
177
|
-
|
178
|
-
|
179
|
-
|
179
|
+
==== Configuration
|
180
|
+
|
181
|
+
To modify the default configuration, use the
|
182
|
+
+settings.datadog_tracer.configure+ method. For example, to change the default
|
183
|
+
service name and activate the debug mode:
|
180
184
|
|
181
|
-
|
182
|
-
|
183
|
-
|
185
|
+
configure do
|
186
|
+
settings.datadog_tracer.configure default_service: 'my-app', debug: true
|
187
|
+
end
|
188
|
+
|
189
|
+
The available settings are:
|
190
|
+
|
191
|
+
* +enabled+: define if the +tracer+ is enabled or not. If set to +false+, the code is still instrumented
|
192
|
+
but no spans are sent to the local trace agent.
|
193
|
+
* +default_service+: set the service name used when tracing application requests. Defaults to +sinatra+
|
194
|
+
* +tracer+: set the tracer to use. Usually you don't need to change that value
|
195
|
+
unless you're already using a different initialized tracer somewhere else
|
196
|
+
* +debug+: set to +true+ to enable debug logging.
|
197
|
+
* +trace_agent_hostname+: set the hostname of the trace agent.
|
198
|
+
* +trace_agent_port+: set the port the trace agent is listening on.
|
199
|
+
|
200
|
+
=== Redis
|
201
|
+
|
202
|
+
The \Redis integration will trace simple calls as well as pipelines.
|
184
203
|
|
185
204
|
require 'redis'
|
186
205
|
require 'ddtrace'
|
187
206
|
|
188
|
-
Datadog::Monkey.
|
207
|
+
Datadog::Monkey.patch_module(:redis) # you need to explicitly patch it
|
189
208
|
|
190
209
|
# now do your Redis stuff, eg:
|
191
210
|
redis = Redis.new
|
@@ -205,18 +224,26 @@ in the \Client object:
|
|
205
224
|
client = Elasticsearch::Client.new url: 'http://127.0.0.1:9200'
|
206
225
|
response = client.perform_request 'GET', '_cluster/health'
|
207
226
|
|
208
|
-
|
209
|
-
|
210
|
-
|
227
|
+
Note that if you enable both \Elasticsearch and \Net/HTTP integrations then
|
228
|
+
for each call, two spans are created, one for \Elasctisearch and one for \Net/HTTP.
|
229
|
+
This typically happens if you call \patch_all to enable all integrations by default.
|
211
230
|
|
212
|
-
|
231
|
+
=== Net/HTTP
|
232
|
+
|
233
|
+
The \Net/HTTP integration will trace any HTTP call using the standard lib
|
234
|
+
\Net::HTTP module.
|
235
|
+
|
236
|
+
require 'net/http'
|
213
237
|
require 'ddtrace'
|
214
238
|
|
215
|
-
Datadog::Monkey.
|
239
|
+
Datadog::Monkey.patch_module(:http) # you need to explicitly patch it
|
216
240
|
|
217
|
-
|
218
|
-
|
219
|
-
|
241
|
+
Net::HTTP.start('127.0.0.1', 8080) do |http|
|
242
|
+
request = Net::HTTP::Get.new '/index'
|
243
|
+
response = http.request request
|
244
|
+
end
|
245
|
+
|
246
|
+
content = Net::HTTP.get(URI('http://127.0.0.1/index.html'))
|
220
247
|
|
221
248
|
== Monkey Patching
|
222
249
|
|
@@ -230,7 +257,7 @@ The available methods are:
|
|
230
257
|
the key is the name of the module and the value \true or \false. If it is \true,
|
231
258
|
a call to \patch_all will enable the module, if it is \false, it will do nothing.
|
232
259
|
* +patch_all+: patches all modules which are supported. Make sure all the necessary
|
233
|
-
calls to \require have been done before this is
|
260
|
+
calls to \require have been done before this is called, else monkey patching will
|
234
261
|
not work.
|
235
262
|
* +patch_module+: patches a single module, regardless of its settings in the
|
236
263
|
\autopatch_modules list.
|
@@ -347,6 +374,24 @@ The \Datadog Trace Client has been tested with the following Ruby versions:
|
|
347
374
|
* Ruby MRI 2.1
|
348
375
|
* Ruby MRI 2.2
|
349
376
|
* Ruby MRI 2.3
|
377
|
+
* Ruby MRI 2.4
|
350
378
|
* JRuby 9.1.5 (experimental)
|
351
379
|
|
352
380
|
Other versions aren't yet officially supported.
|
381
|
+
|
382
|
+
=== Rails support
|
383
|
+
|
384
|
+
The supported versions are:
|
385
|
+
|
386
|
+
* \Rails 3.2 (MRI interpreter, JRuby is experimental)
|
387
|
+
* \Rails 4.2 (MRI interpreter, JRuby is experimental)
|
388
|
+
* \Rails 5.0 (MRI interpreter)
|
389
|
+
|
390
|
+
The currently supported web server are:
|
391
|
+
* Puma 2.16+ and 3.6+
|
392
|
+
* Unicorn 4.8+ and 5.1+
|
393
|
+
* Passenger 5.0+
|
394
|
+
|
395
|
+
=== Sinatra support
|
396
|
+
|
397
|
+
Currently we are supporting Sinatra >= 1.4.0.
|