ddtrace 0.40.0 → 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +148 -130
  3. data/.circleci/images/primary/Dockerfile-3.0.0 +73 -0
  4. data/.github/workflows/add-milestone-to-pull-requests.yml +42 -0
  5. data/.github/workflows/create-next-milestone.yml +20 -0
  6. data/.simplecov +3 -0
  7. data/Appraisals +414 -135
  8. data/CHANGELOG.md +1112 -342
  9. data/CONTRIBUTING.md +2 -2
  10. data/Gemfile +4 -2
  11. data/README.md +1 -0
  12. data/Rakefile +231 -29
  13. data/ddtrace.gemspec +8 -8
  14. data/docker-compose.yml +30 -0
  15. data/docs/DevelopmentGuide.md +12 -2
  16. data/docs/GettingStarted.md +187 -16
  17. data/lib/ddtrace.rb +10 -0
  18. data/lib/ddtrace/auto_instrument.rb +3 -0
  19. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  20. data/lib/ddtrace/buffer.rb +259 -52
  21. data/lib/ddtrace/configuration.rb +19 -0
  22. data/lib/ddtrace/configuration/options.rb +3 -1
  23. data/lib/ddtrace/configuration/settings.rb +9 -3
  24. data/lib/ddtrace/context.rb +18 -0
  25. data/lib/ddtrace/context_provider.rb +17 -5
  26. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  27. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  28. data/lib/ddtrace/contrib/action_view/event.rb +0 -4
  29. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  30. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  31. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  32. data/lib/ddtrace/contrib/active_record/events/sql.rb +4 -0
  33. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  34. data/lib/ddtrace/contrib/active_record/utils.rb +67 -21
  35. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +104 -3
  36. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +21 -0
  37. data/lib/ddtrace/contrib/active_support/ext.rb +3 -0
  38. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  39. data/lib/ddtrace/contrib/active_support/notifications/event.rb +10 -0
  40. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -2
  41. data/lib/ddtrace/contrib/auto_instrument.rb +48 -0
  42. data/lib/ddtrace/contrib/aws/instrumentation.rb +6 -1
  43. data/lib/ddtrace/contrib/aws/patcher.rb +0 -1
  44. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  45. data/lib/ddtrace/contrib/configurable.rb +2 -0
  46. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +6 -5
  47. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +38 -0
  48. data/lib/ddtrace/contrib/cucumber/ext.rb +19 -0
  49. data/lib/ddtrace/contrib/cucumber/formatter.rb +104 -0
  50. data/lib/ddtrace/contrib/cucumber/instrumentation.rb +24 -0
  51. data/lib/ddtrace/contrib/cucumber/integration.rb +45 -0
  52. data/lib/ddtrace/contrib/cucumber/patcher.rb +23 -0
  53. data/lib/ddtrace/contrib/dalli/instrumentation.rb +4 -0
  54. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
  55. data/lib/ddtrace/contrib/delayed_job/ext.rb +2 -0
  56. data/lib/ddtrace/contrib/delayed_job/plugin.rb +39 -15
  57. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +4 -0
  58. data/lib/ddtrace/contrib/ethon/easy_patch.rb +10 -7
  59. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  60. data/lib/ddtrace/contrib/ethon/multi_patch.rb +4 -0
  61. data/lib/ddtrace/contrib/excon/middleware.rb +11 -1
  62. data/lib/ddtrace/contrib/extensions.rb +27 -1
  63. data/lib/ddtrace/contrib/faraday/middleware.rb +4 -0
  64. data/lib/ddtrace/contrib/faraday/patcher.rb +1 -1
  65. data/lib/ddtrace/contrib/grape/configuration/settings.rb +7 -0
  66. data/lib/ddtrace/contrib/grape/endpoint.rb +53 -18
  67. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  68. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +5 -1
  69. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -0
  70. data/lib/ddtrace/contrib/http/instrumentation.rb +6 -2
  71. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  72. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  73. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +152 -0
  74. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  75. data/lib/ddtrace/contrib/httpclient/patcher.rb +35 -0
  76. data/lib/ddtrace/contrib/httprb/instrumentation.rb +6 -3
  77. data/lib/ddtrace/contrib/kafka/event.rb +1 -1
  78. data/lib/ddtrace/contrib/mongodb/subscribers.rb +4 -0
  79. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +4 -0
  80. data/lib/ddtrace/contrib/patchable.rb +18 -7
  81. data/lib/ddtrace/contrib/presto/instrumentation.rb +3 -0
  82. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  83. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  84. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  85. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  86. data/lib/ddtrace/contrib/qless/qless_job.rb +72 -0
  87. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +32 -0
  88. data/lib/ddtrace/contrib/que/configuration/settings.rb +1 -0
  89. data/lib/ddtrace/contrib/que/tracer.rb +2 -1
  90. data/lib/ddtrace/contrib/racecar/event.rb +4 -0
  91. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  92. data/lib/ddtrace/contrib/rack/middlewares.rb +1 -1
  93. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  94. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  95. data/lib/ddtrace/contrib/rails/patcher.rb +19 -5
  96. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  97. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  98. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
  99. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  100. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  101. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  102. data/lib/ddtrace/contrib/redis/quantize.rb +27 -0
  103. data/lib/ddtrace/contrib/redis/tags.rb +9 -1
  104. data/lib/ddtrace/contrib/resque/configuration/settings.rb +1 -0
  105. data/lib/ddtrace/contrib/resque/integration.rb +1 -1
  106. data/lib/ddtrace/contrib/resque/resque_job.rb +1 -1
  107. data/lib/ddtrace/contrib/rest_client/request_patch.rb +4 -0
  108. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +38 -0
  109. data/lib/ddtrace/contrib/rspec/example.rb +61 -0
  110. data/lib/ddtrace/contrib/rspec/example_group.rb +61 -0
  111. data/lib/ddtrace/contrib/rspec/ext.rb +19 -0
  112. data/lib/ddtrace/contrib/rspec/integration.rb +46 -0
  113. data/lib/ddtrace/contrib/rspec/patcher.rb +25 -0
  114. data/lib/ddtrace/contrib/sequel/database.rb +3 -1
  115. data/lib/ddtrace/contrib/sequel/dataset.rb +3 -2
  116. data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
  117. data/lib/ddtrace/contrib/sequel/utils.rb +16 -5
  118. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
  119. data/lib/ddtrace/contrib/shoryuken/tracer.rb +4 -1
  120. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +1 -0
  121. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +4 -1
  122. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +2 -2
  123. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +1 -0
  124. data/lib/ddtrace/contrib/sneakers/tracer.rb +17 -20
  125. data/lib/ddtrace/contrib/status_code_matcher.rb +67 -0
  126. data/lib/ddtrace/ext/app_types.rb +1 -0
  127. data/lib/ddtrace/ext/ci.rb +297 -0
  128. data/lib/ddtrace/ext/distributed.rb +8 -2
  129. data/lib/ddtrace/ext/git.rb +11 -0
  130. data/lib/ddtrace/ext/integration.rb +8 -0
  131. data/lib/ddtrace/ext/runtime.rb +2 -0
  132. data/lib/ddtrace/ext/test.rb +24 -0
  133. data/lib/ddtrace/opentracer/distributed_headers.rb +1 -1
  134. data/lib/ddtrace/propagation/grpc_propagator.rb +18 -6
  135. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  136. data/lib/ddtrace/runtime/identity.rb +4 -5
  137. data/lib/ddtrace/runtime/metrics.rb +6 -2
  138. data/lib/ddtrace/sampler.rb +2 -2
  139. data/lib/ddtrace/sampling/rate_limiter.rb +65 -16
  140. data/lib/ddtrace/span.rb +152 -27
  141. data/lib/ddtrace/tracer.rb +25 -13
  142. data/lib/ddtrace/transport/http/adapters/net.rb +8 -2
  143. data/lib/ddtrace/transport/http/statistics.rb +14 -1
  144. data/lib/ddtrace/transport/traces.rb +7 -2
  145. data/lib/ddtrace/utils.rb +16 -13
  146. data/lib/ddtrace/utils/forking.rb +52 -0
  147. data/lib/ddtrace/version.rb +1 -1
  148. data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
  149. data/lib/ddtrace/writer.rb +19 -1
  150. metadata +111 -19
