ddtrace 0.12.0 → 0.13.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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +468 -0
  3. data/.circleci/images/primary/Dockerfile-1.9.3 +69 -0
  4. data/.circleci/images/primary/Dockerfile-2.0.0 +69 -0
  5. data/.circleci/images/primary/Dockerfile-2.1.10 +69 -0
  6. data/.circleci/images/primary/Dockerfile-2.2.10 +69 -0
  7. data/.circleci/images/primary/Dockerfile-2.3.7 +73 -0
  8. data/.circleci/images/primary/Dockerfile-2.4.4 +73 -0
  9. data/.dockerignore +1 -0
  10. data/.env +21 -11
  11. data/.gitignore +1 -1
  12. data/.rubocop.yml +4 -1
  13. data/Appraisals +471 -66
  14. data/CHANGELOG.md +80 -2
  15. data/Rakefile +304 -80
  16. data/ddtrace.gemspec +7 -7
  17. data/docker-compose.yml +240 -37
  18. data/docs/GettingStarted.md +273 -7
  19. data/lib/ddtrace/configuration.rb +2 -2
  20. data/lib/ddtrace/contrib/active_model_serializers/event.rb +57 -0
  21. data/lib/ddtrace/contrib/active_model_serializers/events/render.rb +32 -0
  22. data/lib/ddtrace/contrib/active_model_serializers/events/serialize.rb +35 -0
  23. data/lib/ddtrace/contrib/active_model_serializers/events.rb +30 -0
  24. data/lib/ddtrace/contrib/active_model_serializers/patcher.rb +62 -0
  25. data/lib/ddtrace/contrib/active_record/event.rb +30 -0
  26. data/lib/ddtrace/contrib/active_record/events/instantiation.rb +51 -0
  27. data/lib/ddtrace/contrib/active_record/events/sql.rb +48 -0
  28. data/lib/ddtrace/contrib/active_record/events.rb +30 -0
  29. data/lib/ddtrace/contrib/active_record/patcher.rb +3 -73
  30. data/lib/ddtrace/contrib/active_record/utils.rb +1 -15
  31. data/lib/ddtrace/contrib/active_support/notifications/event.rb +62 -0
  32. data/lib/ddtrace/contrib/aws/instrumentation.rb +2 -2
  33. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +2 -2
  34. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +18 -49
  35. data/lib/ddtrace/contrib/excon/middleware.rb +139 -0
  36. data/lib/ddtrace/contrib/excon/patcher.rb +50 -0
  37. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +49 -0
  38. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +66 -0
  39. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +65 -0
  40. data/lib/ddtrace/contrib/grpc/intercept_with_datadog.rb +49 -0
  41. data/lib/ddtrace/contrib/grpc/patcher.rb +62 -0
  42. data/lib/ddtrace/contrib/http/patcher.rb +18 -16
  43. data/lib/ddtrace/contrib/mongodb/parsers.rb +24 -13
  44. data/lib/ddtrace/contrib/mongodb/patcher.rb +1 -0
  45. data/lib/ddtrace/contrib/mongodb/subscribers.rb +5 -4
  46. data/lib/ddtrace/contrib/mysql2/client.rb +60 -0
  47. data/lib/ddtrace/contrib/mysql2/patcher.rb +43 -0
  48. data/lib/ddtrace/contrib/racecar/event.rb +61 -0
  49. data/lib/ddtrace/contrib/racecar/events/batch.rb +27 -0
  50. data/lib/ddtrace/contrib/racecar/events/message.rb +27 -0
  51. data/lib/ddtrace/contrib/racecar/events.rb +30 -0
  52. data/lib/ddtrace/contrib/racecar/patcher.rb +6 -52
  53. data/lib/ddtrace/contrib/rack/middlewares.rb +65 -11
  54. data/lib/ddtrace/contrib/rack/patcher.rb +16 -0
  55. data/lib/ddtrace/contrib/rack/request_queue.rb +34 -0
  56. data/lib/ddtrace/contrib/rails/action_controller_patch.rb +77 -0
  57. data/lib/ddtrace/contrib/rails/action_view.rb +0 -65
  58. data/lib/ddtrace/contrib/rails/active_support.rb +9 -8
  59. data/lib/ddtrace/contrib/rails/core_extensions.rb +74 -115
  60. data/lib/ddtrace/contrib/rake/instrumentation.rb +70 -0
  61. data/lib/ddtrace/contrib/rake/patcher.rb +53 -0
  62. data/lib/ddtrace/contrib/sequel/database.rb +58 -0
  63. data/lib/ddtrace/contrib/sequel/dataset.rb +59 -0
  64. data/lib/ddtrace/contrib/sequel/patcher.rb +56 -0
  65. data/lib/ddtrace/contrib/sequel/utils.rb +28 -0
  66. data/lib/ddtrace/contrib/sidekiq/tracer.rb +1 -0
  67. data/lib/ddtrace/contrib/sinatra/env.rb +39 -0
  68. data/lib/ddtrace/contrib/sinatra/headers.rb +31 -0
  69. data/lib/ddtrace/contrib/sinatra/tracer.rb +21 -38
  70. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +61 -0
  71. data/lib/ddtrace/ext/distributed.rb +5 -0
  72. data/lib/ddtrace/ext/grpc.rb +7 -0
  73. data/lib/ddtrace/ext/http.rb +35 -5
  74. data/lib/ddtrace/propagation/grpc_propagator.rb +54 -0
  75. data/lib/ddtrace/quantization/hash.rb +103 -0
  76. data/lib/ddtrace/tracer.rb +4 -1
  77. data/lib/ddtrace/utils/database.rb +21 -0
  78. data/lib/ddtrace/utils.rb +12 -2
  79. data/lib/ddtrace/version.rb +1 -1
  80. data/lib/ddtrace.rb +7 -0
  81. metadata +50 -21
  82. data/circle.yml +0 -69
  83. data/gemfiles/contrib.gemfile +0 -25
  84. data/gemfiles/contrib_old.gemfile +0 -23
  85. data/gemfiles/rails30_postgres.gemfile +0 -11
  86. data/gemfiles/rails30_postgres_sidekiq.gemfile +0 -12
  87. data/gemfiles/rails32_mysql2.gemfile +0 -12
  88. data/gemfiles/rails32_postgres.gemfile +0 -11
  89. data/gemfiles/rails32_postgres_redis.gemfile +0 -13
  90. data/gemfiles/rails32_postgres_sidekiq.gemfile +0 -12
  91. data/gemfiles/rails4_mysql2.gemfile +0 -10
  92. data/gemfiles/rails4_postgres.gemfile +0 -10
  93. data/gemfiles/rails4_postgres_redis.gemfile +0 -12
  94. data/gemfiles/rails4_postgres_sidekiq.gemfile +0 -12
  95. data/gemfiles/rails5_mysql2.gemfile +0 -9
  96. data/gemfiles/rails5_postgres.gemfile +0 -9
  97. data/gemfiles/rails5_postgres_redis.gemfile +0 -11
  98. data/gemfiles/rails5_postgres_sidekiq.gemfile +0 -11
