ddtrace 0.39.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +142 -115
  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/.gitlab-ci.yml +1 -0
  7. data/.simplecov +41 -0
  8. data/Appraisals +476 -120
  9. data/CHANGELOG.md +1115 -325
  10. data/CONTRIBUTING.md +2 -2
  11. data/Gemfile +4 -2
  12. data/Rakefile +665 -477
  13. data/ddtrace.gemspec +8 -8
  14. data/docker-compose.yml +30 -0
  15. data/docs/DevelopmentGuide.md +28 -2
  16. data/docs/GettingStarted.md +170 -41
  17. data/lib/ddtrace.rb +4 -0
  18. data/lib/ddtrace/buffer.rb +259 -52
  19. data/lib/ddtrace/configuration.rb +55 -5
  20. data/lib/ddtrace/configuration/components.rb +4 -7
  21. data/lib/ddtrace/configuration/options.rb +3 -1
  22. data/lib/ddtrace/configuration/settings.rb +9 -3
  23. data/lib/ddtrace/context.rb +18 -0
  24. data/lib/ddtrace/context_provider.rb +17 -5
  25. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +0 -7
  26. data/lib/ddtrace/contrib/action_view/event.rb +0 -4
  27. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  28. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  29. data/lib/ddtrace/contrib/active_record/events/sql.rb +4 -0
  30. data/lib/ddtrace/contrib/active_record/utils.rb +11 -1
  31. data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +104 -3
  32. data/lib/ddtrace/contrib/active_support/cache/patcher.rb +21 -0
  33. data/lib/ddtrace/contrib/active_support/ext.rb +3 -0
  34. data/lib/ddtrace/contrib/active_support/notifications/event.rb +10 -0
  35. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +2 -2
  36. data/lib/ddtrace/contrib/aws/instrumentation.rb +6 -1
  37. data/lib/ddtrace/contrib/aws/patcher.rb +0 -1
  38. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  39. data/lib/ddtrace/contrib/configurable.rb +2 -0
  40. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +6 -5
  41. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +38 -0
  42. data/lib/ddtrace/contrib/cucumber/ext.rb +19 -0
  43. data/lib/ddtrace/contrib/cucumber/formatter.rb +104 -0
  44. data/lib/ddtrace/contrib/cucumber/instrumentation.rb +24 -0
  45. data/lib/ddtrace/contrib/cucumber/integration.rb +40 -0
  46. data/lib/ddtrace/contrib/cucumber/patcher.rb +23 -0
  47. data/lib/ddtrace/contrib/dalli/instrumentation.rb +4 -0
  48. data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
  49. data/lib/ddtrace/contrib/delayed_job/ext.rb +2 -0
  50. data/lib/ddtrace/contrib/delayed_job/plugin.rb +39 -15
  51. data/lib/ddtrace/contrib/elasticsearch/patcher.rb +4 -0
  52. data/lib/ddtrace/contrib/ethon/easy_patch.rb +5 -3
  53. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  54. data/lib/ddtrace/contrib/ethon/multi_patch.rb +4 -0
  55. data/lib/ddtrace/contrib/excon/middleware.rb +11 -1
  56. data/lib/ddtrace/contrib/faraday/middleware.rb +4 -0
  57. data/lib/ddtrace/contrib/faraday/patcher.rb +1 -1
  58. data/lib/ddtrace/contrib/grape/configuration/settings.rb +7 -0
  59. data/lib/ddtrace/contrib/grape/endpoint.rb +53 -18
  60. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  61. data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +5 -1
  62. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +4 -0
  63. data/lib/ddtrace/contrib/http/instrumentation.rb +6 -2
  64. data/lib/ddtrace/contrib/httprb/instrumentation.rb +6 -3
  65. data/lib/ddtrace/contrib/kafka/event.rb +1 -1
  66. data/lib/ddtrace/contrib/mongodb/subscribers.rb +4 -0
  67. data/lib/ddtrace/contrib/mysql2/instrumentation.rb +4 -0
  68. data/lib/ddtrace/contrib/presto/instrumentation.rb +3 -0
  69. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  70. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  71. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  72. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  73. data/lib/ddtrace/contrib/qless/qless_job.rb +72 -0
  74. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +32 -0
  75. data/lib/ddtrace/contrib/que/configuration/settings.rb +43 -0
  76. data/lib/ddtrace/contrib/que/ext.rb +30 -0
  77. data/lib/ddtrace/contrib/que/integration.rb +42 -0
  78. data/lib/ddtrace/contrib/que/patcher.rb +24 -0
  79. data/lib/ddtrace/contrib/que/tracer.rb +57 -0
  80. data/lib/ddtrace/contrib/racecar/event.rb +4 -0
  81. data/lib/ddtrace/contrib/racecar/events.rb +2 -0
  82. data/lib/ddtrace/contrib/racecar/events/consume.rb +27 -0
  83. data/lib/ddtrace/contrib/racecar/ext.rb +1 -0
  84. data/lib/ddtrace/contrib/rack/middlewares.rb +2 -0
  85. data/lib/ddtrace/contrib/rails/configuration/settings.rb +5 -0
  86. data/lib/ddtrace/contrib/rails/ext.rb +1 -0
  87. data/lib/ddtrace/contrib/rails/log_injection.rb +81 -0
  88. data/lib/ddtrace/contrib/rails/middlewares.rb +7 -2
  89. data/lib/ddtrace/contrib/rails/patcher.rb +29 -0
  90. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
  91. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  92. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  93. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  94. data/lib/ddtrace/contrib/redis/quantize.rb +27 -0
  95. data/lib/ddtrace/contrib/redis/tags.rb +9 -1
  96. data/lib/ddtrace/contrib/resque/configuration/settings.rb +1 -0
  97. data/lib/ddtrace/contrib/resque/integration.rb +1 -1
  98. data/lib/ddtrace/contrib/resque/resque_job.rb +1 -1
  99. data/lib/ddtrace/contrib/rest_client/request_patch.rb +4 -0
  100. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +38 -0
  101. data/lib/ddtrace/contrib/rspec/example.rb +61 -0
  102. data/lib/ddtrace/contrib/rspec/example_group.rb +61 -0
  103. data/lib/ddtrace/contrib/rspec/ext.rb +19 -0
  104. data/lib/ddtrace/contrib/rspec/integration.rb +41 -0
  105. data/lib/ddtrace/contrib/rspec/patcher.rb +25 -0
  106. data/lib/ddtrace/contrib/sequel/database.rb +3 -1
  107. data/lib/ddtrace/contrib/sequel/dataset.rb +3 -2
  108. data/lib/ddtrace/contrib/sequel/ext.rb +1 -0
  109. data/lib/ddtrace/contrib/sequel/utils.rb +16 -5
  110. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
  111. data/lib/ddtrace/contrib/shoryuken/tracer.rb +4 -1
  112. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +1 -0
  113. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +4 -1
  114. data/lib/ddtrace/contrib/sinatra/env.rb +5 -4
  115. data/lib/ddtrace/contrib/sinatra/tracer.rb +21 -42
  116. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +50 -23
  117. data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +1 -0
  118. data/lib/ddtrace/contrib/sneakers/tracer.rb +17 -20
  119. data/lib/ddtrace/contrib/status_code_matcher.rb +67 -0
  120. data/lib/ddtrace/ext/app_types.rb +1 -0
  121. data/lib/ddtrace/ext/ci.rb +264 -0
  122. data/lib/ddtrace/ext/distributed.rb +8 -2
  123. data/lib/ddtrace/ext/git.rb +12 -0
  124. data/lib/ddtrace/ext/integration.rb +8 -0
  125. data/lib/ddtrace/ext/runtime.rb +2 -0
  126. data/lib/ddtrace/ext/test.rb +24 -0
  127. data/lib/ddtrace/opentracer/distributed_headers.rb +1 -1
  128. data/lib/ddtrace/propagation/grpc_propagator.rb +18 -6
  129. data/lib/ddtrace/runtime/identity.rb +4 -5
  130. data/lib/ddtrace/runtime/metrics.rb +6 -2
  131. data/lib/ddtrace/sampler.rb +2 -2
  132. data/lib/ddtrace/sampling/rate_limiter.rb +65 -16
  133. data/lib/ddtrace/span.rb +152 -27
  134. data/lib/ddtrace/tracer.rb +25 -13
  135. data/lib/ddtrace/transport/http/adapters/net.rb +8 -2
  136. data/lib/ddtrace/transport/http/statistics.rb +14 -1
  137. data/lib/ddtrace/transport/traces.rb +7 -2
  138. data/lib/ddtrace/utils.rb +16 -13
  139. data/lib/ddtrace/utils/forking.rb +52 -0
  140. data/lib/ddtrace/version.rb +1 -1
  141. data/lib/ddtrace/workers/async.rb +2 -2
  142. data/lib/ddtrace/workers/loop.rb +1 -1
  143. data/lib/ddtrace/workers/polling.rb +1 -1
  144. data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
  145. data/lib/ddtrace/writer.rb +19 -1
  146. metadata +147 -42
