ddtrace 0.41.0 → 0.46.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +223 -126
- data/.circleci/images/primary/Dockerfile-3.0.0 +73 -0
- data/.github/workflows/add-milestone-to-pull-requests.yml +42 -0
- data/.github/workflows/create-next-milestone.yml +20 -0
- data/.rubocop.yml +250 -7
- data/.rubocop_todo.yml +396 -0
- data/.simplecov +3 -0
- data/Appraisals +429 -135
- data/CHANGELOG.md +1158 -354
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +40 -3
- data/README.md +1 -0
- data/Rakefile +236 -29
- data/ddtrace.gemspec +4 -35
- data/docker-compose.yml +30 -0
- data/docs/DevelopmentGuide.md +40 -2
- data/docs/GettingStarted.md +186 -16
- data/integration/README.md +68 -0
- data/integration/apps/rack/.dockerignore +1 -0
- data/integration/apps/rack/.envrc.sample +1 -0
- data/integration/apps/rack/.gitignore +4 -0
- data/integration/apps/rack/.rspec +1 -0
- data/integration/apps/rack/Dockerfile +25 -0
- data/integration/apps/rack/Dockerfile-ci +11 -0
- data/integration/apps/rack/Gemfile +24 -0
- data/integration/apps/rack/README.md +93 -0
- data/integration/apps/rack/app/acme.rb +80 -0
- data/integration/apps/rack/app/datadog.rb +17 -0
- data/integration/apps/rack/bin/run +22 -0
- data/integration/apps/rack/bin/setup +17 -0
- data/integration/apps/rack/bin/test +24 -0
- data/integration/apps/rack/config.ru +6 -0
- data/integration/apps/rack/config/puma.rb +14 -0
- data/integration/apps/rack/config/unicorn.rb +23 -0
- data/integration/apps/rack/docker-compose.ci.yml +62 -0
- data/integration/apps/rack/docker-compose.yml +78 -0
- data/integration/apps/rack/script/build-images +38 -0
- data/integration/apps/rack/script/ci +50 -0
- data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rack/spec/spec_helper.rb +16 -0
- data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/.dockerignore +1 -0
- data/integration/apps/rails-five/.env +3 -0
- data/integration/apps/rails-five/.envrc.sample +1 -0
- data/integration/apps/rails-five/.gitignore +30 -0
- data/integration/apps/rails-five/Dockerfile +25 -0
- data/integration/apps/rails-five/Dockerfile-ci +11 -0
- data/integration/apps/rails-five/Gemfile +104 -0
- data/integration/apps/rails-five/README.md +94 -0
- data/integration/apps/rails-five/Rakefile +6 -0
- data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
- data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
- data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
- data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
- data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
- data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
- data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
- data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
- data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
- data/integration/apps/rails-five/app/models/application_record.rb +3 -0
- data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/models/test.rb +2 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
- data/integration/apps/rails-five/bin/bundle +3 -0
- data/integration/apps/rails-five/bin/rails +9 -0
- data/integration/apps/rails-five/bin/rake +9 -0
- data/integration/apps/rails-five/bin/run +24 -0
- data/integration/apps/rails-five/bin/setup +27 -0
- data/integration/apps/rails-five/bin/spring +17 -0
- data/integration/apps/rails-five/bin/test +21 -0
- data/integration/apps/rails-five/bin/update +28 -0
- data/integration/apps/rails-five/config.ru +5 -0
- data/integration/apps/rails-five/config/application.rb +97 -0
- data/integration/apps/rails-five/config/boot.rb +4 -0
- data/integration/apps/rails-five/config/cable.yml +10 -0
- data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
- data/integration/apps/rails-five/config/database.yml +28 -0
- data/integration/apps/rails-five/config/environment.rb +5 -0
- data/integration/apps/rails-five/config/environments/development.rb +51 -0
- data/integration/apps/rails-five/config/environments/production.rb +82 -0
- data/integration/apps/rails-five/config/environments/test.rb +43 -0
- data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
- data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
- data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
- data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
- data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
- data/integration/apps/rails-five/config/locales/en.yml +33 -0
- data/integration/apps/rails-five/config/puma.rb +24 -0
- data/integration/apps/rails-five/config/routes.rb +11 -0
- data/integration/apps/rails-five/config/spring.rb +6 -0
- data/integration/apps/rails-five/config/unicorn.rb +29 -0
- data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
- data/integration/apps/rails-five/db/schema.rb +23 -0
- data/integration/apps/rails-five/db/seeds.rb +7 -0
- data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
- data/integration/apps/rails-five/docker-compose.yml +100 -0
- data/integration/apps/rails-five/lib/tasks/.keep +0 -0
- data/integration/apps/rails-five/log/.keep +0 -0
- data/integration/apps/rails-five/public/robots.txt +1 -0
- data/integration/apps/rails-five/script/build-images +35 -0
- data/integration/apps/rails-five/script/ci +50 -0
- data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
- data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/storage/.keep +0 -0
- data/integration/apps/rails-five/tmp/.keep +0 -0
- data/integration/apps/rails-five/vendor/.keep +0 -0
- data/integration/apps/ruby/.dockerignore +1 -0
- data/integration/apps/ruby/.envrc.sample +1 -0
- data/integration/apps/ruby/.gitignore +2 -0
- data/integration/apps/ruby/Dockerfile +25 -0
- data/integration/apps/ruby/Dockerfile-ci +11 -0
- data/integration/apps/ruby/Gemfile +11 -0
- data/integration/apps/ruby/README.md +70 -0
- data/integration/apps/ruby/agent.yaml +3 -0
- data/integration/apps/ruby/app/datadog.rb +13 -0
- data/integration/apps/ruby/app/fibonacci.rb +58 -0
- data/integration/apps/ruby/bin/run +20 -0
- data/integration/apps/ruby/bin/setup +17 -0
- data/integration/apps/ruby/bin/test +21 -0
- data/integration/apps/ruby/docker-compose.ci.yml +51 -0
- data/integration/apps/ruby/docker-compose.yml +63 -0
- data/integration/apps/ruby/script/build-images +38 -0
- data/integration/apps/ruby/script/ci +50 -0
- data/integration/images/agent/Dockerfile +2 -0
- data/integration/images/agent/agent.yaml +3 -0
- data/integration/images/include/datadog/analyzer.rb +71 -0
- data/integration/images/include/datadog/demo_env.rb +101 -0
- data/integration/images/include/http-health-check +33 -0
- data/integration/images/ruby/2.0/Dockerfile +54 -0
- data/integration/images/ruby/2.1/Dockerfile +54 -0
- data/integration/images/ruby/2.2/Dockerfile +54 -0
- data/integration/images/ruby/2.3/Dockerfile +70 -0
- data/integration/images/ruby/2.4/Dockerfile +54 -0
- data/integration/images/ruby/2.5/Dockerfile +54 -0
- data/integration/images/ruby/2.6/Dockerfile +54 -0
- data/integration/images/ruby/2.7/Dockerfile +54 -0
- data/integration/images/ruby/3.0/Dockerfile +54 -0
- data/integration/images/wrk/Dockerfile +33 -0
- data/integration/images/wrk/scripts/entrypoint.sh +17 -0
- data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
- data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
- data/integration/script/build-images +43 -0
- data/lib/ddtrace.rb +10 -5
- data/lib/ddtrace/analytics.rb +2 -0
- data/lib/ddtrace/auto_instrument.rb +3 -0
- data/lib/ddtrace/auto_instrument_base.rb +6 -0
- data/lib/ddtrace/buffer.rb +230 -134
- data/lib/ddtrace/configuration.rb +21 -5
- data/lib/ddtrace/configuration/base.rb +1 -1
- data/lib/ddtrace/configuration/components.rb +2 -2
- data/lib/ddtrace/configuration/option_definition.rb +1 -3
- data/lib/ddtrace/configuration/options.rb +2 -3
- data/lib/ddtrace/configuration/settings.rb +21 -5
- data/lib/ddtrace/context.rb +23 -6
- data/lib/ddtrace/context_provider.rb +18 -5
- data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
- data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
- data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_view/event.rb +1 -5
- data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
- data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
- data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
- data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +17 -5
- data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
- data/lib/ddtrace/contrib/active_record/utils.rb +68 -21
- data/lib/ddtrace/contrib/active_support/cache/instrumentation.rb +104 -3
- data/lib/ddtrace/contrib/active_support/cache/patcher.rb +21 -0
- data/lib/ddtrace/contrib/active_support/ext.rb +3 -0
- data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +12 -1
- data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
- data/lib/ddtrace/contrib/auto_instrument.rb +49 -0
- data/lib/ddtrace/contrib/aws/instrumentation.rb +2 -1
- data/lib/ddtrace/contrib/aws/patcher.rb +1 -1
- data/lib/ddtrace/contrib/aws/services.rb +2 -0
- data/lib/ddtrace/contrib/configurable.rb +2 -0
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +6 -8
- data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +28 -0
- data/lib/ddtrace/contrib/cucumber/ext.rb +17 -0
- data/lib/ddtrace/contrib/cucumber/formatter.rb +98 -0
- data/lib/ddtrace/contrib/cucumber/instrumentation.rb +24 -0
- data/lib/ddtrace/contrib/cucumber/integration.rb +45 -0
- data/lib/ddtrace/contrib/cucumber/patcher.rb +23 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
- data/lib/ddtrace/contrib/delayed_job/configuration/settings.rb +2 -0
- data/lib/ddtrace/contrib/delayed_job/ext.rb +2 -0
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +38 -15
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +11 -10
- data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
- data/lib/ddtrace/contrib/excon/middleware.rb +9 -7
- data/lib/ddtrace/contrib/extensions.rb +28 -1
- data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
- data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
- data/lib/ddtrace/contrib/grape/configuration/settings.rb +7 -0
- data/lib/ddtrace/contrib/grape/endpoint.rb +47 -21
- data/lib/ddtrace/contrib/grape/ext.rb +1 -0
- data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/client.rb +1 -1
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
- data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
- data/lib/ddtrace/contrib/http/instrumentation.rb +7 -7
- data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
- data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
- data/lib/ddtrace/contrib/httpclient/instrumentation.rb +151 -0
- data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
- data/lib/ddtrace/contrib/httpclient/patcher.rb +35 -0
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +5 -6
- data/lib/ddtrace/contrib/kafka/event.rb +1 -1
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
- data/lib/ddtrace/contrib/patchable.rb +18 -7
- data/lib/ddtrace/contrib/patcher.rb +1 -1
- data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
- data/lib/ddtrace/contrib/qless/ext.rb +20 -0
- data/lib/ddtrace/contrib/qless/integration.rb +38 -0
- data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
- data/lib/ddtrace/contrib/qless/qless_job.rb +73 -0
- data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +33 -0
- data/lib/ddtrace/contrib/que/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/que/ext.rb +19 -19
- data/lib/ddtrace/contrib/que/tracer.rb +3 -2
- data/lib/ddtrace/contrib/racecar/event.rb +1 -0
- data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
- data/lib/ddtrace/contrib/rack/integration.rb +7 -0
- data/lib/ddtrace/contrib/rack/middlewares.rb +6 -11
- data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
- data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
- data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
- data/lib/ddtrace/contrib/rails/patcher.rb +19 -5
- data/lib/ddtrace/contrib/rails/utils.rb +4 -0
- data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
- data/lib/ddtrace/contrib/rake/integration.rb +1 -1
- data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
- data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
- data/lib/ddtrace/contrib/redis/ext.rb +1 -0
- data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
- data/lib/ddtrace/contrib/redis/quantize.rb +28 -0
- data/lib/ddtrace/contrib/redis/tags.rb +5 -1
- data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
- data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
- data/lib/ddtrace/contrib/registry.rb +2 -2
- data/lib/ddtrace/contrib/resque/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/resque/integration.rb +1 -1
- data/lib/ddtrace/contrib/resque/resque_job.rb +3 -1
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
- data/lib/ddtrace/contrib/rspec/configuration/settings.rb +28 -0
- data/lib/ddtrace/contrib/rspec/example.rb +75 -0
- data/lib/ddtrace/contrib/rspec/ext.rb +16 -0
- data/lib/ddtrace/contrib/rspec/integration.rb +46 -0
- data/lib/ddtrace/contrib/rspec/patcher.rb +23 -0
- data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
- data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +3 -1
- data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +5 -7
- data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
- data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +5 -5
- data/lib/ddtrace/contrib/sneakers/configuration/settings.rb +1 -0
- data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
- data/lib/ddtrace/contrib/sneakers/tracer.rb +16 -21
- data/lib/ddtrace/contrib/status_code_matcher.rb +69 -0
- data/lib/ddtrace/correlation.rb +1 -0
- data/lib/ddtrace/diagnostics/environment_logger.rb +2 -1
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
- data/lib/ddtrace/ext/app_types.rb +1 -0
- data/lib/ddtrace/ext/ci.rb +297 -0
- data/lib/ddtrace/ext/distributed.rb +8 -2
- data/lib/ddtrace/ext/git.rb +11 -0
- data/lib/ddtrace/ext/http.rb +1 -1
- data/lib/ddtrace/ext/runtime.rb +2 -1
- data/lib/ddtrace/ext/test.rb +24 -0
- data/lib/ddtrace/forced_tracing.rb +2 -0
- data/lib/ddtrace/logger.rb +1 -1
- data/lib/ddtrace/metrics.rb +10 -6
- data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
- data/lib/ddtrace/opentracer/span.rb +2 -6
- data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
- data/lib/ddtrace/patcher.rb +2 -3
- data/lib/ddtrace/pin.rb +3 -52
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/propagation/grpc_propagator.rb +17 -4
- data/lib/ddtrace/propagation/http_propagator.rb +17 -2
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +1 -1
- data/lib/ddtrace/runtime/container.rb +2 -2
- data/lib/ddtrace/runtime/identity.rb +4 -5
- data/lib/ddtrace/sampler.rb +1 -1
- data/lib/ddtrace/sampling/rate_limiter.rb +65 -16
- data/lib/ddtrace/sampling/rule_sampler.rb +1 -0
- data/lib/ddtrace/span.rb +7 -7
- data/lib/ddtrace/sync_writer.rb +7 -10
- data/lib/ddtrace/tracer.rb +23 -10
- data/lib/ddtrace/transport/http.rb +1 -3
- data/lib/ddtrace/transport/http/adapters/net.rb +9 -4
- data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
- data/lib/ddtrace/transport/http/builder.rb +2 -0
- data/lib/ddtrace/transport/http/traces.rb +2 -3
- data/lib/ddtrace/transport/io.rb +1 -1
- data/lib/ddtrace/transport/traces.rb +3 -0
- data/lib/ddtrace/utils.rb +10 -11
- data/lib/ddtrace/utils/forking.rb +52 -0
- data/lib/ddtrace/utils/time.rb +25 -1
- data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace/workers.rb +5 -0
- data/lib/ddtrace/workers/async.rb +8 -0
- data/lib/ddtrace/workers/loop.rb +3 -0
- data/lib/ddtrace/workers/polling.rb +1 -0
- data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
- data/lib/ddtrace/workers/trace_writer.rb +9 -10
- data/lib/ddtrace/writer.rb +22 -4
- metadata +168 -358
- data/lib/ddtrace/augmentation.rb +0 -13
- data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
- data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
- data/lib/ddtrace/augmentation/shim.rb +0 -102
- data/lib/ddtrace/monkey.rb +0 -58
data/ddtrace.gemspec
CHANGED
@@ -33,41 +33,10 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ['lib']
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
# Optional extensions
|
39
|
-
# TODO: Move this to Appraisals?
|
40
|
-
spec.add_development_dependency 'dogstatsd-ruby', '>= 3.3.0'
|
41
|
-
spec.add_development_dependency 'opentracing', '>= 0.4.1'
|
42
|
-
|
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.
|
45
|
-
spec.add_development_dependency 'rake', '>= 10.5'
|
46
|
-
spec.add_development_dependency 'rubocop', '= 0.49.1' if RUBY_VERSION >= '2.1.0'
|
47
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
48
|
-
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
|
49
|
-
spec.add_development_dependency 'minitest', '= 5.10.1'
|
50
|
-
spec.add_development_dependency 'minitest-around', '0.5.0'
|
51
|
-
spec.add_development_dependency 'minitest-stub_any_instance', '1.0.2'
|
52
|
-
spec.add_development_dependency 'appraisal', '~> 2.2'
|
53
|
-
spec.add_development_dependency 'yard', '~> 0.9'
|
54
|
-
spec.add_development_dependency 'webmock', '~> 2.0'
|
55
|
-
spec.add_development_dependency 'builder'
|
56
|
-
if RUBY_PLATFORM != 'java'
|
57
|
-
spec.add_development_dependency 'sqlite3', '~> 1.3.6'
|
36
|
+
if RUBY_VERSION >= '2.2.0'
|
37
|
+
spec.add_dependency 'msgpack'
|
58
38
|
else
|
59
|
-
|
39
|
+
# msgpack 1.4 fails for Ruby 2.0 and 2.1: https://github.com/msgpack/msgpack-ruby/issues/205
|
40
|
+
spec.add_dependency 'msgpack', '< 1.4'
|
60
41
|
end
|
61
|
-
spec.add_development_dependency 'climate_control', '~> 0.2.0'
|
62
|
-
|
63
|
-
# locking transitive dependency of webmock
|
64
|
-
spec.add_development_dependency 'addressable', '~> 2.4.0'
|
65
|
-
spec.add_development_dependency 'benchmark-ips', '~> 2.8'
|
66
|
-
spec.add_development_dependency 'benchmark-memory', '~> 0.1'
|
67
|
-
spec.add_development_dependency 'memory_profiler', '~> 0.9'
|
68
|
-
spec.add_development_dependency 'redcarpet', '~> 3.4' if RUBY_PLATFORM != 'java'
|
69
|
-
spec.add_development_dependency 'pry', '~> 0.10.4'
|
70
|
-
spec.add_development_dependency 'pry-stack_explorer', '~> 0.4.9.2'
|
71
|
-
spec.add_development_dependency 'simplecov', '~> 0.17'
|
72
|
-
spec.add_development_dependency 'warning', '~> 1' if RUBY_VERSION >= '2.5.0'
|
73
42
|
end
|
data/docker-compose.yml
CHANGED
@@ -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:
|
data/docs/DevelopmentGuide.md
CHANGED
@@ -114,6 +114,34 @@ Because you are likely not running all tests locally, your report will contain p
|
|
114
114
|
You *must* check the CI step `coverage` for the complete test coverage report, ensuring coverage is not
|
115
115
|
decreased.
|
116
116
|
|
117
|
+
**Ensuring tests don't leak resources**
|
118
|
+
|
119
|
+
Tests execution can create resources that are hard to track: threads, sockets, files, etc. Because these resources can come
|
120
|
+
from the both the test setup as well as the code under test, making sure all resources are properly disposed is important
|
121
|
+
to prevent the application from inadvertently creating cumulative resources during its execution.
|
122
|
+
|
123
|
+
When running tests that utilize threads, you might see an error message similar to this one:
|
124
|
+
|
125
|
+
```
|
126
|
+
Test leaked 1 thread: "Datadog::Workers::AsyncTransport integration tests"
|
127
|
+
Ensure all threads are terminated when test finishes:
|
128
|
+
1: #<Thread:0x00007fcbc99863d0 /Users/marco.costa/work/dd-trace-rb/spec/spec_helper.rb:145 sleep> (Thread)
|
129
|
+
Thread Creation Site:
|
130
|
+
./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'new'
|
131
|
+
./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:245:in 'block (4 levels) in <top (required)>'
|
132
|
+
Thread Backtrace:
|
133
|
+
./dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'sleep'
|
134
|
+
.dd-trace-rb/spec/ddtrace/workers_integration_spec.rb:262:in 'block (5 levels) in <top (required)>'
|
135
|
+
./dd-trace-rb/spec/spec_helper.rb:147:in 'block in initialize'
|
136
|
+
```
|
137
|
+
|
138
|
+
This means that this test did not finish all threads by the time the test had finished. In this case, the thread
|
139
|
+
creation can be traced to `workers_integration_spec.rb:245:in 'new'`. The thread itself is sleeping at `workers_integration_spec.rb:262:in 'sleep'`.
|
140
|
+
|
141
|
+
The actionable in this case would be to ensure that the thread created in `workers_integration_spec.rb:245` is properly terminated by invoking `Thread#join` during the test tear down, which will wait for the thread to finish before returning.
|
142
|
+
|
143
|
+
Depending on the situation, the thread in question might need to be forced to terminate. It's recommended to have a mechanism in place to terminate it (a shared variable that changes value when the thread should exit), but as a last resort, `Thread#terminate` forces the thread to finish. Keep in mind that regardless of the termination method, `Thread#join` must be called to ensure that the thread has completely finished its shutdown process.
|
144
|
+
|
117
145
|
### Checking code quality
|
118
146
|
|
119
147
|
**Linting**
|
@@ -124,6 +152,16 @@ The trace library uses Rubocop to enforce [code style](https://github.com/bbatso
|
|
124
152
|
$ bundle exec rake rubocop
|
125
153
|
```
|
126
154
|
|
155
|
+
### Running benchmarks
|
156
|
+
|
157
|
+
If your changes can have a measurable performance impact, we recommend running our benchmark suite:
|
158
|
+
|
159
|
+
```
|
160
|
+
$ bundle exec rake spec:benchmark
|
161
|
+
```
|
162
|
+
|
163
|
+
Results are printed to STDOUT as well as written to the `./tmp/benchmark/` directory.
|
164
|
+
|
127
165
|
## Appendix
|
128
166
|
|
129
167
|
### Writing new integrations
|
@@ -141,9 +179,9 @@ To get started quickly, it's perfectly fine to copy-paste an existing integratio
|
|
141
179
|
|
142
180
|
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
181
|
|
144
|
-
Then [open a pull request](
|
182
|
+
Then [open a pull request](../CONTRIBUTING.md#have-a-patch) and be sure to add the following to the description:
|
145
183
|
|
146
|
-
- [Documentation](
|
184
|
+
- [Documentation](./GettingStarted.md) for the integration, including versions supported.
|
147
185
|
- Links to the repository/website of the library being integrated
|
148
186
|
- Screenshots showing a sample trace
|
149
187
|
- Any additional code snippets, sample apps, benchmarks, or other resources that demonstrate its implementation are a huge plus!
|
data/docs/GettingStarted.md
CHANGED
@@ -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/ |
|
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
|
-
###
|
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
|
-
|
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
|
+
#### Automatic instrumentation
|
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
|
+
#### Manual instrumentation
|
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
|
+
#### Automatic instrumentation
|
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
|
+
#### Manual instrumentation
|
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` | `
|
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
|
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,41 @@ 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
|
+
| `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
677
|
+
| `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
|
678
|
+
| `operation_name` | Operation name used for `cucumber` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'cucumber.test'` |
|
679
|
+
|
593
680
|
### Dalli
|
594
681
|
|
595
682
|
Dalli integration will trace all calls to your `memcached` server:
|
@@ -617,7 +704,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
617
704
|
|
618
705
|
### DelayedJob
|
619
706
|
|
620
|
-
The DelayedJob integration uses lifecycle hooks to trace the job executions.
|
707
|
+
The DelayedJob integration uses lifecycle hooks to trace the job executions and enqueues.
|
621
708
|
|
622
709
|
You can enable it through `Datadog.configure`:
|
623
710
|
|
@@ -635,6 +722,8 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
635
722
|
| --- | ----------- | ------- |
|
636
723
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
637
724
|
| `service_name` | Service name used for `DelayedJob` instrumentation | `'delayed_job'` |
|
725
|
+
| `client_service_name` | Service name used for client-side `DelayedJob` instrumentation | `'delayed_job-client'` |
|
726
|
+
| `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
727
|
|
639
728
|
### Elasticsearch
|
640
729
|
|
@@ -815,6 +904,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
815
904
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `nil` |
|
816
905
|
| `enabled` | Defines whether Grape should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
817
906
|
| `service_name` | Service name used for `grape` instrumentation | `'grape'` |
|
907
|
+
| `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
908
|
|
819
909
|
### GraphQL
|
820
910
|
|
@@ -962,6 +1052,32 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
962
1052
|
| `service_name` | Service name for `httprb` instrumentation. | `'httprb'` |
|
963
1053
|
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
964
1054
|
|
1055
|
+
### httpclient
|
1056
|
+
|
1057
|
+
The httpclient integration will trace any HTTP call using the httpclient gem.
|
1058
|
+
|
1059
|
+
```ruby
|
1060
|
+
require 'httpclient'
|
1061
|
+
require 'ddtrace'
|
1062
|
+
Datadog.configure do |c|
|
1063
|
+
c.use :httpclient, options
|
1064
|
+
# optionally, specify a different service name for hostnames matching a regex
|
1065
|
+
c.use :httpclient, describes: /user-[^.]+\.example\.com/ do |httpclient|
|
1066
|
+
httpclient.service_name = 'user.example.com'
|
1067
|
+
httpclient.split_by_domain = false # Only necessary if split_by_domain is true by default
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
```
|
1071
|
+
|
1072
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
1073
|
+
|
1074
|
+
| Key | Description | Default |
|
1075
|
+
| --- | ----------- | ------- |
|
1076
|
+
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1077
|
+
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1078
|
+
| `service_name` | Service name for `httpclient` instrumentation. | `'httpclient'` |
|
1079
|
+
| `split_by_domain` | Uses the request domain as the service name when set to `true`. | `false` |
|
1080
|
+
|
965
1081
|
### Kafka
|
966
1082
|
|
967
1083
|
The Kafka integration provides tracing of the `ruby-kafka` gem:
|
@@ -1112,6 +1228,29 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1112
1228
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1113
1229
|
| `service_name` | Service name used for `presto` instrumentation | `'presto'` |
|
1114
1230
|
|
1231
|
+
### Qless
|
1232
|
+
|
1233
|
+
The Qless integration uses lifecycle hooks to trace job executions.
|
1234
|
+
|
1235
|
+
To add tracing to a Qless job:
|
1236
|
+
|
1237
|
+
```ruby
|
1238
|
+
require 'ddtrace'
|
1239
|
+
|
1240
|
+
Datadog.configure do |c|
|
1241
|
+
c.use :qless, options
|
1242
|
+
end
|
1243
|
+
```
|
1244
|
+
|
1245
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
1246
|
+
|
1247
|
+
| Key | Description | Default |
|
1248
|
+
| --- | ----------- | ------- |
|
1249
|
+
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to the global setting, `false` for off. | `false` |
|
1250
|
+
| `service_name` | Service name used for `qless` instrumentation | `'qless'` |
|
1251
|
+
| `tag_job_data` | Enable tagging with job arguments. true for on, false for off. | `false` |
|
1252
|
+
| `tag_job_tags` | Enable tagging with job tags. true for on, false for off. | `false` |
|
1253
|
+
|
1115
1254
|
### Que
|
1116
1255
|
|
1117
1256
|
The Que integration is a middleware which will trace job executions.
|
@@ -1135,6 +1274,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1135
1274
|
| `service_name` | Service name used for `que` instrumentation | `'que'` |
|
1136
1275
|
| `tag_args` | Enable tagging of a job's args field. `true` for on, `false` for off. | `false` |
|
1137
1276
|
| `tag_data` | Enable tagging of a job's data field. `true` for on, `false` for off. | `false` |
|
1277
|
+
| `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
1278
|
|
1139
1279
|
### Racecar
|
1140
1280
|
|
@@ -1188,7 +1328,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1188
1328
|
| `application` | Your Rack application. Required for `middleware_names`. | `nil` |
|
1189
1329
|
| `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
1330
|
| `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
|
1331
|
+
| `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
1332
|
| `quantize` | Hash containing options for quantization. May include `:query` or `:fragment`. | `{}` |
|
1193
1333
|
| `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
1334
|
| `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 +1407,9 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1267
1407
|
| 2.1 | | 3.0 - 4.2 |
|
1268
1408
|
| 2.2 - 2.3 | | 3.0 - 5.2 |
|
1269
1409
|
| 2.4 | | 4.2.8 - 5.2 |
|
1270
|
-
| 2.5 | | 4.2.8 - 6.
|
1271
|
-
| 2.6 - 2.7 | 9.2 | 5.0 - 6.
|
1410
|
+
| 2.5 | | 4.2.8 - 6.1 |
|
1411
|
+
| 2.6 - 2.7 | 9.2 | 5.0 - 6.1 |
|
1412
|
+
| 3.0 | | 6.1 |
|
1272
1413
|
|
1273
1414
|
### Rake
|
1274
1415
|
|
@@ -1358,6 +1499,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1358
1499
|
| --- | ----------- | ------- |
|
1359
1500
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1360
1501
|
| `service_name` | Service name used for `redis` instrumentation | `'redis'` |
|
1502
|
+
| `command_args` | Show the command arguments (e.g. `key` in `GET key`) as resource name and tag | true |
|
1361
1503
|
|
1362
1504
|
You can also set *per-instance* configuration as it follows:
|
1363
1505
|
|
@@ -1435,6 +1577,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1435
1577
|
| `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
1578
|
| `service_name` | Service name used for `resque` instrumentation | `'resque'` |
|
1437
1579
|
| `workers` | An array including all worker classes you want to trace (e.g. `[MyJob]`) | `[]` |
|
1580
|
+
| `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
1581
|
|
1439
1582
|
### Rest Client
|
1440
1583
|
|
@@ -1457,6 +1600,30 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1457
1600
|
| `distributed_tracing` | Enables [distributed tracing](#distributed-tracing) | `true` |
|
1458
1601
|
| `service_name` | Service name for `rest_client` instrumentation. | `'rest_client'` |
|
1459
1602
|
|
1603
|
+
### RSpec
|
1604
|
+
|
1605
|
+
RSpec integration will trace all executions of example groups and examples when using `rspec` test framework.
|
1606
|
+
|
1607
|
+
To activate your integration, use the `Datadog.configure` method:
|
1608
|
+
|
1609
|
+
```ruby
|
1610
|
+
require 'rspec'
|
1611
|
+
require 'ddtrace'
|
1612
|
+
|
1613
|
+
# Configure default RSpec integration
|
1614
|
+
Datadog.configure do |c|
|
1615
|
+
c.use :rspec, options
|
1616
|
+
end
|
1617
|
+
```
|
1618
|
+
|
1619
|
+
Where `options` is an optional `Hash` that accepts the following parameters:
|
1620
|
+
|
1621
|
+
| Key | Description | Default |
|
1622
|
+
| --- | ----------- | ------- |
|
1623
|
+
| `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1624
|
+
| `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
|
1625
|
+
| `operation_name` | Operation name used for `rspec` instrumentation. Useful if you want rename automatic trace metrics e.g. `trace.#{operation_name}.errors`. | `'rspec.example'` |
|
1626
|
+
|
1460
1627
|
### Sequel
|
1461
1628
|
|
1462
1629
|
The Sequel integration traces queries made to your database.
|
@@ -1525,6 +1692,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1525
1692
|
| --- | ----------- | ------- |
|
1526
1693
|
| `analytics_enabled` | Enable analytics for spans produced by this integration. `true` for on, `nil` to defer to global setting, `false` for off. | `false` |
|
1527
1694
|
| `service_name` | Service name used for `shoryuken` instrumentation | `'shoryuken'` |
|
1695
|
+
| `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
1696
|
|
1529
1697
|
### Sidekiq
|
1530
1698
|
|
@@ -1548,6 +1716,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1548
1716
|
| `client_service_name` | Service name used for client-side `sidekiq` instrumentation | `'sidekiq-client'` |
|
1549
1717
|
| `service_name` | Service name used for server-side `sidekiq` instrumentation | `'sidekiq'` |
|
1550
1718
|
| `tag_args` | Enable tagging of job arguments. `true` for on, `false` for off. | `false` |
|
1719
|
+
| `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
1720
|
|
1552
1721
|
### Sinatra
|
1553
1722
|
|
@@ -1635,6 +1804,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
|
|
1635
1804
|
| `enabled` | Defines whether Sneakers should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
1636
1805
|
| `service_name` | Service name used for `sneakers` instrumentation | `'sneakers'` |
|
1637
1806
|
| `tag_body` | Enable tagging of job message. `true` for on, `false` for off. | `false` |
|
1807
|
+
| `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
1808
|
|
1639
1809
|
### Sucker Punch
|
1640
1810
|
|
@@ -1692,6 +1862,7 @@ Available options are:
|
|
1692
1862
|
- `sampler`: set to a custom `Datadog::Sampler` instance. If provided, the tracer will use this sampler to determine sampling behavior.
|
1693
1863
|
- `diagnostics.startup_logs.enabled`: Startup configuration and diagnostic log. Defaults to `true`. Can be configured through the `DD_TRACE_STARTUP_LOGS` environment variable.
|
1694
1864
|
- `diagnostics.debug`: set to true to enable debug logging. Can be configured through the `DD_TRACE_DEBUG` environment variable. Defaults to `false`.
|
1865
|
+
- `time_now_provider`: when testing, it might be helpful to use a different time provider. For Timecop, for example, `->{ Time.now_without_mock_time }` allows the tracer to use the real wall time. Span duration calculation will still use the system monotonic clock when available, thus not being affected by this setting. Defaults to `->{ Time.now }`.
|
1695
1866
|
|
1696
1867
|
#### Custom logging
|
1697
1868
|
|
@@ -1915,6 +2086,7 @@ For more details on how to activate distributed tracing for integrations, see th
|
|
1915
2086
|
- [Rails](#rails)
|
1916
2087
|
- [Sinatra](#sinatra)
|
1917
2088
|
- [http.rb](#http-rb)
|
2089
|
+
- [httpclient](#httpclient)
|
1918
2090
|
|
1919
2091
|
**Using the HTTP propagator**
|
1920
2092
|
|
@@ -1943,9 +2115,7 @@ end
|
|
1943
2115
|
|
1944
2116
|
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
2117
|
|
1946
|
-
This
|
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:
|
2118
|
+
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
2119
|
|
1950
2120
|
```
|
1951
2121
|
# /etc/nginx/conf.d/ruby_service.conf
|
@@ -1959,9 +2129,7 @@ server {
|
|
1959
2129
|
}
|
1960
2130
|
```
|
1961
2131
|
|
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.
|
2132
|
+
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
2133
|
|
1966
2134
|
### Processing Pipeline
|
1967
2135
|
|
@@ -2045,9 +2213,11 @@ Datadog.configure do |c|
|
|
2045
2213
|
end
|
2046
2214
|
```
|
2047
2215
|
|
2216
|
+
_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.
|
2217
|
+
|
2048
2218
|
##### Manual (Lograge)
|
2049
2219
|
|
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.
|
2220
|
+
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
2221
|
|
2052
2222
|
```ruby
|
2053
2223
|
config.lograge.custom_options = lambda do |event|
|