ddtrace 0.44.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +183 -15
- data/.circleci/images/primary/Dockerfile-2.0.0 +11 -1
- data/.circleci/images/primary/Dockerfile-2.1.10 +11 -1
- data/.circleci/images/primary/Dockerfile-2.2.10 +11 -1
- data/.circleci/images/primary/Dockerfile-2.3.8 +10 -0
- data/.circleci/images/primary/Dockerfile-2.4.6 +10 -0
- data/.circleci/images/primary/Dockerfile-2.5.6 +10 -0
- data/.circleci/images/primary/Dockerfile-2.6.4 +10 -0
- data/.circleci/images/primary/Dockerfile-2.7.0 +10 -0
- data/.circleci/images/primary/Dockerfile-jruby-9.2-latest +88 -0
- data/.circleci/images/primary/{Dockerfile-jruby-9.2 → Dockerfile-jruby-9.2.0.0} +1 -5
- data/.circleci/images/primary/Dockerfile-truffleruby-21.0.0 +73 -0
- data/.github/workflows/create-next-milestone.yml +2 -2
- data/.gitlab-ci.yml +18 -18
- data/.rubocop.yml +269 -7
- data/.rubocop_todo.yml +438 -0
- data/.simplecov +6 -0
- data/Appraisals +87 -9
- data/CHANGELOG.md +238 -1
- data/Gemfile +63 -3
- data/LICENSE-3rdparty.csv +2 -0
- data/README.md +1 -0
- data/Rakefile +65 -25
- data/bin/ddtracerb +15 -0
- data/ddtrace.gemspec +9 -36
- data/docker-compose.yml +75 -7
- data/docs/DevelopmentGuide.md +28 -0
- data/docs/GettingStarted.md +162 -68
- data/docs/ProfilingDevelopment.md +88 -0
- data/integration/README.md +67 -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 +28 -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 +8 -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 +4 -4
- data/lib/ddtrace/configuration.rb +121 -26
- data/lib/ddtrace/configuration/base.rb +1 -1
- data/lib/ddtrace/configuration/components.rb +87 -5
- data/lib/ddtrace/configuration/option_definition.rb +1 -3
- data/lib/ddtrace/configuration/options.rb +4 -7
- data/lib/ddtrace/configuration/settings.rb +48 -3
- data/lib/ddtrace/context.rb +5 -6
- data/lib/ddtrace/context_provider.rb +0 -1
- 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 -1
- 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/makara_resolver.rb +30 -0
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +107 -18
- data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
- data/lib/ddtrace/contrib/active_record/utils.rb +57 -20
- data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -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/patcher.rb +1 -0
- data/lib/ddtrace/contrib/aws/services.rb +2 -0
- data/lib/ddtrace/contrib/configurable.rb +63 -39
- data/lib/ddtrace/contrib/configuration/resolver.rb +70 -5
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +19 -20
- data/lib/ddtrace/contrib/configuration/settings.rb +7 -6
- data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
- data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
- data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
- data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
- data/lib/ddtrace/contrib/elasticsearch/patcher.rb +1 -0
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +10 -9
- data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
- data/lib/ddtrace/contrib/extensions.rb +53 -3
- data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
- data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
- data/lib/ddtrace/contrib/grape/endpoint.rb +8 -15
- 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/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 +5 -5
- 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 +147 -0
- data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
- data/lib/ddtrace/contrib/httpclient/patcher.rb +38 -0
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +14 -20
- data/lib/ddtrace/contrib/httprb/patcher.rb +5 -2
- 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 +9 -6
- data/lib/ddtrace/contrib/presto/patcher.rb +5 -2
- data/lib/ddtrace/contrib/qless/qless_job.rb +1 -0
- data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +1 -0
- data/lib/ddtrace/contrib/que/ext.rb +19 -19
- data/lib/ddtrace/contrib/que/tracer.rb +1 -1
- 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 +6 -2
- 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 +11 -4
- data/lib/ddtrace/contrib/redis/quantize.rb +1 -0
- 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 +17 -1
- data/lib/ddtrace/contrib/resque/integration.rb +1 -1
- data/lib/ddtrace/contrib/resque/patcher.rb +4 -4
- data/lib/ddtrace/contrib/resque/resque_job.rb +24 -1
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
- data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/rspec/example.rb +24 -10
- data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
- data/lib/ddtrace/contrib/rspec/integration.rb +6 -1
- data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
- 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 +7 -4
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -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 +3 -3
- data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
- data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
- data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
- data/lib/ddtrace/correlation.rb +1 -0
- data/lib/ddtrace/diagnostics/environment_logger.rb +3 -2
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
- data/lib/ddtrace/error.rb +2 -0
- data/lib/ddtrace/ext/ci.rb +43 -10
- data/lib/ddtrace/ext/distributed.rb +1 -1
- data/lib/ddtrace/ext/git.rb +0 -1
- data/lib/ddtrace/ext/http.rb +1 -1
- data/lib/ddtrace/ext/profiling.rb +52 -0
- data/lib/ddtrace/ext/runtime.rb +3 -1
- data/lib/ddtrace/ext/transport.rb +1 -0
- data/lib/ddtrace/forced_tracing.rb +2 -0
- data/lib/ddtrace/logger.rb +1 -1
- data/lib/ddtrace/metrics.rb +14 -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 +25 -4
- data/lib/ddtrace/pin.rb +8 -61
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/profiling.rb +54 -0
- data/lib/ddtrace/profiling/backtrace_location.rb +32 -0
- data/lib/ddtrace/profiling/buffer.rb +41 -0
- data/lib/ddtrace/profiling/collectors/stack.rb +253 -0
- data/lib/ddtrace/profiling/encoding/profile.rb +31 -0
- data/lib/ddtrace/profiling/event.rb +13 -0
- data/lib/ddtrace/profiling/events/stack.rb +102 -0
- data/lib/ddtrace/profiling/exporter.rb +23 -0
- data/lib/ddtrace/profiling/ext/cpu.rb +54 -0
- data/lib/ddtrace/profiling/ext/cthread.rb +134 -0
- data/lib/ddtrace/profiling/ext/forking.rb +97 -0
- data/lib/ddtrace/profiling/flush.rb +41 -0
- data/lib/ddtrace/profiling/pprof/builder.rb +121 -0
- data/lib/ddtrace/profiling/pprof/converter.rb +85 -0
- data/lib/ddtrace/profiling/pprof/message_set.rb +12 -0
- data/lib/ddtrace/profiling/pprof/payload.rb +18 -0
- data/lib/ddtrace/profiling/pprof/pprof.proto +212 -0
- data/lib/ddtrace/profiling/pprof/pprof_pb.rb +81 -0
- data/lib/ddtrace/profiling/pprof/stack_sample.rb +90 -0
- data/lib/ddtrace/profiling/pprof/string_table.rb +10 -0
- data/lib/ddtrace/profiling/pprof/template.rb +114 -0
- data/lib/ddtrace/profiling/preload.rb +3 -0
- data/lib/ddtrace/profiling/profiler.rb +28 -0
- data/lib/ddtrace/profiling/recorder.rb +87 -0
- data/lib/ddtrace/profiling/scheduler.rb +84 -0
- data/lib/ddtrace/profiling/tasks/setup.rb +77 -0
- data/lib/ddtrace/profiling/transport/client.rb +12 -0
- data/lib/ddtrace/profiling/transport/http.rb +122 -0
- data/lib/ddtrace/profiling/transport/http/api.rb +43 -0
- data/lib/ddtrace/profiling/transport/http/api/endpoint.rb +90 -0
- data/lib/ddtrace/profiling/transport/http/api/instance.rb +36 -0
- data/lib/ddtrace/profiling/transport/http/api/spec.rb +40 -0
- data/lib/ddtrace/profiling/transport/http/builder.rb +28 -0
- data/lib/ddtrace/profiling/transport/http/client.rb +33 -0
- data/lib/ddtrace/profiling/transport/http/response.rb +21 -0
- data/lib/ddtrace/profiling/transport/io.rb +30 -0
- data/lib/ddtrace/profiling/transport/io/client.rb +27 -0
- data/lib/ddtrace/profiling/transport/io/response.rb +16 -0
- data/lib/ddtrace/profiling/transport/parcel.rb +17 -0
- data/lib/ddtrace/profiling/transport/request.rb +15 -0
- data/lib/ddtrace/profiling/transport/response.rb +8 -0
- data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
- data/lib/ddtrace/propagation/http_propagator.rb +17 -2
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +2 -2
- data/lib/ddtrace/runtime/container.rb +32 -26
- data/lib/ddtrace/runtime/identity.rb +8 -0
- data/lib/ddtrace/sampler.rb +1 -1
- data/lib/ddtrace/sampling/rule_sampler.rb +4 -9
- data/lib/ddtrace/span.rb +7 -7
- data/lib/ddtrace/sync_writer.rb +12 -12
- data/lib/ddtrace/tasks/exec.rb +48 -0
- data/lib/ddtrace/tasks/help.rb +14 -0
- data/lib/ddtrace/tracer.rb +28 -5
- data/lib/ddtrace/transport/http.rb +15 -8
- data/lib/ddtrace/transport/http/adapters/net.rb +27 -8
- 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 +7 -1
- data/lib/ddtrace/transport/http/env.rb +8 -0
- data/lib/ddtrace/transport/http/traces.rb +2 -3
- data/lib/ddtrace/transport/io.rb +1 -1
- data/lib/ddtrace/transport/io/client.rb +15 -8
- data/lib/ddtrace/transport/io/response.rb +1 -3
- data/lib/ddtrace/transport/io/traces.rb +6 -0
- data/lib/ddtrace/transport/parcel.rb +4 -0
- data/lib/ddtrace/transport/traces.rb +18 -1
- data/lib/ddtrace/utils/compression.rb +27 -0
- data/lib/ddtrace/utils/object_set.rb +41 -0
- data/lib/ddtrace/utils/only_once.rb +40 -0
- data/lib/ddtrace/utils/sequence.rb +17 -0
- data/lib/ddtrace/utils/string_table.rb +45 -0
- data/lib/ddtrace/utils/time.rb +32 -1
- data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
- data/lib/ddtrace/vendor/multipart-post/LICENSE +11 -0
- data/lib/ddtrace/vendor/multipart-post/multipart.rb +12 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post.rb +8 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb +116 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/multipartable.rb +57 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/parts.rb +135 -0
- data/lib/ddtrace/vendor/multipart-post/multipart/post/version.rb +9 -0
- data/lib/ddtrace/vendor/multipart-post/net/http/post/multipart.rb +32 -0
- data/lib/ddtrace/version.rb +3 -1
- data/lib/ddtrace/workers.rb +5 -0
- data/lib/ddtrace/workers/async.rb +11 -3
- data/lib/ddtrace/workers/loop.rb +17 -3
- data/lib/ddtrace/workers/polling.rb +1 -0
- data/lib/ddtrace/workers/queue.rb +1 -0
- data/lib/ddtrace/workers/runtime_metrics.rb +14 -1
- data/lib/ddtrace/workers/trace_writer.rb +10 -10
- data/lib/ddtrace/writer.rb +7 -4
- metadata +213 -379
- 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/contrib/rspec/example_group.rb +0 -61
- data/lib/ddtrace/monkey.rb +0 -58
data/lib/ddtrace.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'thread'
|
|
2
|
-
|
|
3
1
|
# During development, we load `ddtrace` by through `ddtrace.gemspec`,
|
|
4
2
|
# which in turn eager loads 'ddtrace/version'.
|
|
5
3
|
#
|
|
@@ -15,13 +13,14 @@ require 'ddtrace/quantization/http'
|
|
|
15
13
|
require 'ddtrace/pipeline'
|
|
16
14
|
require 'ddtrace/configuration'
|
|
17
15
|
require 'ddtrace/patcher'
|
|
18
|
-
require 'ddtrace/augmentation'
|
|
19
16
|
require 'ddtrace/metrics'
|
|
17
|
+
require 'ddtrace/auto_instrument_base'
|
|
18
|
+
require 'ddtrace/profiling'
|
|
20
19
|
|
|
21
20
|
# \Datadog global namespace that includes all tracing functionality for Tracer and Span classes.
|
|
22
21
|
module Datadog
|
|
23
|
-
extend Augmentation
|
|
24
22
|
extend Configuration
|
|
23
|
+
extend AutoInstrumentBase
|
|
25
24
|
|
|
26
25
|
# Load and extend Contrib by default
|
|
27
26
|
require 'ddtrace/contrib/extensions'
|
|
@@ -31,6 +30,10 @@ module Datadog
|
|
|
31
30
|
require 'ddtrace/opentelemetry/extensions'
|
|
32
31
|
extend OpenTelemetry::Extensions
|
|
33
32
|
|
|
33
|
+
# Load and extend AutoInstrument
|
|
34
|
+
require 'ddtrace/contrib/auto_instrument'
|
|
35
|
+
extend Contrib::AutoInstrument
|
|
36
|
+
|
|
34
37
|
# Add shutdown hook:
|
|
35
38
|
# Ensures the tracer has an opportunity to flush traces
|
|
36
39
|
# and cleanup before terminating the process.
|
|
@@ -56,6 +59,7 @@ require 'ddtrace/contrib/grape/integration'
|
|
|
56
59
|
require 'ddtrace/contrib/graphql/integration'
|
|
57
60
|
require 'ddtrace/contrib/grpc/integration'
|
|
58
61
|
require 'ddtrace/contrib/http/integration'
|
|
62
|
+
require 'ddtrace/contrib/httpclient/integration'
|
|
59
63
|
require 'ddtrace/contrib/httprb/integration'
|
|
60
64
|
require 'ddtrace/contrib/integration'
|
|
61
65
|
require 'ddtrace/contrib/kafka/integration'
|
|
@@ -78,4 +82,3 @@ require 'ddtrace/contrib/sidekiq/integration'
|
|
|
78
82
|
require 'ddtrace/contrib/sinatra/integration'
|
|
79
83
|
require 'ddtrace/contrib/sneakers/integration'
|
|
80
84
|
require 'ddtrace/contrib/sucker_punch/integration'
|
|
81
|
-
require 'ddtrace/monkey'
|
data/lib/ddtrace/analytics.rb
CHANGED
|
@@ -6,11 +6,13 @@ module Datadog
|
|
|
6
6
|
class << self
|
|
7
7
|
def set_sample_rate(span, sample_rate)
|
|
8
8
|
return if span.nil? || !sample_rate.is_a?(Numeric)
|
|
9
|
+
|
|
9
10
|
span.set_metric(Datadog::Ext::Analytics::TAG_SAMPLE_RATE, sample_rate)
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def set_measured(span, value = true)
|
|
13
14
|
return if span.nil?
|
|
15
|
+
|
|
14
16
|
# rubocop:disable Style/MultipleComparison
|
|
15
17
|
value = value == true || value == 1 ? 1 : 0
|
|
16
18
|
span.set_metric(Datadog::Ext::Analytics::TAG_MEASURED, value)
|
data/lib/ddtrace/buffer.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'thread'
|
|
2
1
|
require 'ddtrace/diagnostics/health'
|
|
3
2
|
require 'ddtrace/runtime/object_space'
|
|
4
3
|
|
|
@@ -18,6 +17,7 @@ module Datadog
|
|
|
18
17
|
# even if the buffer is full. In that case, a random item is discarded.
|
|
19
18
|
def push(item)
|
|
20
19
|
return if closed?
|
|
20
|
+
|
|
21
21
|
full? ? replace!(item) : add!(item)
|
|
22
22
|
item
|
|
23
23
|
end
|
|
@@ -168,8 +168,8 @@ module Datadog
|
|
|
168
168
|
synchronize { super }
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
def synchronize
|
|
172
|
-
@mutex.synchronize
|
|
171
|
+
def synchronize(&block)
|
|
172
|
+
@mutex.synchronize(&block)
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -318,7 +318,7 @@ module Datadog
|
|
|
318
318
|
#
|
|
319
319
|
# TODO We should restructure this module, so that classes are not declared at top-level ::Datadog.
|
|
320
320
|
# TODO Making such a change is potentially breaking for users manually configuring the tracer.
|
|
321
|
-
TraceBuffer = if Datadog::Ext::Runtime::RUBY_ENGINE == 'ruby'
|
|
321
|
+
TraceBuffer = if Datadog::Ext::Runtime::RUBY_ENGINE == 'ruby'
|
|
322
322
|
CRubyTraceBuffer
|
|
323
323
|
else
|
|
324
324
|
ThreadSafeTraceBuffer
|
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
require 'forwardable'
|
|
2
|
-
|
|
3
2
|
require 'ddtrace/configuration/pin_setup'
|
|
4
3
|
require 'ddtrace/configuration/settings'
|
|
5
4
|
require 'ddtrace/configuration/components'
|
|
5
|
+
require 'ddtrace/utils/only_once'
|
|
6
6
|
|
|
7
7
|
module Datadog
|
|
8
8
|
# Configuration provides a unique access point for configurations
|
|
9
|
-
module Configuration
|
|
9
|
+
module Configuration # rubocop:disable Metrics/ModuleLength
|
|
10
10
|
extend Forwardable
|
|
11
11
|
|
|
12
|
+
# Used to ensure that @components initialization/reconfiguration is performed one-at-a-time, by a single thread.
|
|
13
|
+
#
|
|
14
|
+
# This is important because components can end up being accessed from multiple application threads (for instance on
|
|
15
|
+
# a threaded webserver), and we don't want their initialization to clash (for instance, starting two profilers...).
|
|
16
|
+
#
|
|
17
|
+
# Note that a Mutex **IS NOT** reentrant: the same thread cannot grab the same Mutex more than once.
|
|
18
|
+
# This means below we are careful not to nest calls to methods that would trigger initialization and grab the lock.
|
|
19
|
+
#
|
|
20
|
+
# Every method that directly or indirectly mutates @components should be holding the lock (through
|
|
21
|
+
# #safely_synchronize) while doing so.
|
|
22
|
+
COMPONENTS_WRITE_LOCK = Mutex.new
|
|
23
|
+
private_constant :COMPONENTS_WRITE_LOCK
|
|
24
|
+
|
|
25
|
+
# We use a separate lock when reading the @components, so that they continue to be accessible during reconfiguration.
|
|
26
|
+
# This was needed because we ran into several issues where we still needed to read the old
|
|
27
|
+
# components while the COMPONENTS_WRITE_LOCK was being held (see https://github.com/DataDog/dd-trace-rb/pull/1387
|
|
28
|
+
# and https://github.com/DataDog/dd-trace-rb/pull/1373#issuecomment-799593022 ).
|
|
29
|
+
#
|
|
30
|
+
# Technically on MRI we could get away without this lock, but on non-MRI Rubies, we may run into issues because
|
|
31
|
+
# we fall into the "UnsafeDCLFactory" case of https://shipilev.net/blog/2014/safe-public-construction/ .
|
|
32
|
+
# Specifically, on JRuby reads from the @components do NOT have volatile semantics, and on TruffleRuby they do
|
|
33
|
+
# BUT just as an implementation detail, see https://github.com/jruby/jruby/wiki/Concurrency-in-jruby#volatility and
|
|
34
|
+
# https://github.com/DataDog/dd-trace-rb/pull/1329#issuecomment-776750377 .
|
|
35
|
+
# Concurrency is hard.
|
|
36
|
+
COMPONENTS_READ_LOCK = Mutex.new
|
|
37
|
+
private_constant :COMPONENTS_READ_LOCK
|
|
38
|
+
|
|
12
39
|
attr_writer :configuration
|
|
13
40
|
|
|
14
41
|
def configuration
|
|
@@ -16,16 +43,20 @@ module Datadog
|
|
|
16
43
|
end
|
|
17
44
|
|
|
18
45
|
def configure(target = configuration, opts = {})
|
|
46
|
+
ruby_version_deprecation_warning
|
|
47
|
+
|
|
19
48
|
if target.is_a?(Settings)
|
|
20
49
|
yield(target) if block_given?
|
|
21
50
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
safely_synchronize do |write_components|
|
|
52
|
+
write_components.call(
|
|
53
|
+
if components?
|
|
54
|
+
replace_components!(target, @components)
|
|
55
|
+
else
|
|
56
|
+
build_components(target)
|
|
57
|
+
end
|
|
58
|
+
)
|
|
59
|
+
end
|
|
29
60
|
|
|
30
61
|
target
|
|
31
62
|
else
|
|
@@ -36,22 +67,19 @@ module Datadog
|
|
|
36
67
|
def_delegators \
|
|
37
68
|
:components,
|
|
38
69
|
:health_metrics,
|
|
70
|
+
:profiler,
|
|
39
71
|
:runtime_metrics,
|
|
40
72
|
:tracer
|
|
41
73
|
|
|
42
74
|
def logger
|
|
43
|
-
|
|
75
|
+
# avoid initializing components if they didn't already exist
|
|
76
|
+
current_components = components(allow_initialization: false)
|
|
77
|
+
|
|
78
|
+
if current_components
|
|
44
79
|
@temp_logger = nil
|
|
45
|
-
|
|
80
|
+
current_components.logger
|
|
46
81
|
else
|
|
47
|
-
|
|
48
|
-
# This prevents recursive loops while initializing.
|
|
49
|
-
# e.g. Get logger --> Build components --> Log message --> Repeat...
|
|
50
|
-
@temp_logger ||= begin
|
|
51
|
-
logger = configuration.logger.instance || Datadog::Logger.new(STDOUT)
|
|
52
|
-
logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
|
|
53
|
-
logger
|
|
54
|
-
end
|
|
82
|
+
logger_without_components
|
|
55
83
|
end
|
|
56
84
|
end
|
|
57
85
|
|
|
@@ -65,26 +93,64 @@ module Datadog
|
|
|
65
93
|
#
|
|
66
94
|
# Components won't be automatically reinitialized after a shutdown.
|
|
67
95
|
def shutdown!
|
|
68
|
-
|
|
96
|
+
safely_synchronize do
|
|
97
|
+
@components.shutdown! if components?
|
|
98
|
+
end
|
|
69
99
|
end
|
|
70
100
|
|
|
101
|
+
protected
|
|
102
|
+
|
|
103
|
+
def components(allow_initialization: true)
|
|
104
|
+
current_components = COMPONENTS_READ_LOCK.synchronize { defined?(@components) && @components }
|
|
105
|
+
return current_components if current_components || !allow_initialization
|
|
106
|
+
|
|
107
|
+
safely_synchronize do |write_components|
|
|
108
|
+
(defined?(@components) && @components) || write_components.call(build_components(configuration))
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
private
|
|
113
|
+
|
|
71
114
|
# Gracefully shuts down the tracer and disposes of component references,
|
|
72
115
|
# allowing execution to start anew.
|
|
73
116
|
#
|
|
74
117
|
# In contrast with +#shutdown!+, components will be automatically
|
|
75
118
|
# reinitialized after a reset.
|
|
119
|
+
#
|
|
120
|
+
# Used internally to ensure a clean environment between test runs.
|
|
76
121
|
def reset!
|
|
77
|
-
|
|
78
|
-
|
|
122
|
+
safely_synchronize do |write_components|
|
|
123
|
+
@components.shutdown! if components?
|
|
124
|
+
write_components.call(nil)
|
|
125
|
+
configuration.reset!
|
|
126
|
+
end
|
|
79
127
|
end
|
|
80
128
|
|
|
81
|
-
|
|
129
|
+
def safely_synchronize
|
|
130
|
+
# Writes to @components should only happen through this proc. Because this proc is only accessible to callers of
|
|
131
|
+
# safely_synchronize, this forces all writers to go through this method.
|
|
132
|
+
write_components = proc do |new_value|
|
|
133
|
+
COMPONENTS_READ_LOCK.synchronize { @components = new_value }
|
|
134
|
+
end
|
|
82
135
|
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
COMPONENTS_WRITE_LOCK.synchronize do
|
|
137
|
+
begin
|
|
138
|
+
yield write_components
|
|
139
|
+
rescue ThreadError => e
|
|
140
|
+
logger_without_components.error(
|
|
141
|
+
'Detected deadlock during ddtrace initialization. ' \
|
|
142
|
+
'Please report this at https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug' \
|
|
143
|
+
"\n\tSource:\n\t#{e.backtrace.join("\n\t")}"
|
|
144
|
+
)
|
|
145
|
+
nil
|
|
146
|
+
end
|
|
147
|
+
end
|
|
85
148
|
end
|
|
86
149
|
|
|
87
|
-
|
|
150
|
+
def components?
|
|
151
|
+
# This does not need to grab the COMPONENTS_READ_LOCK because it's not returning the components
|
|
152
|
+
(defined?(@components) && @components) != nil
|
|
153
|
+
end
|
|
88
154
|
|
|
89
155
|
def build_components(settings)
|
|
90
156
|
components = Components.new(settings)
|
|
@@ -99,5 +165,34 @@ module Datadog
|
|
|
99
165
|
components.startup!(settings)
|
|
100
166
|
components
|
|
101
167
|
end
|
|
168
|
+
|
|
169
|
+
def logger_without_components
|
|
170
|
+
# Use default logger without initializing components.
|
|
171
|
+
# This enables logging during initialization, otherwise we'd run into deadlocks.
|
|
172
|
+
@temp_logger ||= begin
|
|
173
|
+
logger = configuration.logger.instance || Datadog::Logger.new($stdout)
|
|
174
|
+
logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
|
|
175
|
+
logger
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Perform version check only once
|
|
180
|
+
DEPRECATED_RUBY_VERSION = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
|
|
181
|
+
private_constant :DEPRECATED_RUBY_VERSION
|
|
182
|
+
|
|
183
|
+
RUBY_VERSION_DEPRECATION_ONLY_ONCE = Datadog::Utils::OnlyOnce.new
|
|
184
|
+
private_constant :RUBY_VERSION_DEPRECATION_ONLY_ONCE
|
|
185
|
+
|
|
186
|
+
def ruby_version_deprecation_warning
|
|
187
|
+
return unless DEPRECATED_RUBY_VERSION
|
|
188
|
+
|
|
189
|
+
RUBY_VERSION_DEPRECATION_ONLY_ONCE.run do
|
|
190
|
+
Datadog.logger.warn(
|
|
191
|
+
"Support for Ruby versions < 2.1 in dd-trace-rb is DEPRECATED.\n" \
|
|
192
|
+
"Last version to support Ruby < 2.1 will be 0.49.x, which will only receive critical bugfixes.\n" \
|
|
193
|
+
'Support for Ruby versions < 2.1 will be REMOVED in version 0.50.0.'
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
102
197
|
end
|
|
103
198
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'ddtrace/diagnostics/health'
|
|
2
2
|
require 'ddtrace/logger'
|
|
3
|
+
require 'ddtrace/profiling'
|
|
3
4
|
require 'ddtrace/runtime/metrics'
|
|
4
5
|
require 'ddtrace/tracer'
|
|
5
6
|
require 'ddtrace/workers/runtime_metrics'
|
|
@@ -7,7 +8,8 @@ require 'ddtrace/workers/runtime_metrics'
|
|
|
7
8
|
module Datadog
|
|
8
9
|
module Configuration
|
|
9
10
|
# Global components for the trace library.
|
|
10
|
-
# rubocop:disable
|
|
11
|
+
# rubocop:disable Layout/LineLength
|
|
12
|
+
# rubocop:disable Metrics/ClassLength
|
|
11
13
|
class Components
|
|
12
14
|
class << self
|
|
13
15
|
def build_health_metrics(settings)
|
|
@@ -19,7 +21,7 @@ module Datadog
|
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def build_logger(settings)
|
|
22
|
-
logger = settings.logger.instance || Datadog::Logger.new(
|
|
24
|
+
logger = settings.logger.instance || Datadog::Logger.new($stdout)
|
|
23
25
|
logger.level = settings.diagnostics.debug ? ::Logger::DEBUG : settings.logger.level
|
|
24
26
|
|
|
25
27
|
logger
|
|
@@ -66,6 +68,22 @@ module Datadog
|
|
|
66
68
|
tracer
|
|
67
69
|
end
|
|
68
70
|
|
|
71
|
+
def build_profiler(settings)
|
|
72
|
+
return unless Datadog::Profiling.supported? && settings.profiling.enabled
|
|
73
|
+
|
|
74
|
+
# Load extensions needed to support some of the Profiling features
|
|
75
|
+
Datadog::Profiling::Tasks::Setup.new.run
|
|
76
|
+
|
|
77
|
+
# NOTE: Please update the Initialization section of ProfilingDevelopment.md with any changes to this method
|
|
78
|
+
|
|
79
|
+
recorder = build_profiler_recorder(settings)
|
|
80
|
+
collectors = build_profiler_collectors(settings, recorder)
|
|
81
|
+
exporters = build_profiler_exporters(settings)
|
|
82
|
+
scheduler = build_profiler_scheduler(settings, recorder, exporters)
|
|
83
|
+
|
|
84
|
+
Datadog::Profiler.new(collectors, scheduler)
|
|
85
|
+
end
|
|
86
|
+
|
|
69
87
|
private
|
|
70
88
|
|
|
71
89
|
def build_tracer_tags(settings)
|
|
@@ -90,11 +108,51 @@ module Datadog
|
|
|
90
108
|
opts[:writer_options] = settings.writer_options if settings.writer.nil?
|
|
91
109
|
end
|
|
92
110
|
end
|
|
111
|
+
|
|
112
|
+
def build_profiler_recorder(settings)
|
|
113
|
+
event_classes = [Datadog::Profiling::Events::StackSample]
|
|
114
|
+
|
|
115
|
+
Datadog::Profiling::Recorder.new(event_classes, settings.profiling.max_events)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def build_profiler_collectors(settings, recorder)
|
|
119
|
+
[
|
|
120
|
+
Datadog::Profiling::Collectors::Stack.new(
|
|
121
|
+
recorder,
|
|
122
|
+
max_frames: settings.profiling.max_frames
|
|
123
|
+
# TODO: Provide proc that identifies Datadog worker threads?
|
|
124
|
+
# ignore_thread: settings.profiling.ignore_profiler
|
|
125
|
+
)
|
|
126
|
+
]
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def build_profiler_exporters(settings)
|
|
130
|
+
if settings.profiling.exporter.instances.is_a?(Array)
|
|
131
|
+
settings.profiling.exporter.instances
|
|
132
|
+
else
|
|
133
|
+
transport = if settings.profiling.exporter.transport
|
|
134
|
+
settings.profiling.exporter.transport
|
|
135
|
+
else
|
|
136
|
+
transport_options = settings.profiling.exporter.transport_options.dup
|
|
137
|
+
transport_options[:site] ||= settings.site if settings.site
|
|
138
|
+
transport_options[:api_key] ||= settings.api_key if settings.api_key
|
|
139
|
+
transport_options[:timeout] ||= settings.profiling.upload.timeout
|
|
140
|
+
Datadog::Profiling::Transport::HTTP.default(transport_options)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
[Datadog::Profiling::Exporter.new(transport)]
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def build_profiler_scheduler(settings, recorder, exporters)
|
|
148
|
+
Datadog::Profiling::Scheduler.new(recorder, exporters)
|
|
149
|
+
end
|
|
93
150
|
end
|
|
94
151
|
|
|
95
152
|
attr_reader \
|
|
96
153
|
:health_metrics,
|
|
97
154
|
:logger,
|
|
155
|
+
:profiler,
|
|
98
156
|
:runtime_metrics,
|
|
99
157
|
:tracer
|
|
100
158
|
|
|
@@ -105,6 +163,9 @@ module Datadog
|
|
|
105
163
|
# Tracer
|
|
106
164
|
@tracer = self.class.build_tracer(settings)
|
|
107
165
|
|
|
166
|
+
# Profiler
|
|
167
|
+
@profiler = self.class.build_profiler(settings)
|
|
168
|
+
|
|
108
169
|
# Runtime metrics
|
|
109
170
|
@runtime_metrics = self.class.build_runtime_metrics_worker(settings)
|
|
110
171
|
|
|
@@ -113,7 +174,20 @@ module Datadog
|
|
|
113
174
|
end
|
|
114
175
|
|
|
115
176
|
# Starts up components
|
|
116
|
-
def startup!(settings)
|
|
177
|
+
def startup!(settings)
|
|
178
|
+
if settings.profiling.enabled
|
|
179
|
+
if profiler
|
|
180
|
+
@logger.debug('Profiling started')
|
|
181
|
+
profiler.start
|
|
182
|
+
else
|
|
183
|
+
# Display a warning for users who expected profiling to autostart
|
|
184
|
+
protobuf = Datadog::Profiling.google_protobuf_supported?
|
|
185
|
+
logger.warn("Profiling was enabled but is not supported; profiling disabled. (google-protobuf?: #{protobuf})")
|
|
186
|
+
end
|
|
187
|
+
else
|
|
188
|
+
@logger.debug('Profiling is disabled')
|
|
189
|
+
end
|
|
190
|
+
end
|
|
117
191
|
|
|
118
192
|
# Shuts down all the components in use.
|
|
119
193
|
# If it has another instance to compare to, it will compare
|
|
@@ -123,12 +197,20 @@ module Datadog
|
|
|
123
197
|
# (e.g. a custom tracer instance passed in.)
|
|
124
198
|
tracer.shutdown! unless replacement && tracer == replacement.tracer
|
|
125
199
|
|
|
200
|
+
# Shutdown old profiler
|
|
201
|
+
profiler.shutdown! unless profiler.nil?
|
|
202
|
+
|
|
126
203
|
# Shutdown workers
|
|
127
|
-
runtime_metrics.
|
|
128
|
-
runtime_metrics.stop(true)
|
|
204
|
+
runtime_metrics.stop(true, close_metrics: false)
|
|
129
205
|
|
|
130
206
|
# Shutdown the old metrics, unless they are still being used.
|
|
131
207
|
# (e.g. custom Statsd instances.)
|
|
208
|
+
#
|
|
209
|
+
# TODO: This violates the encapsulation created by Runtime::Metrics and
|
|
210
|
+
# Health::Metrics, by directly manipulating `statsd` and changing
|
|
211
|
+
# it's lifecycle management.
|
|
212
|
+
# If we need to directly have ownership of `statsd` lifecycle, we should
|
|
213
|
+
# have direct ownership of it.
|
|
132
214
|
old_statsd = [
|
|
133
215
|
runtime_metrics.metrics.statsd,
|
|
134
216
|
health_metrics.statsd
|