@@ -41,22 +41,20 @@ 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'
61
59
 
62
60
  # locking transitive dependency of webmock
@@ -65,7 +63,9 @@ Gem::Specification.new do |spec|
65
63
  spec.add_development_dependency 'benchmark-memory', '~> 0.1'
66
64
  spec.add_development_dependency 'memory_profiler', '~> 0.9'
67
65
  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'
66
+ spec.add_development_dependency 'pry', '~> 0.12.2'
67
+ spec.add_development_dependency 'pry-nav', '~> 0.3.0'
68
+ spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9' if RUBY_PLATFORM != 'java'
69
+ spec.add_development_dependency 'simplecov', '~> 0.17'
70
70
  spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
71
71
  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:
@@ -98,6 +98,22 @@ $ bundle exec appraisal contrib rake spec:redis'[--seed,1234]'
98
98
 
99
99
  This can be useful for replicating conditions from CI or isolating certain tests.
100
100
 
101
+ **Checking test coverage**
102
+
103
+ You can check test code coverage by creating a report _after_ running a test suite:
104
+ ```
105
+ # Run the desired test suite
106
+ $ bundle exec appraisal contrib rake spec:redis
107
+ # Generate report for the suite executed
108
+ $ bundle exec rake coverage:report
109
+ ```
110
+
111
+ A webpage will be generated at `coverage/report/index.html` with the resulting report.
112
+
113
+ Because you are likely not running all tests locally, your report will contain partial coverage results.
114
+ You *must* check the CI step `coverage` for the complete test coverage report, ensuring coverage is not
115
+ decreased.
116
+
101
117
  ### Checking code quality