@@ -41,23 +41,22 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency 'opentracing', '>= 0.4.1'
42
42
 
43
43
  # Development dependencies
44
+ spec.add_development_dependency 'concurrent-ruby' # Leave it open as we also have it as an integration and want Appraisal to control the version under test.
44
45
  spec.add_development_dependency 'rake', '>= 10.5'
45
46
  spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
46
47
  spec.add_development_dependency 'rspec', '~> 3.0'
47
48
  spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
49
+ spec.add_development_dependency 'ruby-prof', '~> 1.4' if RUBY_PLATFORM != 'java' && RUBY_VERSION >= '2.4.0'
48
50
  spec.add_development_dependency 'minitest', '= 5.10.1'
49
51
  spec.add_development_dependency 'minitest-around', '0.5.0'
50
52
  spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
53
+ spec.add_development_dependency 'pimpmychangelog', '>= 0.1.2'
51
54
  spec.add_development_dependency 'appraisal', '~> 2.2'
52
55
  spec.add_development_dependency 'yard', '~> 0.9'
53
- spec.add_development_dependency 'webmock', '~> 2.0'
56
+ spec.add_development_dependency 'webmock', '>= 3.10.0'
54
57
  spec.add_development_dependency 'builder'
55
- if RUBY_PLATFORM != 'java'
56
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
57
- else
58
- spec.add_development_dependency 'jdbc-sqlite3', '~> 3'
59
- end
60
58
  spec.add_development_dependency 'climate_control', '~> 0.2.0'
