fair-ddtrace 0.8.2.a
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 +7 -0
- data/.env +11 -0
- data/.gitignore +59 -0
- data/.rubocop.yml +61 -0
- data/.yardopts +5 -0
- data/Appraisals +136 -0
- data/Gemfile +3 -0
- data/LICENSE +24 -0
- data/README.md +156 -0
- data/Rakefile +176 -0
- data/circle.yml +61 -0
- data/ddtrace.gemspec +44 -0
- data/docker-compose.yml +42 -0
- data/docs/GettingStarted.md +735 -0
- data/gemfiles/contrib.gemfile +16 -0
- data/gemfiles/contrib_old.gemfile +15 -0
- data/gemfiles/rails30_postgres.gemfile +10 -0
- data/gemfiles/rails30_postgres_sidekiq.gemfile +11 -0
- data/gemfiles/rails32_mysql2.gemfile +11 -0
- data/gemfiles/rails32_postgres.gemfile +10 -0
- data/gemfiles/rails32_postgres_redis.gemfile +11 -0
- data/gemfiles/rails32_postgres_sidekiq.gemfile +11 -0
- data/gemfiles/rails4_mysql2.gemfile +9 -0
- data/gemfiles/rails4_postgres.gemfile +9 -0
- data/gemfiles/rails4_postgres_redis.gemfile +10 -0
- data/gemfiles/rails4_postgres_sidekiq.gemfile +11 -0
- data/gemfiles/rails5_mysql2.gemfile +8 -0
- data/gemfiles/rails5_postgres.gemfile +8 -0
- data/gemfiles/rails5_postgres_redis.gemfile +9 -0
- data/gemfiles/rails5_postgres_sidekiq.gemfile +10 -0
- data/lib/ddtrace.rb +73 -0
- data/lib/ddtrace/buffer.rb +52 -0
- data/lib/ddtrace/context.rb +145 -0
- data/lib/ddtrace/contrib/active_record/patcher.rb +94 -0
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +108 -0
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +22 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +164 -0
- data/lib/ddtrace/contrib/grape/patcher.rb +73 -0
- data/lib/ddtrace/contrib/http/patcher.rb +156 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +150 -0
- data/lib/ddtrace/contrib/rails/action_controller.rb +81 -0
- data/lib/ddtrace/contrib/rails/action_view.rb +110 -0
- data/lib/ddtrace/contrib/rails/active_record.rb +56 -0
- data/lib/ddtrace/contrib/rails/active_support.rb +113 -0
- data/lib/ddtrace/contrib/rails/core_extensions.rb +137 -0
- data/lib/ddtrace/contrib/rails/framework.rb +171 -0
- data/lib/ddtrace/contrib/rails/middlewares.rb +32 -0
- data/lib/ddtrace/contrib/rails/utils.rb +43 -0
- data/lib/ddtrace/contrib/redis/patcher.rb +118 -0
- data/lib/ddtrace/contrib/redis/quantize.rb +30 -0
- data/lib/ddtrace/contrib/redis/tags.rb +19 -0
- data/lib/ddtrace/contrib/sidekiq/tracer.rb +103 -0
- data/lib/ddtrace/contrib/sinatra/tracer.rb +169 -0
- data/lib/ddtrace/distributed.rb +38 -0
- data/lib/ddtrace/encoding.rb +65 -0
- data/lib/ddtrace/error.rb +37 -0
- data/lib/ddtrace/ext/app_types.rb +10 -0
- data/lib/ddtrace/ext/cache.rb +7 -0
- data/lib/ddtrace/ext/distributed.rb +10 -0
- data/lib/ddtrace/ext/errors.rb +10 -0
- data/lib/ddtrace/ext/http.rb +11 -0
- data/lib/ddtrace/ext/net.rb +8 -0
- data/lib/ddtrace/ext/redis.rb +11 -0
- data/lib/ddtrace/ext/sql.rb +8 -0
- data/lib/ddtrace/logger.rb +39 -0
- data/lib/ddtrace/monkey.rb +84 -0
- data/lib/ddtrace/pin.rb +63 -0
- data/lib/ddtrace/provider.rb +21 -0
- data/lib/ddtrace/sampler.rb +49 -0
- data/lib/ddtrace/span.rb +222 -0
- data/lib/ddtrace/tracer.rb +310 -0
- data/lib/ddtrace/transport.rb +162 -0
- data/lib/ddtrace/utils.rb +16 -0
- data/lib/ddtrace/version.rb +9 -0
- data/lib/ddtrace/workers.rb +108 -0
- data/lib/ddtrace/writer.rb +118 -0
- metadata +208 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8d8406c22a52e0293d58c806768b921dfce85da1
|
|
4
|
+
data.tar.gz: 31b29c7a0af9d5bed73bc8670eb2646d6ee62d56
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e01f435e62fedd4e295a2b62f14041aec9e524a5e908a0a7050bf7ca94133798d7d5fda30690cb4351dd6d58902331a58a7241f57651ddf24ca4bcc23364103a
|
|
7
|
+
data.tar.gz: a46d900f85f22b957858df467de8e8b6b62a47ad8ff188c3a0c421c29a2e14b945ddf47e8e7547e90e07b3a1af1822cb52c540ce3ccaa9c2f0b732ca765cd33e
|
data/.env
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
TEST_POSTGRES_PORT=55432
|
|
2
|
+
TEST_POSTGRES_USER=postgres
|
|
3
|
+
TEST_POSTGRES_PASSWORD=postgres
|
|
4
|
+
TEST_POSTGRES_DB=postgres
|
|
5
|
+
TEST_MYSQL_PORT=53306
|
|
6
|
+
TEST_MYSQL_ROOT_PASSWORD=root
|
|
7
|
+
TEST_MYSQL_PASSWORD=mysql
|
|
8
|
+
TEST_MYSQL_USER=mysql
|
|
9
|
+
TEST_ELASTICSEARCH_REST_PORT=49200
|
|
10
|
+
TEST_ELASTICSEARCH_NATIVE_PORT=49300
|
|
11
|
+
TEST_REDIS_PORT=46379
|
data/.gitignore
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
/log/
|
|
13
|
+
|
|
14
|
+
# Used by dotenv library to load environment variables.
|
|
15
|
+
# .env
|
|
16
|
+
|
|
17
|
+
## Specific to RubyMotion:
|
|
18
|
+
.dat*
|
|
19
|
+
.repl_history
|
|
20
|
+
build/
|
|
21
|
+
*.bridgesupport
|
|
22
|
+
build-iPhoneOS/
|
|
23
|
+
build-iPhoneSimulator/
|
|
24
|
+
|
|
25
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
26
|
+
#
|
|
27
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
28
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
29
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
30
|
+
#
|
|
31
|
+
# vendor/Pods/
|
|
32
|
+
|
|
33
|
+
## Documentation cache and generated files:
|
|
34
|
+
/.yardoc/
|
|
35
|
+
/_yardoc/
|
|
36
|
+
/doc/
|
|
37
|
+
/rdoc/
|
|
38
|
+
/html/
|
|
39
|
+
|
|
40
|
+
## Environment normalization:
|
|
41
|
+
/.bundle/
|
|
42
|
+
/vendor/bundle
|
|
43
|
+
/lib/bundler/man/
|
|
44
|
+
|
|
45
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
46
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
47
|
+
# Gemfile.lock
|
|
48
|
+
# .ruby-version
|
|
49
|
+
# .ruby-gemset
|
|
50
|
+
|
|
51
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
52
|
+
.rvmrc
|
|
53
|
+
|
|
54
|
+
# lock files
|
|
55
|
+
Gemfile.lock
|
|
56
|
+
gemfiles/*.lock
|
|
57
|
+
|
|
58
|
+
# bundle config
|
|
59
|
+
gemfiles/.bundle
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.1
|
|
3
|
+
|
|
4
|
+
# 80 characters is a nice goal, but not worth currently changing in existing
|
|
5
|
+
# code for the sake of changing it to conform to a length set in 1928 (IBM).
|
|
6
|
+
Metrics/LineLength:
|
|
7
|
+
Max: 124
|
|
8
|
+
|
|
9
|
+
# These exceptions are good goals to attain, and probably will over time,
|
|
10
|
+
# so periodic disabling and re-running to inspect values is suggested.
|
|
11
|
+
|
|
12
|
+
Metrics/AbcSize:
|
|
13
|
+
Max: 50
|
|
14
|
+
|
|
15
|
+
# TODO: As refactors continue, this should drop. However, the goal of
|
|
16
|
+
# 10 lines in a method may be a little lofty.
|
|
17
|
+
Metrics/MethodLength:
|
|
18
|
+
Max: 36
|
|
19
|
+
|
|
20
|
+
# TODO: this is not compliant with the Ruby community style guide. We
|
|
21
|
+
# should enable again this rule but it will change the public API because
|
|
22
|
+
# we're using set_ methods. We should work on that because also Rails
|
|
23
|
+
# honors this rule.
|
|
24
|
+
Style/AccessorMethodName:
|
|
25
|
+
Enabled: false
|
|
26
|
+
|
|
27
|
+
Style/MethodCallWithoutArgsParentheses:
|
|
28
|
+
Enabled: false
|
|
29
|
+
|
|
30
|
+
Style/RescueModifier:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
Style/NumericLiterals:
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
Metrics/ClassLength:
|
|
37
|
+
Max: 140
|
|
38
|
+
|
|
39
|
+
Metrics/BlockLength:
|
|
40
|
+
Max: 42
|
|
41
|
+
|
|
42
|
+
Metrics/ParameterLists:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Metrics/CyclomaticComplexity:
|
|
46
|
+
Max: 15
|
|
47
|
+
|
|
48
|
+
Metrics/PerceivedComplexity:
|
|
49
|
+
Max: 15
|
|
50
|
+
|
|
51
|
+
Lint/UnusedMethodArgument:
|
|
52
|
+
Enabled: false
|
|
53
|
+
|
|
54
|
+
# Disabling advices that would lead to incompatible Ruby 1.9 code
|
|
55
|
+
Style/SymbolArray:
|
|
56
|
+
Enabled: false
|
|
57
|
+
|
|
58
|
+
# Simple conditionals are perfectly fine, and more readable for multiline
|
|
59
|
+
# expressions.
|
|
60
|
+
Style/GuardClause:
|
|
61
|
+
Enabled: false
|
data/.yardopts
ADDED
data/Appraisals
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
if RUBY_VERSION < '2.4.0' && RUBY_PLATFORM != 'java'
|
|
2
|
+
if RUBY_VERSION >= '1.9.1'
|
|
3
|
+
appraise 'rails32-mysql2' do
|
|
4
|
+
gem 'test-unit'
|
|
5
|
+
gem 'rails', '3.2.22.5'
|
|
6
|
+
gem 'mysql2', '0.3.21', platform: :ruby
|
|
7
|
+
gem 'activerecord-mysql-adapter', platform: :ruby
|
|
8
|
+
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if RUBY_VERSION >= '1.9.1'
|
|
13
|
+
appraise 'rails30-postgres' do
|
|
14
|
+
gem 'test-unit'
|
|
15
|
+
gem 'rails', '3.0.20'
|
|
16
|
+
gem 'pg', '0.15.1', platform: :ruby
|
|
17
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
|
18
|
+
end
|
|
19
|
+
|
|
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
|
|
31
|
+
gem 'test-unit'
|
|
32
|
+
gem 'rails', '3.2.22.5'
|
|
33
|
+
gem 'pg', '0.15.1', platform: :ruby
|
|
34
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
appraise 'rails32-postgres-redis' do
|
|
38
|
+
gem 'test-unit'
|
|
39
|
+
gem 'rails', '3.2.22.5'
|
|
40
|
+
gem 'pg', '0.15.1', platform: :ruby
|
|
41
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
|
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
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if RUBY_VERSION >= '2.1.10'
|
|
57
|
+
appraise 'rails4-mysql2' do
|
|
58
|
+
gem 'rails', '4.2.7.1'
|
|
59
|
+
gem 'mysql2', platform: :ruby
|
|
60
|
+
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
appraise 'rails4-postgres' do
|
|
64
|
+
gem 'rails', '4.2.7.1'
|
|
65
|
+
gem 'pg', platform: :ruby
|
|
66
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
appraise 'rails4-postgres-redis' do
|
|
70
|
+
gem 'rails', '4.2.7.1'
|
|
71
|
+
gem 'pg', platform: :ruby
|
|
72
|
+
gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
|
|
73
|
+
gem 'redis-rails'
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if RUBY_VERSION >= '2.2.2'
|
|
78
|
+
appraise 'rails5-mysql2' do
|
|
79
|
+
gem 'rails', '5.0.1'
|
|
80
|
+
gem 'mysql2', platform: :ruby
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
appraise 'rails5-postgres' do
|
|
84
|
+
gem 'rails', '5.0.1'
|
|
85
|
+
gem 'pg', platform: :ruby
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
appraise 'rails5-postgres-redis' do
|
|
89
|
+
gem 'rails', '5.0.1'
|
|
90
|
+
gem 'pg', platform: :ruby
|
|
91
|
+
gem 'redis-rails'
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
appraise 'rails5-postgres-sidekiq' do
|
|
95
|
+
gem 'rails', '5.0.1'
|
|
96
|
+
gem 'pg', platform: :ruby
|
|
97
|
+
gem 'sidekiq'
|
|
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'
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
|
|
112
|
+
appraise 'contrib' do
|
|
113
|
+
gem 'elasticsearch-transport'
|
|
114
|
+
gem 'grape'
|
|
115
|
+
gem 'rack'
|
|
116
|
+
gem 'rack-test'
|
|
117
|
+
gem 'redis'
|
|
118
|
+
gem 'hiredis'
|
|
119
|
+
gem 'sinatra'
|
|
120
|
+
gem 'sqlite3'
|
|
121
|
+
gem 'activerecord'
|
|
122
|
+
gem 'sidekiq'
|
|
123
|
+
end
|
|
124
|
+
else
|
|
125
|
+
appraise 'contrib-old' do
|
|
126
|
+
gem 'elasticsearch-transport'
|
|
127
|
+
gem 'redis', '< 4.0.0'
|
|
128
|
+
gem 'hiredis'
|
|
129
|
+
gem 'rack', '1.4.7'
|
|
130
|
+
gem 'rack-test'
|
|
131
|
+
gem 'sinatra', '1.4.5'
|
|
132
|
+
gem 'sqlite3'
|
|
133
|
+
gem 'activerecord', '3.2.22.5'
|
|
134
|
+
gem 'sidekiq', '4.0.0'
|
|
135
|
+
end
|
|
136
|
+
end
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2016, Datadog <info@datadoghq.com>
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
* Redistributions of source code must retain the above copyright
|
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
|
10
|
+
documentation and/or other materials provided with the distribution.
|
|
11
|
+
* Neither the name of Datadog nor the
|
|
12
|
+
names of its contributors may be used to endorse or promote products
|
|
13
|
+
derived from this software without specific prior written permission.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# dd-trace-rb
|
|
2
|
+
|
|
3
|
+
[](https://circleci.com/gh/DataDog/dd-trace-rb/tree/master)
|
|
4
|
+
|
|
5
|
+
## Why this Fork?
|
|
6
|
+
The v0.8.2 version of dd-trace-rb has a bug whenever calling [send_traces on the worker](https://github.com/DataDog/dd-trace-rb/blob/v0.8.2/lib/ddtrace/workers.rb#L36). Ironically, this ends up blowing up on the log line and killing the worker.
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
You can find the latest documentation on [rubydoc.info][docs]
|
|
11
|
+
|
|
12
|
+
[docs]: http://www.rubydoc.info/github/DataDog/dd-trace-rb/
|
|
13
|
+
|
|
14
|
+
## Getting started
|
|
15
|
+
|
|
16
|
+
### Install
|
|
17
|
+
|
|
18
|
+
Install the Ruby client with the ``gem`` command:
|
|
19
|
+
|
|
20
|
+
gem install ddtrace
|
|
21
|
+
|
|
22
|
+
If you're using ``Bundler``, just update your ``Gemfile`` as follows:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
source 'https://rubygems.org'
|
|
26
|
+
|
|
27
|
+
# tracing gem
|
|
28
|
+
gem 'ddtrace'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
To use a development/preview version, use:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
gem 'ddtrace', :github => 'DataDog/dd-trace-rb', :branch => 'me/my-feature-branch'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Quickstart (manual instrumentation)
|
|
38
|
+
|
|
39
|
+
If you aren't using a supported framework instrumentation, you may want to to manually instrument your code.
|
|
40
|
+
Adding tracing to your code is very simple. As an example, let’s imagine we have a web server and we want
|
|
41
|
+
to trace requests to the home page:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
require 'ddtrace'
|
|
45
|
+
require 'sinatra'
|
|
46
|
+
require 'active_record'
|
|
47
|
+
|
|
48
|
+
# a generic tracer that you can use across your application
|
|
49
|
+
tracer = Datadog.tracer
|
|
50
|
+
|
|
51
|
+
get '/' do
|
|
52
|
+
tracer.trace('web.request') do |span|
|
|
53
|
+
# set some span metadata
|
|
54
|
+
span.service = 'my-web-site'
|
|
55
|
+
span.resource = '/'
|
|
56
|
+
span.set_tag('http.method', request.request_method)
|
|
57
|
+
|
|
58
|
+
# trace the activerecord call
|
|
59
|
+
tracer.trace('posts.fetch') do
|
|
60
|
+
@posts = Posts.order(created_at: :desc).limit(10)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# trace the template rendering
|
|
64
|
+
tracer.trace('template.render') do
|
|
65
|
+
erb :index
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Quickstart (integration)
|
|
72
|
+
|
|
73
|
+
Instead of doing the above manually, whenever an integration is available,
|
|
74
|
+
you can activate it. The example above would become:
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
require 'ddtrace'
|
|
78
|
+
require 'sinatra'
|
|
79
|
+
require 'active_record'
|
|
80
|
+
|
|
81
|
+
Datadog::Monkey.patch_all # monkey patch all available integrations
|
|
82
|
+
|
|
83
|
+
# now write your code naturally, it's traced automatically
|
|
84
|
+
get '/' do
|
|
85
|
+
@posts = Posts.order(created_at: :desc).limit(10)
|
|
86
|
+
erb :index
|
|
87
|
+
end
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This will automatically trace any app inherited from `Sinatra::Application`.
|
|
91
|
+
To trace apps inherited from `Sinatra::Base`, you should manually register
|
|
92
|
+
the tracer inside your class.
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
require "ddtrace"
|
|
96
|
+
require "ddtrace/contrib/sinatra/tracer"
|
|
97
|
+
|
|
98
|
+
class App < Sinatra::Base
|
|
99
|
+
register Datadog::Contrib::Sinatra::Tracer
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To know if a given framework or lib is supported by our client,
|
|
104
|
+
please consult our [integrations][contrib] list.
|
|
105
|
+
|
|
106
|
+
[contrib]: http://www.rubydoc.info/github/DataDog/dd-trace-rb/Datadog/Contrib
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
### Testing
|
|
111
|
+
|
|
112
|
+
Configure your environment through:
|
|
113
|
+
|
|
114
|
+
$ bundle install
|
|
115
|
+
$ appraisal install
|
|
116
|
+
|
|
117
|
+
You can launch tests using the following Rake commands:
|
|
118
|
+
|
|
119
|
+
$ rake test:main # tracer tests
|
|
120
|
+
$ appraisal rails<version>-<database> rake test:rails # tests Rails matrix
|
|
121
|
+
$ appraisal contrib rake test:redis # tests Redis integration
|
|
122
|
+
...
|
|
123
|
+
|
|
124
|
+
Run ``rake --tasks`` for the list of available Rake tasks.
|
|
125
|
+
|
|
126
|
+
Available appraisals are:
|
|
127
|
+
|
|
128
|
+
* ``contrib``: default for integrations
|
|
129
|
+
* ``contrib-old``: default for integrations, with version suited for old Ruby (possibly unmaintained) versions
|
|
130
|
+
* ``rails3-mysql2``: Rails3 with Mysql
|
|
131
|
+
* ``rails3-postgres``: Rails 3 with Postgres
|
|
132
|
+
* ``rails3-postgres-redis``: Rails 3 with Postgres and Redis
|
|
133
|
+
* ``rails3-postgres-sidekiq``: Rails 3 with Postgres and Sidekiq
|
|
134
|
+
* ``rails4-mysql2``: Rails4 with Mysql
|
|
135
|
+
* ``rails4-postgres``: Rails 4 with Postgres
|
|
136
|
+
* ``rails4-postgres-redis``: Rails 4 with Postgres and Redis
|
|
137
|
+
* ``rails4-postgres-sidekiq``: Rails 4 with Postgres and Sidekiq
|
|
138
|
+
* ``rails5-mysql2``: Rails5 with Mysql
|
|
139
|
+
* ``rails5-postgres``: Rails 5 with Postgres
|
|
140
|
+
* ``rails5-postgres-redis``: Rails 5 with Postgres and Redis
|
|
141
|
+
* ``rails5-postgres-sidekiq``: Rails 5 with Postgres and Sidekiq
|
|
142
|
+
|
|
143
|
+
The test suite requires many backing services (PostgreSQL, MySQL, Redis, ...) and we're using
|
|
144
|
+
``docker`` and ``docker-compose`` to start these services in the CI.
|
|
145
|
+
To launch properly the test matrix, please [install docker][2] and [docker-compose][3] using
|
|
146
|
+
the instructions provided by your platform. Then launch them through:
|
|
147
|
+
|
|
148
|
+
$ docker-compose up -d
|
|
149
|
+
|
|
150
|
+
We also enforce the Ruby [community-driven style guide][1] through Rubocop. Simply launch:
|
|
151
|
+
|
|
152
|
+
$ rake rubocop
|
|
153
|
+
|
|
154
|
+
[1]: https://github.com/bbatsov/ruby-style-guide
|
|
155
|
+
[2]: https://www.docker.com/products/docker
|
|
156
|
+
[3]: https://www.docker.com/products/docker-compose
|