102
118
 
103
119
  **Linting**
@@ -108,6 +124,16 @@ The trace library uses Rubocop to enforce [code style](https://github.com/bbatso
108
124
  $ bundle exec rake rubocop
109
125
  ```
110
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
+
111
137
  ## Appendix
112
138
 
113
139
  ### Writing new integrations
@@ -125,9 +151,9 @@ To get started quickly, it's perfectly fine to copy-paste an existing integratio
125
151
 
126
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.
127
153
 
128
- 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:
129
155
 
130
- - [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.
131
157
  - Links to the repository/website of the library being integrated
132
158
  - Screenshots showing a sample trace
133
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)
@@ -43,11 +44,13 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
43
44
  - [Grape](#grape)
44
45
  - [GraphQL](#graphql)
45
46
  - [gRPC](#grpc)
46
- - [http.rb](#http.rb)
47
+ - [http.rb](#http-rb)
47
48
  - [MongoDB](#mongodb)
48
49
  - [MySQL2](#mysql2)
49
50
  - [Net/HTTP](#net-http)
50
51
  - [Presto](#presto)
52
+ - [Qless](#qless)
53
+ - [Que](#que)
51
54
  - [Racecar](#racecar)
52
55
  - [Rack](#rack)
53
56
  - [Rails](#rails)
@@ -55,6 +58,7 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
55
58
  - [Redis](#redis)
56
59
  - [Rest Client](#rest-client)
57
60
  - [Resque](#resque)
61
+ - [RSpec](#rspec)
58
62
  - [Shoryuken](#shoryuken)
59
63
  - [Sequel](#sequel)
60
64
  - [Sidekiq](#sidekiq)
@@ -84,7 +88,8 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
84
88
 
85
89
  | Type | Documentation | Version | Support type | Gem version support |
86
90
  | ----- | -------------------------- | ----- | ------------------------------------ | ------------------- |
87
- | MRI | https://www.ruby-lang.org/ | 2.7 | Full | Latest |
91
+ | MRI | https://www.ruby-lang.org/ | 3.0 | Full | Latest |
92
+ | | | 2.7 | Full | Latest |
88
93
  | | | 2.6 | Full | Latest |
89
94
  | | | 2.5 | Full | Latest |
90
95
  | | | 2.4 | Full | Latest |
@@ -92,8 +97,8 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
92
97
  | | | 2.2 | Full | Latest |
93
98
  | | | 2.1 | Full | Latest |
94
99
  | | | 2.0 | Full | Latest |
95
- | | | 1.9.3 | Maintenance (until August 6th, 2020) | < 0.27.0 |
96
- | | | 1.9.1 | Maintenance (until August 6th, 2020) | < 0.27.0 |
100
+ | | | 1.9.3 | EOL since August 6th, 2020 | < 0.27.0 |
101
+ | | | 1.9.1 | EOL since August 6th, 2020 | < 0.27.0 |
97
102
  | JRuby | https://www.jruby.org | 9.2 | Full | Latest |
98
103
 
99
104
  **Supported web servers**:
@@ -122,11 +127,20 @@ To contribute, check out the [contribution guidelines][contribution docs] and [d
122
127
 
123
128
  The following steps will help you quickly start tracing your Ruby application.
124
129
 
125
- ### Setup the Datadog Agent
130
+ ### Configure the Datadog Agent for APM
126
131
 
127
132
  Before downloading tracing on your application, install the Datadog Agent. The Ruby APM tracer sends trace data through the Datadog Agent.
128
133
 
129
- [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/).
134
+ 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.
135
+
136
+ #### Containers
137
+
138
+ 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).
139
+
140
+ 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:
141
+
142
+ 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`.
143
+
130
144
 
131
145
  ### Quickstart for Rails applications
132
146
 
@@ -225,7 +239,7 @@ And `options` is an optional `Hash` that accepts the following parameters:
225
239
  | `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. |
226
240
  | `span_type` | `String` | The type of the span (such as `'http'`, `'db'`, etc.) | `nil` |
227
241
  | `child_of` | `Datadog::Span` / `Datadog::Context` | Parent for this span. If not provided, will automatically become current active span. | `nil` |
228
- | `start_time` | `Integer` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now.utc` |
242
+ | `start_time` | `Time` | When the span actually starts. Useful when tracing events that have already happened. | `Time.now` |
229
243
  | `tags` | `Hash` | Extra tags which should be added to the span. | `{}` |
230
244
  | `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? }` |
231
245
 
@@ -337,6 +351,7 @@ For a list of available integrations, and their configuration options, please re
337
351
  | Active Support | `active_support` | `>= 3.0` | `>= 3.0` | *[Link](#active-support)* | *[Link](https://github.com/rails/rails/tree/master/activesupport)* |
338
352
  | AWS | `aws` | `>= 2.0` | `>= 2.0` | *[Link](#aws)* | *[Link](https://github.com/aws/aws-sdk-ruby)* |
339
353
  | Concurrent Ruby | `concurrent_ruby` | `>= 0.9` | `>= 0.9` | *[Link](#concurrent-ruby)* | *[Link](https://github.com/ruby-concurrency/concurrent-ruby)* |
354
+ | Cucumber | `cucumber` | `>= 3.0` | `>= 1.7.16` | *[Link](#cucumber)* | *[Link](https://github.com/cucumber/cucumber-ruby)* |
340
355
  | Dalli | `dalli` | `>= 2.0` | `>= 2.0` | *[Link](#dalli)* | *[Link](https://github.com/petergoldstein/dalli)* |
341
356
  | DelayedJob | `delayed_job` | `>= 4.1` | `>= 4.1` | *[Link](#delayedjob)* | *[Link](https://github.com/collectiveidea/delayed_job)* |
342
357
  | Elasticsearch | `elasticsearch` | `>= 1.0` | `>= 1.0` | *[Link](#elasticsearch)* | *[Link](https://github.com/elastic/elasticsearch-ruby)* |
@@ -346,19 +361,22 @@ For a list of available integrations, and their configuration options, please re
346
361
  | Grape | `grape` | `>= 1.0` | `>= 1.0` | *[Link](#grape)* | *[Link](https://github.com/ruby-grape/grape)* |
347
362
  | GraphQL | `graphql` | `>= 1.7.9` | `>= 1.7.9` | *[Link](#graphql)* | *[Link](https://github.com/rmosolgo/graphql-ruby)* |
348
363
  | gRPC | `grpc` | `>= 1.7` | *gem not available* | *[Link](#grpc)* | *[Link](https://github.com/grpc/grpc/tree/master/src/rubyc)* |
349
- | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http.rb)* | *[Link](https://github.com/httprb/http)* |
364
+ | http.rb | `httprb` | `>= 2.0` | `>= 2.0` | *[Link](#http-rb)* | *[Link](https://github.com/httprb/http)* |
350
365
  | Kafka | `ruby-kafka` | `>= 0.7.10` | `>= 0.7.10` | *[Link](#kafka)* | *[Link](https://github.com/zendesk/ruby-kafka)* |
351
366
  | MongoDB | `mongo` | `>= 2.1` | `>= 2.1` | *[Link](#mongodb)* | *[Link](https://github.com/mongodb/mongo-ruby-driver)* |
352
367
  | MySQL2 | `mysql2` | `>= 0.3.21` | *gem not available* | *[Link](#mysql2)* | *[Link](https://github.com/brianmario/mysql2)* |
353
368
  | 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)* |
354
369
  | Presto | `presto` | `>= 0.5.14` | `>= 0.5.14` | *[Link](#presto)* | *[Link](https://github.com/treasure-data/presto-client-ruby)* |
370
+ | Qless | `qless` | `>= 0.10.0` | `>= 0.10.0` | *[Link](#qless)* | *[Link](https://github.com/seomoz/qless)* |
371
+ | Que | `que` | `>= 1.0.0.beta2` | `>= 1.0.0.beta2` | *[Link](#que)* | *[Link](https://github.com/que-rb/que)* |
355
372
  | Racecar | `racecar` | `>= 0.3.5` | `>= 0.3.5` | *[Link](#racecar)* | *[Link](https://github.com/zendesk/racecar)* |
356
373
  | Rack | `rack` | `>= 1.1` | `>= 1.1` | *[Link](#rack)* | *[Link](https://github.com/rack/rack)* |
357
374
  | Rails | `rails` | `>= 3.0` | `>= 3.0` | *[Link](#rails)* | *[Link](https://github.com/rails/rails)* |
358
375
  | Rake | `rake` | `>= 12.0` | `>= 12.0` | *[Link](#rake)* | *[Link](https://github.com/ruby/rake)* |
359
376
  | Redis | `redis` | `>= 3.2` | `>= 3.2` | *[Link](#redis)* | *[Link](https://github.com/redis/redis-rb)* |
360
- | Resque | `resque` | `>= 1.0, < 2.0` | `>= 1.0, < 2.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
377
+ | Resque | `resque` | `>= 1.0` | `>= 1.0` | *[Link](#resque)* | *[Link](https://github.com/resque/resque)* |
361
378
  | Rest Client | `rest-client` | `>= 1.8` | `>= 1.8` | *[Link](#rest-client)* | *[Link](https://github.com/rest-client/rest-client)* |
379
+ | RSpec | `rspec`. | `>= 3.0.0` | `>= 3.0.0` | *[Link](#rspec)*. | *[Link](https://github.com/rspec/rspec)* |
362
380
  | Sequel | `sequel` | `>= 3.41` | `>= 3.41` | *[Link](#sequel)* | *[Link](https://github.com/jeremyevans/sequel)* |
363
381
  | Shoryuken | `shoryuken` | `>= 3.2` | `>= 3.2` | *[Link](#shoryuken)* | *[Link](https://github.com/phstc/shoryuken)* |
364
382
  | Sidekiq | `sidekiq` | `>= 3.5.4` | `>= 3.5.4` | *[Link](#sidekiq)* | *[Link](https://github.com/mperham/sidekiq)* |
@@ -588,6 +606,42 @@ Where `options` is an optional `Hash` that accepts the following parameters:
588
606
  | --- | ----------- | ------- |
589
607
  | `service_name` | Service name used for `concurrent-ruby` instrumentation | `'concurrent-ruby'` |
590
608
 
609
+ ### Cucumber
610
+
611
+ Cucumber integration will trace all executions of scenarios and steps when using `cucumber` framework.
612
+
613
+ To activate your integration, use the `Datadog.configure` method:
614
+
615
+ ```ruby
616
+ require 'cucumber'
617
+ require 'ddtrace'
618
+
619
+ # Configure default Cucumber integration
620
+ Datadog.configure do |c|
621
+ c.use :cucumber, options
622
+ end
623
+
624
+ # Example of how to attach tags from scenario to active span
625
+ Around do |scenario, block|
626
+ active_span = Datadog.configuration[:cucumber][:tracer].active_span
627
+ unless active_span.nil?
628
+ scenario.tags.filter { |tag| tag.include? ':' }.each do |tag|
629
+ active_span.set_tag(*tag.name.split(':', 2))
630
+ end
631
+ end
632
+ block.call
633
+ end
634
+ ```
635
+
636
+ Where `options` is an optional `Hash` that accepts the following parameters:
637
+
638
+ | Key | Description | Default |
639
+ | --- | ----------- | ------- |
640
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
641
+ | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
642
+ | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
643
+ | `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
644
+
591
645
  ### Dalli
592
646
 
593
647
  Dalli integration will trace all calls to your `memcached` server:
@@ -615,7 +669,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
615
669
 
616
670
  ### DelayedJob
617
671
 
618
- The DelayedJob integration uses lifecycle hooks to trace the job executions.
672
+ The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
619
673
 
620
674
  You can enable it through `Datadog.configure`:
621
675
 
@@ -633,6 +687,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
633
687
  | --- | ----------- | ------- |
634
688
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
635
689
  | `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
690
+ | `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
691
+ | `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? }` |
636
692
 
637
693
  ### Elasticsearch
638
694
 
@@ -813,6 +869,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
813
869
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
814
870
  | `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
815
871
  | `service_name` | Service name used for `grape` instrumentation | `'grape'` |
872
+ | `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` |
816
873
 
817
874
  ### GraphQL
818
875
 
@@ -1110,6 +1167,54 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1110
1167
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1111
1168
  | `service_name` | Service name used for `presto` instrumentation | `'presto'` |
1112
1169
 
1170
+ ### Qless
1171
+
1172
+ The Qless integration uses lifecycle hooks to trace job executions.
1173
+
1174
+ To add tracing to a Qless job:
1175
+
1176
+ ```ruby
1177
+ require 'ddtrace'
1178
+
1179
+ Datadog.configure do |c|
1180
+ c.use :qless, options
1181
+ end
1182
+ ```
1183
+
1184
+ Where `options` is an optional `Hash` that accepts the following parameters:
1185
+
1186
+ | Key | Description | Default |
1187
+ | --- | ----------- | ------- |
1188
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1189
+ | `service_name` | Service name used for `qless` instrumentation | `'qless'` |
1190
+ | `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
1191
+ | `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
1192
+
1193
+ ### Que
1194
+
1195
+ The Que integration is a middleware which will trace job executions.
1196
+
1197
+ You can enable it through `Datadog.configure`:
1198
+
1199
+ ```ruby
1200
+ require 'ddtrace'
1201
+
1202
+ Datadog.configure do |c|
1203
+ c.use :que, options
1204
+ end
1205
+ ```
1206
+
1207
+ Where `options` is an optional `Hash` that accepts the following parameters:
1208
+
1209
+ | Key | Description | Default |
1210
+ | --- | ----------- | ------- |
1211
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1212
+ | `enabled` | Defines whether Que should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1213
+ | `service_name` | Service name used for `que` instrumentation | `'que'` |
1214
+ | `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
1215
+ | `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
1216
+ | `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? }` |
1217
+
1113
1218
  ### Racecar
1114
1219
 
1115
1220
  The Racecar integration provides tracing for Racecar jobs.
@@ -1162,7 +1267,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1162
1267
  | `application` | Your Rack application. Required for `middleware_names`. | `nil` |
1163
1268
  | `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` |
1164
1269
  | `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'] }` |
1165
- | `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` |
1270
+ | `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` |
1166
1271
  | `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
1167
1272
  | `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. | `{}` |
1168
1273
  | `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` |
@@ -1172,7 +1277,6 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1172
1277
  | `service_name` | Service name used for `rack` instrumentation | `'rack'` |
1173
1278
  | `web_service_name` | Service name for frontend server request queuing spans. (e.g. `'nginx'`) | `'web-server'` |
1174
1279
 
1175
-
1176
1280
  **Configuring URL quantization behavior**
1177
1281
 
1178
1282
  ```ruby
@@ -1232,6 +1336,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1232
1336
  | `middleware_names` | Enables any short-circuited middleware requests to display the middleware name as a resource for the trace. | `false` |
1233
1337
  | `service_name` | Service name used when tracing application requests (on the `rack` level) | `'<app_name>'` (inferred from your Rails application namespace) |
1234
1338
  | `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/'` |
1339
+ | `log_injection` | Automatically enables injection [Trace Correlation](#trace-correlation) information, such as `dd.trace_id`, into Rails logs. Supports the default logger (`ActiveSupport::TaggedLogging`) and `Lograge`. Details on the format of Trace Correlation information can be found in the [Trace Correlation](#trace-correlation) section. | `false` |
1235
1340
 
1236
1341
  **Supported versions**
1237
1342
 
@@ -1241,8 +1346,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1241
1346
  | 2.1 | | 3.0 - 4.2 |
1242
1347
  | 2.2 - 2.3 | | 3.0 - 5.2 |
1243
1348
  | 2.4 | | 4.2.8 - 5.2 |
1244
- | 2.5 | | 4.2.8 - 6.0 |
1245
- | 2.6 - 2.7 | 9.2 | 5.0 - 6.0 |
1349
+ | 2.5 | | 4.2.8 - 6.1 |
1350
+ | 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
1351
+ | 3.0 | | 6.1 |
1246
1352
 
1247
1353
  ### Rake
1248
1354
 
@@ -1332,6 +1438,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1332
1438
  | --- | ----------- | ------- |
1333
1439
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1334
1440
  | `service_name` | Service name used for `redis` instrumentation | `'redis'` |
1441
+ | `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
1335
1442
 
1336
1443
  You can also set *per-instance* configuration as it follows:
1337
1444
 
@@ -1409,6 +1516,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1409
1516
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
1410
1517
  | `service_name` | Service name used for `resque` instrumentation | `'resque'` |
1411
1518
  | `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
1519
+ | `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? }` |
1412
1520
 
1413
1521
  ### Rest Client
1414
1522
 
@@ -1431,6 +1539,31 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1431
1539
  | `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
1432
1540
  | `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
1433
1541
 
1542
+ ### RSpec
1543
+
1544
+ RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
1545
+
1546
+ To activate your integration, use the `Datadog.configure` method:
1547
+
1548
+ ```ruby
1549
+ require 'rspec'
1550
+ require 'ddtrace'
1551
+
1552
+ # Configure default RSpec integration
1553
+ Datadog.configure do |c|
1554
+ c.use :rspec, options
1555
+ end
1556
+ ```
1557
+
1558
+ Where `options` is an optional `Hash` that accepts the following parameters:
1559
+
1560
+ | Key | Description | Default |
1561
+ | --- | ----------- | ------- |
1562
+ | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `true` |
1563
+ | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1564
+ | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
1565
+ | `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
1566
+
1434
1567
  ### Sequel
1435
1568
 
1436
1569
  The Sequel integration traces queries made to your database.
@@ -1499,6 +1632,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1499
1632
  | --- | ----------- | ------- |
1500
1633
  | `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
1501
1634
  | `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
1635
+ | `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? }` |
1502
1636
 
1503
1637
  ### Sidekiq
1504
1638
 
@@ -1522,6 +1656,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1522
1656
  | `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
1523
1657
  | `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
1524
1658
  | `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
1659
+ | `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? }` |
1525
1660
 
1526
1661
  ### Sinatra
1527
1662
 
@@ -1609,6 +1744,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1609
1744
  | `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1610
1745
  | `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
1611
1746
  | `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
1747
+ | `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? }` |
1612
1748
 
1613
1749
  ### Sucker Punch
1614
1750
 
@@ -1721,6 +1857,7 @@ Other Environment Variables:
1721
1857
  - `DD_TRACE_<INTEGRATION>_ENABLED`: Enables or disables an **activated** integration. Defaults to `true`.. e.g. `DD_TRACE_RAILS_ENABLED=false`. This option has no effects on integrations that have not been explicitly activated (e.g. `Datadog.configure{ |c| c.use :integration }`).on code. This environment variable can only be used to disable an integration.
1722
1858
  - `DD_TRACE_<INTEGRATION>_ANALYTICS_ENABLED`: Enables or disable App Analytics for a specific integration. Valid values are: true or false (default). e.g. `DD_TRACE_ACTION_CABLE_ANALYTICS_ENABLED=true`.
1723
1859
  - `DD_TRACE_<INTEGRATION>_ANALYTICS_SAMPLE_RATE`: Sets the App Analytics sampling rate for a specific integration. A floating number between 0.0 and 1.0 (default). e.g. `DD_TRACE_ACTION_CABLE_ANALYTICS_SAMPLE_RATE=0.5`.
1860
+ - `DD_LOGS_INJECTION`: Automatically enables injection [Trace Correlation](#trace-correlation) information, such as `dd.trace_id`, into Rails logs. Supports the default logger (`ActiveSupport::TaggedLogging`) and `Lograge`. Details on the format of Trace Correlation information can be found in the [Trace Correlation](#trace-correlation) section. Valid values are: `true` or `false`(default). e.g. `DD_LOGS_INJECTION=true`.
1724
1861
 
1725
1862
  ### Sampling
1726
1863
 
@@ -1887,7 +2024,7 @@ For more details on how to activate distributed tracing for integrations, see th
1887
2024
  - [Rack](#rack)
1888
2025
  - [Rails](#rails)
1889
2026
  - [Sinatra](#sinatra)
1890
- - [http.rb](#http.rb)
2027
+ - [http.rb](#http-rb)
1891
2028
 
1892
2029
  **Using the HTTP propagator**
1893
2030
 
@@ -2001,34 +2138,28 @@ Datadog::Pipeline.before_flush(
2001
2138
 
2002
2139
  ### Trace correlation
2003
2140
 
2004
- In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing. The tracer can produce a correlation identifier for the currently active trace via `active_correlation`, which can be used to decorate these other data sources.
2141
+ In many cases, such as logging, it may be useful to correlate trace IDs to other events or data streams, for easier cross-referencing.
2142
+
2143
+ #### For logging in Rails applications
2144
+
2145
+ ##### Automatic
2146
+
2147
+ For Rails applications using the default logger (`ActiveSupport::TaggedLogging`) or `lograge`, you can automatically enable trace correlation injection by setting the `rails` instrumentation configuration option `log_injection` to `true` or by setting environment variable `DD_LOGS_INJECTION=true`:
2005
2148
 
2006
2149
  ```ruby
2007
- # When a trace is active...
2008
- Datadog.tracer.trace('correlation.example') do
2009
- # Returns #<Datadog::Correlation::Identifier>
2010
- correlation = Datadog.tracer.active_correlation
2011
- correlation.trace_id # => 5963550561812073440
2012
- correlation.span_id # => 2232727802607726424
2013
- correlation.env # => 'production' (derived from DD_ENV)
2014
- correlation.service # => 'billing-api' (derived from DD_SERVICE)
2015
- correlation.version # => '2.5.17' (derived from DD_VERSION)
2016
- end
2150
+ # config/initializers/datadog.rb
2151
+ require 'ddtrace'
2017
2152
 
2018
- # When a trace isn't active...
2019
- correlation = Datadog.tracer.active_correlation
2020
- # Returns #<Datadog::Correlation::Identifier>
2021
- correlation = Datadog.tracer.active_correlation
2022
- correlation.trace_id # => 0
2023
- correlation.span_id # => 0
2024
- correlation.env # => 'production' (derived from DD_ENV)
2025
- correlation.service # => 'billing-api' (derived from DD_SERVICE)
2026
- correlation.version # => '2.5.17' (derived from DD_VERSION)
2153
+ Datadog.configure do |c|
2154
+ c.use :rails, log_injection: true
2155
+ end
2027
2156
  ```
2028
2157
 
2029
- #### For logging in Rails applications using Lograge (recommended)
2158
+ _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.
2159
+
2160
+ ##### Manual (Lograge)
2030
2161
 
2031
- After [setting up Lograge in a Rails application](https://docs.datadoghq.com/logs/log_collection/ruby/), modify the `custom_options` block in your environment configuration file (e.g. `config/environments/production.rb`) to add the trace IDs:
2162
+ 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.
2032
2163
 
2033
2164
  ```ruby
2034
2165
  config.lograge.custom_options = lambda do |event|
@@ -2051,11 +2182,9 @@ config.lograge.custom_options = lambda do |event|
2051
2182
  end
2052
2183
  ```
2053
2184
 
2054
- #### For logging in Rails applications
2055
-
2056
- Rails applications which are configured with an `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. The default Rails logger implements this tagged logging, making it easier to add correlation tags.
2185
+ ##### Manual (ActiveSupport::TaggedLogging)
2057
2186
 
2058
- In your Rails environment configuration file, add the following:
2187
+ Rails applications which are configured with the default `ActiveSupport::TaggedLogging` logger can append correlation IDs as tags to log output. To enable Trace Correlation with `ActiveSupport::TaggedLogging`, in your Rails environment configuration file, add the following:
2059
2188
 
2060
2189
  ```ruby
2061
2190
  Rails.application.configure do