59
+ spec.add_development_dependency 'rspec_junit_formatter', '>= 0.4.1'
61
60
 
62
61
  # locking transitive dependency of webmock
63
62
  spec.add_development_dependency 'addressable', '~> 2.4.0'
@@ -65,8 +64,9 @@ Gem::Specification.new do |spec|
65
64
  spec.add_development_dependency 'benchmark-memory', '~> 0.1'
66
65
  spec.add_development_dependency 'memory_profiler', '~> 0.9'
67
66
  spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
68
- spec.add_development_dependency 'pry', '~> 0.10.4'
69
- spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
67
+ spec.add_development_dependency 'pry', '~> 0.12.2'
68
+ spec.add_development_dependency 'pry-nav', '~> 0.3.0'
69
+ spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9' if RUBY_PLATFORM != 'java'
70
70
  spec.add_development_dependency 'simplecov', '~> 0.17'
71
71
  spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
72
72
  end
@@ -248,6 +248,34 @@ services:
248
248
  - .:/app
249
249
  - bundle-2.7:/usr/local/bundle
250
250
  - gemfiles-2.7:/app/gemfiles
251
+ tracer-3.0:
252
+ image: marcotc/docker-library:ddtrace_rb_3.0.0
253
+ command: /bin/bash
254
+ depends_on:
255
+ - ddagent
256
+ - elasticsearch
257
+ - memcached
258
+ - mongodb
259
+ - mysql
260
+ - postgres
261
+ - redis
262
+ env_file: ./.env
263
+ environment:
264
+ - BUNDLE_GEMFILE=/app/Gemfile
265
+ - DD_AGENT_HOST=ddagent
266
+ - TEST_DATADOG_INTEGRATION=1
267
+ - TEST_ELASTICSEARCH_HOST=elasticsearch
268
+ - TEST_MEMCACHED_HOST=memcached
269
+ - TEST_MONGODB_HOST=mongodb
270
+ - TEST_MYSQL_HOST=mysql
271
+ - TEST_POSTGRES_HOST=postgres
272
+ - TEST_REDIS_HOST=redis
273
+ stdin_open: true
274
+ tty: true
275
+ volumes:
276
+ - .:/app
277
+ - bundle-3.0:/usr/local/bundle
278
+ - gemfiles-3.0:/app/gemfiles
251
279
  # JRuby