data/docker-compose.yml CHANGED
@@ -1,52 +1,255 @@
1
- # remember to use this compose file __ONLY__ for development/testing purposes
2
- postgres:
3
- image: postgres:9.6
1
+ version: '3.2'
2
+ services:
3
+ tracer-1.9:
4
+ build:
5
+ context: ./.circleci/images/primary
6
+ dockerfile: Dockerfile-1.9.3
7
+ command: /bin/bash
8
+ depends_on:
9
+ - ddagent
10
+ - elasticsearch
11
+ - memcached
12
+ - mongodb
13
+ - mysql
14
+ - postgres
15
+ - redis
16
+ env_file: ./.env
4
17
  environment:
5
- - POSTGRES_PASSWORD=$TEST_POSTGRES_PASSWORD
6
- - POSTGRES_USER=$TEST_POSTGRES_USER
7
- - POSTGRES_DB=$TEST_POSTGRES_DB
8
- ports:
9
- - "127.0.0.1:${TEST_POSTGRES_PORT}:5432"
10
-
11
- mysql:
12
- image: mysql:5.6
18
+ - BUNDLE_GEMFILE=/app/Gemfile
19
+ - TEST_DATADOG_INTEGRATION=1
20
+ - TEST_DDAGENT_HOST=ddagent
21
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
22
+ - TEST_MEMCACHED_HOST=memcached
23
+ - TEST_MONGODB_HOST=mongodb
24
+ - TEST_MYSQL_HOST=mysql
25
+ - TEST_POSTGRES_HOST=postgres
26
+ - TEST_REDIS_HOST=redis
27
+ stdin_open: true
28
+ tty: true
29
+ volumes:
30
+ - .:/app
31
+ - bundle-1.9:/usr/local/bundle
32
+ - gemfiles-1.9:/app/gemfiles
33
+ tracer-2.0:
34
+ build:
35
+ context: ./.circleci/images/primary
36
+ dockerfile: Dockerfile-2.0.0
37
+ command: /bin/bash
38
+ depends_on:
39
+ - ddagent
40
+ - elasticsearch
41
+ - memcached
42
+ - mongodb
43
+ - mysql
44
+ - postgres
45
+ - redis
46
+ env_file: ./.env
47
+ environment:
48
+ - BUNDLE_GEMFILE=/app/Gemfile
49
+ - TEST_DATADOG_INTEGRATION=1
50
+ - TEST_DDAGENT_HOST=ddagent
51
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
52
+ - TEST_MEMCACHED_HOST=memcached
53
+ - TEST_MONGODB_HOST=mongodb
54
+ - TEST_MYSQL_HOST=mysql
55
+ - TEST_POSTGRES_HOST=postgres
56
+ - TEST_REDIS_HOST=redis
57
+ stdin_open: true
58
+ tty: true
59
+ volumes:
60
+ - .:/app
61
+ - bundle-2.0:/usr/local/bundle
62
+ - gemfiles-2.0:/app/gemfiles
63
+ tracer-2.1:
64
+ build:
65
+ context: ./.circleci/images/primary
66
+ dockerfile: Dockerfile-2.1.10
67
+ command: /bin/bash
68
+ depends_on:
69
+ - ddagent
70
+ - elasticsearch
71
+ - memcached
72
+ - mongodb
73
+ - mysql
74
+ - postgres
75
+ - redis
76
+ env_file: ./.env
77
+ environment:
78
+ - BUNDLE_GEMFILE=/app/Gemfile
79
+ - TEST_DATADOG_INTEGRATION=1
80
+ - TEST_DDAGENT_HOST=ddagent
81
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
82
+ - TEST_MEMCACHED_HOST=memcached
83
+ - TEST_MONGODB_HOST=mongodb
84
+ - TEST_MYSQL_HOST=mysql
85
+ - TEST_POSTGRES_HOST=postgres
86
+ - TEST_REDIS_HOST=redis
87
+ stdin_open: true
88
+ tty: true
89
+ volumes:
90
+ - .:/app
91
+ - bundle-2.1:/usr/local/bundle
92
+ - gemfiles-2.1:/app/gemfiles
93
+ tracer-2.2:
94
+ build:
95
+ context: ./.circleci/images/primary
96
+ dockerfile: Dockerfile-2.2.10
97
+ command: /bin/bash
98
+ depends_on:
99
+ - ddagent
100
+ - elasticsearch
101
+ - memcached
102
+ - mongodb
103
+ - mysql
104
+ - postgres
105
+ - redis
106
+ env_file: ./.env
107
+ environment:
108
+ - BUNDLE_GEMFILE=/app/Gemfile
109
+ - TEST_DATADOG_INTEGRATION=1
110
+ - TEST_DDAGENT_HOST=ddagent
111
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
112
+ - TEST_MEMCACHED_HOST=memcached
113
+ - TEST_MONGODB_HOST=mongodb
114
+ - TEST_MYSQL_HOST=mysql
115
+ - TEST_POSTGRES_HOST=postgres
116
+ - TEST_REDIS_HOST=redis
117
+ stdin_open: true
118
+ tty: true
119
+ volumes:
120
+ - .:/app
121
+ - bundle-2.2:/usr/local/bundle
122
+ - gemfiles-2.2:/app/gemfiles
123
+ tracer-2.3:
124
+ build:
125
+ context: ./.circleci/images/primary
126
+ dockerfile: Dockerfile-2.3.7
127
+ command: /bin/bash
128
+ depends_on:
129
+ - ddagent
130
+ - elasticsearch
131
+ - memcached
132
+ - mongodb
133
+ - mysql
134
+ - postgres
135
+ - redis
136
+ env_file: ./.env
137
+ environment:
138
+ - BUNDLE_GEMFILE=/app/Gemfile
139
+ - TEST_DATADOG_INTEGRATION=1
140
+ - TEST_DDAGENT_HOST=ddagent
141
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
142
+ - TEST_MEMCACHED_HOST=memcached
143
+ - TEST_MONGODB_HOST=mongodb
144
+ - TEST_MYSQL_HOST=mysql
145
+ - TEST_POSTGRES_HOST=postgres
146
+ - TEST_REDIS_HOST=redis
147
+ stdin_open: true
148
+ tty: true
149
+ volumes:
150
+ - .:/app
151
+ - bundle-2.3:/usr/local/bundle
152
+ - gemfiles-2.3:/app/gemfiles
153
+ tracer-2.4:
154
+ build:
155
+ context: ./.circleci/images/primary
156
+ dockerfile: Dockerfile-2.4.4
157
+ command: /bin/bash
158
+ depends_on:
159
+ - ddagent
160
+ - elasticsearch
161
+ - memcached
162
+ - mongodb
163
+ - mysql
164
+ - postgres
165
+ - redis
166
+ env_file: ./.env
167
+ environment:
168
+ - BUNDLE_GEMFILE=/app/Gemfile
169
+ - TEST_DATADOG_INTEGRATION=1
170
+ - TEST_DDAGENT_HOST=ddagent
171
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
172
+ - TEST_MEMCACHED_HOST=memcached
173
+ - TEST_MONGODB_HOST=mongodb
174
+ - TEST_MYSQL_HOST=mysql
175
+ - TEST_POSTGRES_HOST=postgres
176
+ - TEST_REDIS_HOST=redis
177
+ stdin_open: true
178
+ tty: true
179
+ volumes:
180
+ - .:/app
181
+ - bundle-2.4:/usr/local/bundle
182
+ - gemfiles-2.4:/app/gemfiles
183
+ ddagent:
184
+ image: datadog/docker-dd-agent
13
185
  environment:
14
- - MYSQL_ROOT_PASSWORD=$TEST_MYSQL_ROOT_PASSWORD
15
- - MYSQL_PASSWORD=$TEST_MYSQL_PASSWORD
16
- - MYSQL_USER=$TEST_MYSQL_USER
186
+ - DD_APM_ENABLED=true
187
+ - DD_BIND_HOST=0.0.0.0
188
+ - DD_API_KEY=invalid_key_but_this_is_fine
189
+ expose:
190
+ - "8126"
17
191
  ports:
18
- - "127.0.0.1:${TEST_MYSQL_PORT}:3306"
19
-
20
- elasticsearch:
192
+ - "${TEST_DDAGENT_PORT}:8126"
193
+ elasticsearch:
21
194
  # Note: ES 5.0 dies with error:
22
195
  # max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
23
196
  # see https://github.com/docker-library/elasticsearch/issues/98 for details
24
197
  # For now, just rely on a 2.X server.
25
198
  image: elasticsearch:2.4
199
+ expose:
200
+ - "9200"
201
+ - "9300"
26
202
  ports:
27
- - "127.0.0.1:${TEST_ELASTICSEARCH_REST_PORT}:9200"
28
- - "127.0.0.1:${TEST_ELASTICSEARCH_NATIVE_PORT}:9300"
29
-
30
- redis:
31
- image: redis:3.0
203
+ - "${TEST_ELASTICSEARCH_REST_PORT}:9200"
204
+ - "${TEST_ELASTICSEARCH_NATIVE_PORT}:9300"
205
+ memcached:
206
+ image: memcached:1.5-alpine
207
+ expose:
208
+ - "11211"
32
209
  ports:
33
- - "127.0.0.1:${TEST_REDIS_PORT}:6379"
34
-
35
- mongodb:
210
+ - "${TEST_MEMCACHED_PORT}:11211"
211
+ mongodb:
36
212
  image: mongo:3.5
213
+ expose:
214
+ - "27017"
37
215
  ports:
38
- - "127.0.0.1:${TEST_MONGODB_PORT}:27017"
39
-
40
- memcached:
41
- image: memcached:1.5-alpine
216
+ - "${TEST_MONGODB_PORT}:27017"
217
+ mysql:
218
+ image: mysql:5.6
219
+ environment:
220
+ - MYSQL_ROOT_PASSWORD=$TEST_MYSQL_ROOT_PASSWORD
221
+ - MYSQL_PASSWORD=$TEST_MYSQL_PASSWORD
222
+ - MYSQL_USER=$TEST_MYSQL_USER
223
+ expose:
224
+ - "3306"
42
225
  ports:
43
- - "127.0.0.1:${TEST_MEMCACHED_PORT}:11211"
44
-
45
- ddagent:
46
- image: datadog/docker-dd-agent
226
+ - "${TEST_MYSQL_PORT}:3306"
227
+ postgres:
228
+ image: postgres:9.6
47
229
  environment:
48
- - DD_APM_ENABLED=true
49
- - DD_BIND_HOST=0.0.0.0
50
- - DD_API_KEY=invalid_key_but_this_is_fine
230
+ - POSTGRES_PASSWORD=$TEST_POSTGRES_PASSWORD
231
+ - POSTGRES_USER=$TEST_POSTGRES_USER
232
+ - POSTGRES_DB=$TEST_POSTGRES_DB
233
+ expose:
234
+ - "5432"
235
+ ports:
236
+ - "${TEST_POSTGRES_PORT}:5432"
237
+ redis:
238
+ image: redis:3.0
239
+ expose:
240
+ - "6379"
51
241
  ports:
52
- - "127.0.0.1:8126:8126"
242
+ - "${TEST_REDIS_PORT}:6379"
243
+ volumes:
244
+ bundle-1.9:
245
+ bundle-2.0:
246
+ bundle-2.1:
247
+ bundle-2.2:
248
+ bundle-2.3:
249
+ bundle-2.4:
250
+ gemfiles-1.9:
251
+ gemfiles-2.0:
252
+ gemfiles-2.1:
253
+ gemfiles-2.2:
254
+ gemfiles-2.3:
255
+ gemfiles-2.4:
@@ -27,7 +27,9 @@ For descriptions of terminology used in APM, take a look at the [official docume
27
27
  - [AWS](#aws)
28
28
  - [Dalli](#dalli)
29
29
  - [Elastic Search](#elastic-search)
30
+ - [Excon](#excon)
30
31
  - [Faraday](#faraday)
32
+ - [gRPC](#grpc)
31
33
  - [Grape](#grape)
32
34
  - [GraphQL](#graphql)
33
35
  - [MongoDB](#mongodb)
@@ -35,8 +37,10 @@ For descriptions of terminology used in APM, take a look at the [official docume
35
37
  - [Racecar](#racecar)
36
38
  - [Rack](#rack)
37
39
  - [Rails](#rails)
40
+ - [Rake](#rake)
38
41
  - [Redis](#redis)
39
42
  - [Resque](#resque)
43
+ - [Sequel](#sequel)
40
44
  - [Sidekiq](#sidekiq)
41
45
  - [Sinatra](#sinatra)
42
46
  - [Sucker Punch](#sucker-punch)
@@ -47,6 +51,7 @@ For descriptions of terminology used in APM, take a look at the [official docume
47
51
  - [Sampling](#sampling)
48
52
  - [Priority sampling](#priority-sampling)
49
53
  - [Distributed tracing](#distributed-tracing)
54
+ - [HTTP request queuing](#http-request-queuing)
50
55
  - [Processing pipeline](#processing-pipeline)
51
56
  - [Filtering](#filtering)
52
57
  - [Processing](#processing)
@@ -221,6 +226,16 @@ def finish(name, id, payload)
221
226
  end
222
227
  end
223
228
  ```
229
+ #####Enriching traces from nested methods
230
+
231
+ You can tag additional information to current active span from any method. Note however that if the method is called and there is no span currently active `active_span` will be nil.
232
+
233
+ ```ruby
234
+ # e.g. adding tag to active span
235
+
236
+ current_span = Datadog.tracer.active_span
237
+ current_span.set_tag('my_tag', 'my_value') unless current_span.nil?
238
+ ```
224
239
 
225
240
  ## Integration instrumentation
226
241
 
@@ -243,7 +258,9 @@ For a list of available integrations, and their configuration options, please re
243
258
  | AWS | `aws` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
244
259
  | Dalli | `dalli` | `>= 2.7` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
245
260
  | Elastic Search | `elasticsearch` | `>= 6.0` | *[Link](#elastic-search)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
261
+ | Excon | `excon` | `>= 0.62` | *[Link](#excon)* | *[Link](https://github.com/excon/excon)* |
246
262
  | Faraday | `faraday` | `>= 0.14` | *[Link](#faraday)* | *[Link](https://github.com/lostisland/faraday)* |
263
+ | gRPC | `grpc` | `>= 1.10` | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
247
264
  | Grape | `grape` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
248
265
  | GraphQL | `graphql` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
249
266
  | MongoDB | `mongo` | `>= 2.0, < 2.5` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
@@ -251,8 +268,10 @@ For a list of available integrations, and their configuration options, please re
251
268
  | Racecar | `racecar` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
252
269
  | Rack | `rack` | `>= 1.4.7` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
253
270
  | Rails | `rails` | `>= 3.2, < 5.2` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
271
+ | Rake | `rake` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
254
272
  | Redis | `redis` | `>= 3.2, < 4.0` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
255
273
  | Resque | `resque` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
274
+ | Sequel | `sequel` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
256
275
  | Sidekiq | `sidekiq` | `>= 4.0` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
257
276
  | Sinatra | `sinatra` | `>= 1.4.5` | *[Link](#sinatra)* | *[Link](https://github.com/sinatra/sinatra)* |
258
277
  | Sucker Punch | `sucker_punch` | `>= 2.0` | *[Link](#sucker-punch)* | *[Link](https://github.com/brandonhilkert/sucker_punch)* |
@@ -352,6 +371,58 @@ Where `options` is an optional `Hash` that accepts the following parameters:
352
371
  | ``service_name`` | Service name used for `elasticsearch` instrumentation | elasticsearch |
353
372
  | ``quantize`` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | {} |
354
373
 
374
+ ### Excon
375
+
376
+ The `excon` integration is available through the `ddtrace` middleware:
377
+
378
+ ```ruby
379
+ require 'excon'
380
+ require 'ddtrace'
381
+
382
+ # Configure default Excon tracing behavior
383
+ Datadog.configure do |c|
384
+ c.use :excon, service_name: 'excon'
385
+ end
386
+
387
+ connection = Excon.new('https://example.com')
388
+ connection.get
389
+ ```
390
+
391
+ Where `options` is an optional `Hash` that accepts the following parameters:
392
+
393
+ | Key | Description | Default |
394
+ | --- | --- | --- |
395
+ | `service_name` | Service name for Excon instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'excon'` |
396
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
397
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
398
+ | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | `nil` |
399
+ | `tracer` | A `Datadog::Tracer` instance used to instrument the application. Usually you don't need to set that. | `Datadog.tracer` |
400
+
401
+ **Configuring connections to use different settings**
402
+
403
+ If you use multiple connections with Excon, you can give each of them different settings by configuring their constructors with middleware:
404
+
405
+ ```ruby
406
+ # Wrap the Datadog tracing middleware around the default middleware stack
407
+ Excon.new(
408
+ 'http://example.com',
409
+ middlewares: Datadog::Contrib::Excon::Middleware.with(options).around_default_stack
410
+ )
411
+
412
+ # Insert the middleware into a custom middleware stack.
413
+ # NOTE: Trace middleware must be inserted after ResponseParser!
414
+ Excon.new(
415
+ 'http://example.com',
416
+ middlewares: [
417
+ Excon::Middleware::ResponseParser,
418
+ Datadog::Contrib::Excon::Middleware.with(options),
419
+ Excon::Middleware::Idempotent
420
+ ]
421
+ )
422
+ ```
423
+
424
+ Where `options` is a Hash that contains any of the parameters listed in the table above.
425
+
355
426
  ### Faraday
356
427
 
357
428
  The `faraday` integration is available through the `ddtrace` middleware:
@@ -374,12 +445,63 @@ connection.get('/foo')
374
445
 
375
446
  Where `options` is an optional `Hash` that accepts the following parameters:
376
447
 
377
- | Key | Default | Description |
448
+ | Key | Description | Default |
378
449
  | --- | --- | --- |
379
- | `service_name` | Global service name (default: `faraday`) | Service name for this specific connection object. |
380
- | `split_by_domain` | `false` | Uses the request domain as the service name when set to `true`. |
381
- | `distributed_tracing` | `false` | Propagates tracing context along the HTTP request when set to `true`. |
382
- | `error_handler` | ``5xx`` evaluated as errors | A callable object that receives a single argument – the request environment. If it evaluates to a *truthy* value, the trace span is marked as an error. |
450
+ | `service_name` | Service name for Faraday instrumentation. When provided to middleware for a specific connection, it applies only to that connection object. | `'faraday'` |
451
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
452
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `false` |
453
+ | `error_handler` | A `Proc` that accepts a `response` parameter. If it evaluates to a *truthy* value, the trace span is marked as an error. By default only sets 5XX responses as errors. | ``5xx`` evaluated as errors |
454
+ | `tracer` | A `Datadog::Tracer` instance used to instrument the application. Usually you don't need to set that. | `Datadog.tracer` |
455
+
456
+ ### gRPC
457
+
458
+ The `grpc` integration adds both client and server interceptors, which run as middleware prior to executing the service's remote procedure call. As gRPC applications are often distributed, the integration shares trace information between client and server.
459
+
460
+ To setup your integration, use the ``Datadog.configure`` method like so:
461
+
462
+ ```ruby
463
+ require 'grpc'
464
+ require 'ddtrace'
465
+
466
+ Datadog.configure do |c|
467
+ c.use :grpc, options
468
+ end
469
+
470
+ # run your application normally
471
+
472
+ # server side
473
+ server = GRPC::RpcServer.new
474
+ server.add_http2_port('localhost:50051', :this_port_is_insecure)
475
+ server.handle(Demo)
476
+ server.run_till_terminated
477
+
478
+ # client side
479
+ client = Demo.rpc_stub_class.new('localhost:50051', :this_channel_is_insecure)
480
+ client.my_endpoint(DemoMessage.new(contents: 'hello!'))
481
+ ```
482
+
483
+ In situations where you have multiple clients calling multiple distinct services, you may pass the Datadog interceptor directly, like so
484
+
485
+ ```ruby
486
+ configured_interceptor = Datadog::Contrib::GRPC::DatadogInterceptor::Client.new do |c|
487
+ c.service_name = "Alternate"
488
+ end
489
+
490
+ alternate_client = Demo::Echo::Service.rpc_stub_class.new(
491
+ 'localhost:50052',
492
+ :this_channel_is_insecure,
493
+ :interceptors => [configured_interceptor]
494
+ )
495
+ ```
496
+
497
+ The integration will ensure that the ``configured_interceptor`` establishes a unique tracing setup for that client instance.
498
+
499
+ The following configuration options are supported:
500
+
501
+ | Key | Description | Default |
502
+ | --- | --- | --- |
503
+ | ``service_name`` | Service name used for `grpc` instrumentation | grpc |
504
+ | ``tracer`` | Datadog tracer used for `grpc` instrumentation | Datadog.tracer |
383
505
 
384
506
  ### Grape
385
507
 
@@ -489,6 +611,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
489
611
  | Key | Description | Default |
490
612
  | --- | --- | --- |
491
613
  | ``service_name`` | Service name used for `mongo` instrumentation | mongodb |
614
+ | ``quantize`` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | ```{ show: [:collection, :database, :operation] }``` |
492
615
 
493
616
  ### Net/HTTP
494
617
 
@@ -514,8 +637,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
514
637
 
515
638
  | Key | Description | Default |
516
639
  | --- | --- | --- |
517
- | ``service_name`` | Service name used for `http` instrumentation | http |
518
- | ``distributed_tracing`` | Enables distributed tracing | ``false`` |
640
+ | ``service_name`` | Service name used for `http` instrumentation | net/http |
641
+ | ``distributed_tracing`` | Enables [distributed tracing](#distributed-tracing) | ``false`` |
642
+ | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
519
643
 
520
644
  If you wish to configure each connection object individually, you may use the ``Datadog.configure`` as it follows:
521
645
 
@@ -582,6 +706,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
582
706
  | ``quantize.fragment`` | Defines behavior for URL fragments. Removes fragments by default. May be `:show` to show URL fragments. Option must be nested inside the `quantize` option. | ``nil`` |
583
707
  | ``application`` | Your Rack application. Necessary for enabling middleware resource names. | ``nil`` |
584
708
  | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
709
+ | ``request_queuing`` | Track HTTP request time spent in the queue of the frontend server. See [HTTP request queuing](#http-request-queuing) for setup details. Set to `true` to enable. | ``false`` |
710
+ | ``web_service_name`` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | ``'web-server'`` |
711
+ | ``headers`` | Hash of HTTP request or response headers to add as tags to the `rack.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | ``{ response: ['Content-Type', 'X-Request-ID'] }`` |
585
712
 
586
713
  **Configuring URL quantization behavior**
587
714
 
@@ -641,6 +768,71 @@ Where `options` is an optional `Hash` that accepts the following parameters:
641
768
  | ``template_base_path`` | Used when the template name is parsed. If you don't store your templates in the ``views/`` folder, you may need to change this value | ``views/`` |
642
769
  | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
643
770
 
771
+ ### Rake
772
+
773
+ You can add instrumentation around your Rake tasks by activating the `rake` integration. Each task and its subsequent subtasks will be traced.
774
+
775
+ To activate Rake task tracing, add the following to your `Rakefile`:
776
+
777
+ ```ruby
778
+ # At the top of your Rakefile:
779
+ require 'rake'
780
+ require 'ddtrace'
781
+
782
+ Datadog.configure do |c|
783
+ c.use :rake, options
784
+ end
785
+
786
+ task :my_task do
787
+ # Do something task work here...
788
+ end
789
+
790
+ Rake::Task['my_task'].invoke
791
+ ```
792
+
793
+ Where `options` is an optional `Hash` that accepts the following parameters:
794
+
795
+ | Key | Description | Default |
796
+ | --- | --- | --- |
797
+ | ``enabled`` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | ``true`` |
798
+ | ``quantize`` | Hash containing options for quantization of task arguments. See below for more details and examples. | ``{}`` |
799
+ | ``service_name`` | Service name which the Rake task traces should be grouped under. | ``rake`` |
800
+ | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
801
+
802
+ **Configuring task quantization behavior**
803
+
804
+ ```ruby
805
+ Datadog.configure do |c|
806
+ # Given a task that accepts :one, :two, :three...
807
+ # Invoked with 'foo', 'bar', 'baz'.
808
+
809
+ # Default behavior: all arguments are quantized.
810
+ # `rake.invoke.args` tag --> ['?']
811
+ # `rake.execute.args` tag --> { one: '?', two: '?', three: '?' }
812
+ c.use :rake
813
+
814
+ # Show values for any argument matching :two exactly
815
+ # `rake.invoke.args` tag --> ['?']
816
+ # `rake.execute.args` tag --> { one: '?', two: 'bar', three: '?' }
817
+ c.use :rake, quantize: { args: { show: [:two] } }
818
+
819
+ # Show all values for all arguments.
820
+ # `rake.invoke.args` tag --> ['foo', 'bar', 'baz']
821
+ # `rake.execute.args` tag --> { one: 'foo', two: 'bar', three: 'baz' }
822
+ c.use :rake, quantize: { args: { show: :all } }
823
+
824
+ # Totally exclude any argument matching :three exactly
825
+ # `rake.invoke.args` tag --> ['?']
826
+ # `rake.execute.args` tag --> { one: '?', two: '?' }
827
+ c.use :rake, quantize: { args: { exclude: [:three] } }
828
+
829
+ # Remove the arguments entirely
830
+ # `rake.invoke.args` tag --> ['?']
831
+ # `rake.execute.args` tag --> {}
832
+ c.use :rake, quantize: { args: { exclude: :all } }
833
+ end
834
+ ```
835
+
644
836
  ### Redis
645
837
 
646
838
  The Redis integration will trace simple calls as well as pipelines.
@@ -703,6 +895,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
703
895
  | ``service_name`` | Service name used for `resque` instrumentation | resque |
704
896
  | ``workers`` | An array including all worker classes you want to trace (eg ``[MyJob]``) | ``[]`` |
705
897
 
898
+ ### Sequel
899
+
900
+ The Sequel integration traces queries made to your database.
901
+
902
+ ```ruby
903
+ require 'sequel'
904
+ require 'ddtrace'
905
+
906
+ # Connect to database
907
+ database = Sequel.sqlite
908
+
909
+ # Create a table
910
+ database.create_table :articles do
911
+ primary_key :id
912
+ String :name
913
+ end
914
+
915
+ Datadog.configure do |c|
916
+ c.use :sequel, options
917
+ end
918
+
919
+ # Perform a query
920
+ articles = database[:articles]
921
+ articles.all
922
+ ```
923
+
924
+ Where `options` is an optional `Hash` that accepts the following parameters:
925
+
926
+ | Key | Description | Default |
927
+ | --- | --- | --- |
928
+ | ``service_name`` | Service name used for `sequel.query` spans. | Name of database adapter (e.g. `mysql2`) |
929
+ | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
930
+
931
+ Only Ruby 2.0+ is supported.
932
+
933
+ **Configuring databases to use different settings**
934
+
935
+ If you use multiple databases with Sequel, you can give each of them different settings by configuring their respective `Sequel::Database` objects:
936
+
937
+ ```ruby
938
+ sqlite_database = Sequel.sqlite
939
+ postgres_database = Sequel.connect('postgres://user:password@host:port/database_name')
940
+
941
+ # Configure each database with different service names
942
+ Datadog.configure(sqlite_database, service_name: 'my-sqlite-db')
943
+ Datadog.configure(postgres_database, service_name: 'my-postgres-db')
944
+ ```
945
+
706
946
  ### Sidekiq
707
947
 
708
948
  The Sidekiq integration is a server-side middleware which will trace job executions.
@@ -752,6 +992,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
752
992
  | ``resource_script_names`` | Prepend resource names with script name | ``false`` |
753
993
  | ``distributed_tracing`` | Enables [distributed tracing](#distributed-tracing) so that this service trace is connected with a trace of another service if tracing headers are received | `false` |
754
994
  | ``tracer`` | A ``Datadog::Tracer`` instance used to instrument the application. Usually you don't need to set that. | ``Datadog.tracer`` |
995
+ | ``headers`` | Hash of HTTP request or response headers to add as tags to the `sinatra.request`. Accepts `request` and `response` keys with Array values e.g. `['Last-Modified']`. Adds `http.request.headers.*` and `http.response.headers.*` tags respectively. | ``{ response: ['Content-Type', 'X-Request-ID'] }`` |
755
996
 
756
997
  ### Sucker Punch
757
998
 
@@ -995,6 +1236,7 @@ Many integrations included in `ddtrace` support distributed tracing. Distributed
995
1236
 
996
1237
  For more details on how to activate distributed tracing for integrations, see their documentation:
997
1238
 
1239
+ - [Excon](#excon)
998
1240
  - [Faraday](#faraday)
999
1241
  - [Net/HTTP](#nethttp)
1000
1242
  - [Rack](#rack)
@@ -1024,6 +1266,30 @@ Datadog.tracer.trace('web.work') do |span|
1024
1266
  end
1025
1267
  ```
1026
1268
 
1269
+ ### HTTP request queuing
1270
+
1271
+ Traces that originate from HTTP requests can be configured to include the time spent in a frontend web server or load balancer queue, before the request reaches the Ruby application.
1272
+
1273
+ This functionality is **experimental** and deactivated by default.
1274
+
1275
+ To activate this feature, you must add a ``X-Request-Start`` or ``X-Queue-Start`` header from your web server (i.e. Nginx). The following is an Nginx configuration example:
1276
+
1277
+ ```
1278
+ # /etc/nginx/conf.d/ruby_service.conf
1279
+ server {
1280
+ listen 8080;
1281
+
1282
+ location / {
1283
+ proxy_set_header X-Request-Start "t=${msec}";
1284
+ proxy_pass http://web:3000;
1285
+ }
1286
+ }
1287
+ ```
1288
+
1289
+ Then you must enable the request queuing feature in the integration handling the request.
1290
+
1291
+ For Rack based applications, see the [documentation](#rack) for details for enabling this feature.
1292
+
1027
1293
  ### Processing Pipeline
1028
1294
 
1029
1295
  Some applications might require that traces be altered or filtered out before they are sent upstream. The processing pipeline allows users to create *processors* to define such behavior.