252
280
  tracer-jruby-9.2:
253
281
  image: marcotc/docker-library:ddtrace_rb_jruby_9_2
@@ -358,6 +386,7 @@ volumes:
358
386
  bundle-2.5:
359
387
  bundle-2.6:
360
388
  bundle-2.7:
389
+ bundle-3.0:
361
390
  bundle-jruby-9.2:
362
391
  gemfiles-2.0:
363
392
  gemfiles-2.1:
@@ -367,4 +396,5 @@ volumes:
367
396
  gemfiles-2.5:
368
397
  gemfiles-2.6:
369
398
  gemfiles-2.7:
399
+ gemfiles-3.0:
370
400
  gemfiles-jruby-9.2:
@@ -124,6 +124,16 @@ The trace library uses Rubocop to enforce [code style](https://github.com/bbatso
124
124
  $ bundle exec rake rubocop
125
125
  ```
126
126
 
127
+ ### Running benchmarks
128
+
129
+ If your changes can have a measurable performance impact, we recommend running our benchmark suite:
130
+
131
+ ```
132
+ $ bundle exec rake spec:benchmark
133
+ ```
134
+
135
+ Results are printed to STDOUT as well as written to the `./tmp/benchmark/` directory.
136
+
127
137
  ## Appendix
128
138
 
129
139
  ### Writing new integrations
@@ -141,9 +151,9 @@ To get started quickly, it's perfectly fine to copy-paste an existing integratio
141
151
 
142
152
  Once you have it working in your application, you can [add unit tests](#writing-tests), [run them locally](#running-tests), and [check for code quality](#checking-code-quality) using Docker Compose.
143
153
 
144
- Then [open a pull request](https://github.com/DataDog/dd-trace-rb/CONTRIBUTING.md#have-a-patch) and be sure to add the following to the description:
154
+ Then [open a pull request](../CONTRIBUTING.md#have-a-patch) and be sure to add the following to the description:
145
155
 
146
- - [Documentation](https://github.com/DataDog/dd-trace-rb/docs/GettingStarted.md) for the integration, including versions supported.
156
+ - [Documentation](./GettingStarted.md) for the integration, including versions supported.
147
157
  - Links to the repository/website of the library being integrated
148
158
  - Screenshots showing a sample trace
149
159
  - Any additional code snippets, sample apps, benchmarks, or other resources that demonstrate its implementation are a huge plus!
@@ -34,6 +34,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
34
34
  - [Active Support](#active-support)
35
35
  - [AWS](#aws)
36
36
  - [Concurrent Ruby](#concurrent-ruby)
37
+ - [Cucumber](#cucumber)
37
38
  - [Dalli](#dalli)
38
39
  - [DelayedJob](#delayedjob)
39
40
  - [Elasticsearch](#elasticsearch)
@@ -44,10 +45,12 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
44
45
  - [GraphQL](#graphql)
45
46
  - [gRPC](#grpc)
46
47
  - [http.rb](#http-rb)
48
+ - [httpclient](#httpclient)
47
49
  - [MongoDB](#mongodb)
48
50
  - [MySQL2](#mysql2)
49
51
  - [Net/HTTP](#net-http)
50
52
  - [Presto](#presto)
53
+ - [Qless](#qless)
51
54
  - [Que](#que)
52
55
  - [Racecar](#racecar)
53
56
  - [Rack](#rack)
@@ -56,6 +59,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
56
59
  - [Redis](#redis)
57
60
  - [Rest Client](#rest-client)
58
61
  - [Resque](#resque)
62
+ - [RSpec](#rspec)
59
63
  - [Shoryuken](#shoryuken)
60
64
  - [Sequel](#sequel)
61
65
  - [Sidekiq](#sidekiq)
@@ -85,7 +89,8 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
85
89
 
86
90
  | Type | Documentation | Version | Support type | Gem version support |
87
91
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
88
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
92
+ | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
93
+ | | | 2.7 | Full | Latest |
89
94
  | | | 2.6 | Full | Latest |
90
95
  | | | 2.5 | Full | Latest |
91
96
  | | | 2.4 | Full | Latest |
@@ -123,14 +128,38 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
123
128
 
124
129
  The following steps will help you quickly start tracing your Ruby application.
125
130
 
126
- ### Setup the Datadog Agent
131
+ ### Configure the Datadog Agent for APM
127
132
 
128
133
  Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
129
134
 
130
- [Install and configure the Datadog Agent](https://docs.datadoghq.com/tracing/setup), see additional documentation for [tracing Docker applications](https://docs.datadoghq.com/tracing/setup/docker/).
135
+ Install and configure the Datadog Agent to receive traces from your now instrumented application. By default the Datadog Agent is enabled in your `datadog.yaml` file under `apm_enabled: true` and listens for trace traffic at `localhost:8126`. For containerized environments, follow the steps below to enable trace collection within the Datadog Agent.
136
+
137
+ #### Containers
138
+
139
+ 1. Set `apm_non_local_traffic: true` in your main [`datadog.yaml` configuration file](https://docs.datadoghq.com/agent/guide/agent-configuration-files/#agent-main-configuration-file).
140
+
141
+ 2. See the specific setup instructions for [Docker](https://docs.datadoghq.com/agent/docker/apm/?tab=ruby), [Kubernetes](https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm), [Amazon ECS](https://docs.datadoghq.com/agent/amazon_ecs/apm/?tab=ruby) or [Fargate](https://docs.datadoghq.com/integrations/ecs_fargate/#trace-collection) to ensure that the Agent is configured to receive traces in a containerized environment:
142
+
143
+ 3. After having instrumented your application, the tracing client sends traces to `localhost:8126` by default. If this is not the correct host and port change it by setting the env variables `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
144
+
131
145
 
132
146
  ### Quickstart for Rails applications
133
147
 
148
+ #### Rails Auto Instrument all Integrations
149
+
150
+ 1. Add the `ddtrace` gem to your Gemfile:
151
+
152
+ ```ruby
153
+ source 'https://rubygems.org'
154
+ gem 'ddtrace', require: 'ddtrace/auto_instrument'
155
+ ```
156
+
157
+ 2. Install the gem with `bundle install`
158
+
159
+ 3. You can configure, override, or disable any specific integration settings by also adding a [Rails Manual Configuration](#rails-manual-configuration) file.
160
+
161
+ #### Rails Manual Configuration
162
+
134
163
  1. Add the `ddtrace` gem to your Gemfile:
135
164
 
136
165
  ```ruby
@@ -152,6 +181,25 @@ Before downloading tracing on your application, install the Datadog Agent. The R
152
181
 
153
182
  ### Quickstart for Ruby applications
154
183
 
184
+ #### Ruby Auto Instrument all Integrations
185
+
186
+ 1. Install the gem with `gem install ddtrace`
187
+ 2. Requiring any [supported libraries or frameworks](#integration-instrumentation) that should be instrumented.
188
+ 3. Add `require 'ddtrace/auto_instrument'` to your application. _Note:_ This must be done _after_ requiring any supported libraries or frameworks.
189
+
190
+ ```ruby
191
+ # Example frameworks and libraries
192
+ require 'sinatra'
193
+ require 'faraday'
194
+ require 'redis'
195
+
196
+ require 'ddtrace/auto_instrument'
197
+ ```
198
+
199
+ You can configure, override, or disable any specific integration settings by also adding a [Ruby Manual Configuration Block](#ruby-manual-configuration).
200
+
201
+ #### Ruby Manual Configuration
202
+
155
203
  1. Install the gem with `gem install ddtrace`
156
204
  2. Add a configuration block to your Ruby application:
157
205
 
@@ -226,7 +274,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
226
274
  | `resource` | `String` | Name of the resource or action being operated on. Traces with the same resource value will be grouped together for the purpose of metrics (but still independently viewable.) Usually domain specific, such as a URL, query, request, etc. (e.g. `'Article#submit'`, `http://example.com/articles/list`.) | `name` of Span. |
227
275
  | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
228
276
  | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
229
- | `start_time` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
277
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
230
278
  | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
231
279
  | `on_error` | `Proc` | Handler invoked when a block is provided to trace, and it raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
232
280
 
@@ -338,6 +386,7 @@ For a list of available integrations, and their configuration options, please re
338
386
  | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
339
387
  | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
340
388
  | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
389
+ | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
341
390
  | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
342
391
  | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
343
392
  | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
@@ -348,19 +397,22 @@ For a list of available integrations, and their configuration options, please re
348
397
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
349
398
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
350
399
  | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
400
+ | httpclient | `httpclient` | `>= 2.2` | `>= 2.2` | *[Link](#httpclient)* | *[Link](https://github.com/nahi/httpclient)* |
351
401
  | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
352
402
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
353
403
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
354
404
  | Net/HTTP | `http` | *(Any supported Ruby)* | *(Any supported Ruby)* | *[Link](#nethttp)* | *[Link](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html)* |
355
405
  | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
406
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
356
407
  | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
357
408
  | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
358
409
  | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
359
410
  | Rails | `rails` | `>= 3.0` | `>= 3.0` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
360
411
  | Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
361
412
  | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
362
- | Resque | `resque` | `>= 1.0, < 2.0` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
413
+ | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
363
414
  | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
415
+ | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
364
416
  | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
365
417
  | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
366
418
  | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
@@ -590,6 +642,42 @@ Where `options` is an optional `Hash` that accepts the following parameters:
590
642
  | --- | ----------- | ------- |
591
643
  | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
592
644
 
645
+ ### Cucumber
646
+
647
+ Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
648
+
649
+ To activate your integration, use the `Datadog.configure` method:
650
+
651
+ ```ruby
652
+ require 'cucumber'
653
+ require 'ddtrace'
654
+
655
+ # Configure default Cucumber integration
656
+ Datadog.configure do |c|
657
+ c.use :cucumber, options
658
+ end
659
+
660
+ # Example of how to attach tags from scenario to active span
661
+ Around do |scenario, block|
662
+ active_span = Datadog.configuration[:cucumber][:tracer].active_span
663
+ unless active_span.nil?
664
+ scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
665
+ active_span.set_tag(*tag.name.split(':', 2))
666
+ end
667
+ end
668
+ block.call
669
+ end
670
+ ```
671
+
672
+ Where `options` is an optional `Hash` that accepts the following parameters:
673
+
674
+ | Key | Description | Default |
675
+ | --- | ----------- | ------- |
676
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
677
+ | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
678
+ | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
679
+ | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
680
+
593
681
  ### Dalli
594
682
 
595
683
  Dalli integration will trace all calls to your `memcached` server:
@@ -617,7 +705,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
617
705
 
618
706
  ### DelayedJob
619
707
 
620
- The DelayedJob integration uses lifecycle hooks to trace the job executions.
708
+ The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
621
709
 
622
710
  You can enable it through `Datadog.configure`:
623
711
 
@@ -635,6 +723,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
635
723
  | --- | ----------- | ------- |
636
724
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
637
725
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
726
+ | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
727
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
638
728
 
639
729
  ### Elasticsearch
640
730
 
@@ -815,6 +905,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
815
905
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
816
906
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
817
907
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
908
+ | `error_statuses`| Defines a status code or range of status codes which should be marked as errors. `'404,405,500-599'` or `[404,405,'500-599']` | `nil` |
818
909
 
819
910
  ### GraphQL
820
911
 
@@ -962,6 +1053,32 @@ Where `options` is an optional `Hash` that accepts the following parameters:
962
1053
  | `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
963
1054
  | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
964
1055
 
1056
+ ### httpclient
1057
+
1058
+ The httpclient integration will trace any HTTP call using the httpclient gem.
1059
+
1060
+ ```ruby
1061
+ require 'http'
1062
+ require 'ddtrace'
1063
+ Datadog.configure do |c|
1064
+ c.use :httpclient, options
1065
+ # optionally, specify a different service name for hostnames matching a regex
1066
+ c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
1067
+ httpclient.service_name = 'user.example.com'
1068
+ httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
1069
+ end
1070
+ end
1071
+ ```
1072
+
1073
+ Where `options` is an optional `Hash` that accepts the following parameters:
1074
+
1075
+ | Key | Description | Default |
1076
+ | --- | ----------- | ------- |
1077
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1078
+ | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1079
+ | `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
1080
+ | `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
1081
+
965
1082
  ### Kafka
966
1083
 
967
1084
  The Kafka integration provides tracing of the `ruby-kafka` gem:
@@ -1112,6 +1229,29 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1112
1229
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1113
1230
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1114
1231
 
1232
+ ### Qless
1233
+
1234
+ The Qless integration uses lifecycle hooks to trace job executions.
1235
+
1236
+ To add tracing to a Qless job:
1237
+
1238
+ ```ruby
1239
+ require 'ddtrace'
1240
+
1241
+ Datadog.configure do |c|
1242
+ c.use :qless, options
1243
+ end
1244
+ ```
1245
+
1246
+ Where `options` is an optional `Hash` that accepts the following parameters:
1247
+
1248
+ | Key | Description | Default |
1249
+ | --- | ----------- | ------- |
1250
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1251
+ | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1252
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1253
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1254
+
1115
1255
  ### Que
1116
1256
 
1117
1257
  The Que integration is a middleware which will trace job executions.
@@ -1135,6 +1275,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1135
1275
  | `service_name` | Service name used for `que` instrumentation | `'que'` |
1136
1276
  | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1137
1277
  | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1278
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1138
1279
 
1139
1280
  ### Racecar
1140
1281
 
@@ -1188,7 +1329,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1188
1329
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1189
1330
  | `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 | `true` |
1190
1331
  | `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'] }` |
1191
- | `middleware_names` | Enable this if you want to use the middleware classes as the resource names for `rack` spans. Requires `application` option to use. | `false` |
1332
+ | `middleware_names` | Enable this if you want to use the last executed middleware class as the resource name for the `rack` span. If enabled alongside the `rails` instrumention, `rails` takes precedence by setting the `rack` resource name to the active `rails` controller when applicable. Requires `application` option to use. | `false` |
1192
1333
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1193
1334
  | `quantize.query` | Hash containing options for query portion of URL quantization. May include `:show` or `:exclude`. See options below. Option must be nested inside the `quantize` option. | `{}` |
1194
1335
  | `quantize.query.show` | Defines which values should always be shown. Shows no values by default. May be an Array of strings, or `:all` to show all values. Option must be nested inside the `query` option. | `nil` |
@@ -1267,8 +1408,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1267
1408
  | 2.1 | | 3.0 - 4.2 |
1268
1409
  | 2.2 - 2.3 | | 3.0 - 5.2 |
1269
1410
  | 2.4 | | 4.2.8 - 5.2 |
1270
- | 2.5 | | 4.2.8 - 6.0 |
1271
- | 2.6 - 2.7 | 9.2 | 5.0 - 6.0 |
1411
+ | 2.5 | | 4.2.8 - 6.1 |
1412
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1413
+ | 3.0 | | 6.1 |
1272
1414
 
1273
1415
  ### Rake
1274
1416
 
@@ -1358,6 +1500,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1358
1500
  | --- | ----------- | ------- |
1359
1501
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1360
1502
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1503
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1361
1504
 
1362
1505
  You can also set *per-instance* configuration as it follows:
1363
1506
 
@@ -1435,6 +1578,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1435
1578
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1436
1579
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1437
1580
  | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1581
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1438
1582
 
1439
1583
  ### Rest Client
1440
1584
 
@@ -1457,6 +1601,31 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1457
1601
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1458
1602
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1459
1603
 
1604
+ ### RSpec
1605
+
1606
+ RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1607
+
1608
+ To activate your integration, use the `Datadog.configure` method:
1609
+
1610
+ ```ruby
1611
+ require 'rspec'
1612
+ require 'ddtrace'
1613
+
1614
+ # Configure default RSpec integration
1615
+ Datadog.configure do |c|
1616
+ c.use :rspec, options
1617
+ end
1618
+ ```
1619
+
1620
+ Where `options` is an optional `Hash` that accepts the following parameters:
1621
+
1622
+ | Key | Description | Default |
1623
+ | --- | ----------- | ------- |
1624
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
1625
+ | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1626
+ | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1627
+ | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1628
+
1460
1629
  ### Sequel
1461
1630
 
1462
1631
  The Sequel integration traces queries made to your database.
@@ -1525,6 +1694,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1525
1694
  | --- | ----------- | ------- |
1526
1695
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1527
1696
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1697
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1528
1698
 
1529
1699
  ### Sidekiq
1530
1700
 
@@ -1548,6 +1718,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1548
1718
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1549
1719
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1550
1720
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1721
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1551
1722
 
1552
1723
  ### Sinatra
1553
1724
 
@@ -1635,6 +1806,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1635
1806
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1636
1807
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1637
1808
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1809
+ | `error_handler` | Custom error handler invoked when a job raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { |span, error| span.set_error(error) unless span.nil? }` |
1638
1810
 
1639
1811
  ### Sucker Punch
1640
1812
 
@@ -1915,6 +2087,7 @@ For more details on how to activate distributed tracing for integrations, see th
1915
2087
  - [Rails](#rails)
1916
2088
  - [Sinatra](#sinatra)
1917
2089
  - [http.rb](#http-rb)
2090
+ - [httpclient](#httpclient)
1918
2091
 
1919
2092
  **Using the HTTP propagator**
1920
2093
 
@@ -1943,9 +2116,7 @@ end
1943
2116
 
1944
2117
  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.
1945
2118
 
1946
- This functionality is **experimental** and deactivated by default.
1947
-
1948
- To activate this feature, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
2119
+ This feature is disabled by default. To activate it, you must add an `X-Request-Start` or `X-Queue-Start` header from your web server (i.e., Nginx). The following is an Nginx configuration example:
1949
2120
 
1950
2121
  ```
1951
2122
  # /etc/nginx/conf.d/ruby_service.conf
@@ -1959,9 +2130,7 @@ server {
1959
2130
  }
1960
2131
  ```
1961
2132
 
1962
- Then you must enable the request queuing feature in the integration handling the request.
1963
-
1964
- For Rack-based applications, see the [documentation](#rack) for details for enabling this feature.
2133
+ Then you must enable the request queuing feature, by setting `request_queuing: true`, in the integration handling the request. For Rack-based applications, see the [documentation](#rack) for details.
1965
2134
 
1966
2135
  ### Processing Pipeline
1967
2136
 
@@ -2045,9 +2214,11 @@ Datadog.configure do |c|
2045
2214
  end
2046
2215
  ```
2047
2216
 
2217
+ _Note:_ For `lograge` users who have also defined `lograge.custom_options` in an `initializers/lograge.rb` configuration file, due to the order that Rails loads initializers (alphabetical), automatic trace correlation may not take effect, since `initializers/datadog.rb` would be overwritten by the `initializers/lograge.rb` initializer. To support automatic trace correlation with _existing_ `lograge.custom_options`, use the [Manual (Lograge)](#manual-lograge) configuration below.
2218
+
2048
2219
  ##### Manual (Lograge)
2049
2220
 
2050
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
2221
+ After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), manually modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs.
2051
2222
 
2052
2223
  ```ruby
2053
2224
  config.lograge.custom_options = lambda do |event|