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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'ddtrace/transport/response'
|
|
2
|
+
require 'ddtrace/vendor/multipart-post/net/http/post/multipart'
|
|
2
3
|
|
|
3
4
|
module Datadog
|
|
4
5
|
module Transport
|
|
@@ -9,27 +10,28 @@ module Datadog
|
|
|
9
10
|
attr_reader \
|
|
10
11
|
:hostname,
|
|
11
12
|
:port,
|
|
12
|
-
:timeout
|
|
13
|
+
:timeout,
|
|
14
|
+
:ssl
|
|
13
15
|
|
|
14
|
-
DEFAULT_TIMEOUT =
|
|
16
|
+
DEFAULT_TIMEOUT = 30
|
|
15
17
|
|
|
16
18
|
def initialize(hostname, port, options = {})
|
|
17
19
|
@hostname = hostname
|
|
18
20
|
@port = port
|
|
19
21
|
@timeout = options[:timeout] || DEFAULT_TIMEOUT
|
|
22
|
+
@ssl = options.key?(:ssl) ? options[:ssl] == true : false
|
|
20
23
|
end
|
|
21
24
|
|
|
22
|
-
def open
|
|
25
|
+
def open(&block)
|
|
23
26
|
# DEV Initializing +Net::HTTP+ directly help us avoid expensive
|
|
24
27
|
# options processing done in +Net::HTTP.start+:
|
|
25
28
|
# https://github.com/ruby/ruby/blob/b2d96abb42abbe2e01f010ffc9ac51f0f9a50002/lib/net/http.rb#L614-L618
|
|
26
29
|
req = ::Net::HTTP.new(hostname, port, nil)
|
|
27
30
|
|
|
31
|
+
req.use_ssl = ssl
|
|
28
32
|
req.open_timeout = req.read_timeout = timeout
|
|
29
33
|
|
|
30
|
-
req.start
|
|
31
|
-
yield(http)
|
|
32
|
-
end
|
|
34
|
+
req.start(&block)
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def call(env)
|
|
@@ -41,8 +43,18 @@ module Datadog
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def post(env)
|
|
44
|
-
post =
|
|
45
|
-
|
|
46
|
+
post = nil
|
|
47
|
+
|
|
48
|
+
if env.form.nil? || env.form.empty?
|
|
49
|
+
post = ::Net::HTTP::Post.new(env.path, env.headers)
|
|
50
|
+
post.body = env.body
|
|
51
|
+
else
|
|
52
|
+
post = ::Datadog::Vendor::Net::HTTP::Post::Multipart.new(
|
|
53
|
+
env.path,
|
|
54
|
+
env.form,
|
|
55
|
+
env.headers
|
|
56
|
+
)
|
|
57
|
+
end
|
|
46
58
|
|
|
47
59
|
# Connect and send the request
|
|
48
60
|
http_response = open do |http|
|
|
@@ -82,36 +94,43 @@ module Datadog
|
|
|
82
94
|
|
|
83
95
|
def payload
|
|
84
96
|
return super if http_response.nil?
|
|
97
|
+
|
|
85
98
|
http_response.body
|
|
86
99
|
end
|
|
87
100
|
|
|
88
101
|
def code
|
|
89
102
|
return super if http_response.nil?
|
|
103
|
+
|
|
90
104
|
http_response.code.to_i
|
|
91
105
|
end
|
|
92
106
|
|
|
93
107
|
def ok?
|
|
94
108
|
return super if http_response.nil?
|
|
109
|
+
|
|
95
110
|
code.between?(200, 299)
|
|
96
111
|
end
|
|
97
112
|
|
|
98
113
|
def unsupported?
|
|
99
114
|
return super if http_response.nil?
|
|
115
|
+
|
|
100
116
|
code == 415
|
|
101
117
|
end
|
|
102
118
|
|
|
103
119
|
def not_found?
|
|
104
120
|
return super if http_response.nil?
|
|
121
|
+
|
|
105
122
|
code == 404
|
|
106
123
|
end
|
|
107
124
|
|
|
108
125
|
def client_error?
|
|
109
126
|
return super if http_response.nil?
|
|
127
|
+
|
|
110
128
|
code.between?(400, 499)
|
|
111
129
|
end
|
|
112
130
|
|
|
113
131
|
def server_error?
|
|
114
132
|
return super if http_response.nil?
|
|
133
|
+
|
|
115
134
|
code.between?(500, 599)
|
|
116
135
|
end
|
|
117
136
|
|
|
@@ -18,7 +18,7 @@ module Datadog
|
|
|
18
18
|
@timeout = options.fetch(:timeout, DEFAULT_TIMEOUT)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def open
|
|
21
|
+
def open(&block)
|
|
22
22
|
# Open connection
|
|
23
23
|
connection = HTTP.new(
|
|
24
24
|
filepath,
|
|
@@ -26,9 +26,7 @@ module Datadog
|
|
|
26
26
|
continue_timeout: timeout
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
connection.start
|
|
30
|
-
yield(http)
|
|
31
|
-
end
|
|
29
|
+
connection.start(&block)
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
def url
|
|
@@ -36,6 +36,7 @@ module Datadog
|
|
|
36
36
|
@default_adapter = if type.is_a?(Symbol)
|
|
37
37
|
registry_klass = REGISTRY.get(type)
|
|
38
38
|
raise UnknownAdapterError, type if registry_klass.nil?
|
|
39
|
+
|
|
39
40
|
registry_klass.new(*args)
|
|
40
41
|
else
|
|
41
42
|
type
|
|
@@ -67,6 +68,7 @@ module Datadog
|
|
|
67
68
|
|
|
68
69
|
def default_api=(key)
|
|
69
70
|
raise UnknownApiError, key unless @apis.key?(key)
|
|
71
|
+
|
|
70
72
|
@default_api = key
|
|
71
73
|
end
|
|
72
74
|
|
|
@@ -93,7 +95,7 @@ module Datadog
|
|
|
93
95
|
api_options[:headers] = @default_headers.merge((api_options[:headers] || {}))
|
|
94
96
|
|
|
95
97
|
# Add API::Instance with all settings
|
|
96
|
-
instances[key] =
|
|
98
|
+
instances[key] = api_instance_class.new(
|
|
97
99
|
spec,
|
|
98
100
|
adapter,
|
|
99
101
|
api_options
|
|
@@ -105,6 +107,10 @@ module Datadog
|
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
109
|
|
|
110
|
+
def api_instance_class
|
|
111
|
+
API::Instance
|
|
112
|
+
end
|
|
113
|
+
|
|
108
114
|
# Raised when the API key does not match known APIs.
|
|
109
115
|
class UnknownApiError < StandardError
|
|
110
116
|
attr_reader :key
|
|
@@ -41,6 +41,7 @@ module Datadog
|
|
|
41
41
|
|
|
42
42
|
def send_traces(env, &block)
|
|
43
43
|
raise NoTraceEndpointDefinedError, self if traces.nil?
|
|
44
|
+
|
|
44
45
|
traces.call(env, &block)
|
|
45
46
|
end
|
|
46
47
|
|
|
@@ -121,9 +122,7 @@ module Datadog
|
|
|
121
122
|
# Parse service rates, if configured to do so.
|
|
122
123
|
if service_rates? && !http_response.payload.to_s.empty?
|
|
123
124
|
body = JSON.parse(http_response.payload)
|
|
124
|
-
if body.is_a?(Hash) && body.key?(SERVICE_RATE_KEY)
|
|
125
|
-
options[:service_rates] = body[SERVICE_RATE_KEY]
|
|
126
|
-
end
|
|
125
|
+
options[:service_rates] = body[SERVICE_RATE_KEY] if body.is_a?(Hash) && body.key?(SERVICE_RATE_KEY)
|
|
127
126
|
end
|
|
128
127
|
end
|
|
129
128
|
|
data/lib/ddtrace/transport/io.rb
CHANGED
|
@@ -12,19 +12,24 @@ module Datadog
|
|
|
12
12
|
:encoder,
|
|
13
13
|
:out
|
|
14
14
|
|
|
15
|
-
def initialize(out, encoder)
|
|
15
|
+
def initialize(out, encoder, options = {})
|
|
16
16
|
@out = out
|
|
17
17
|
@encoder = encoder
|
|
18
|
+
|
|
19
|
+
@request_block = options.fetch(:request, method(:send_default_request))
|
|
20
|
+
@encode_block = options.fetch(:encode, method(:encode_data))
|
|
21
|
+
@write_block = options.fetch(:write, method(:write_data))
|
|
22
|
+
@response_block = options.fetch(:response, method(:build_response))
|
|
18
23
|
end
|
|
19
24
|
|
|
20
25
|
def send_request(request)
|
|
21
26
|
# Write data to IO
|
|
22
27
|
# If block is given, allow it to handle writing
|
|
23
|
-
# Otherwise
|
|
28
|
+
# Otherwise do a standard encode/write/response.
|
|
24
29
|
response = if block_given?
|
|
25
30
|
yield(out, request)
|
|
26
31
|
else
|
|
27
|
-
|
|
32
|
+
@request_block.call(out, request)
|
|
28
33
|
end
|
|
29
34
|
|
|
30
35
|
# Update statistics
|
|
@@ -48,8 +53,6 @@ module Datadog
|
|
|
48
53
|
InternalErrorResponse.new(e)
|
|
49
54
|
end
|
|
50
55
|
|
|
51
|
-
protected
|
|
52
|
-
|
|
53
56
|
def encode_data(encoder, request)
|
|
54
57
|
request.parcel.encode_with(encoder)
|
|
55
58
|
end
|
|
@@ -58,17 +61,21 @@ module Datadog
|
|
|
58
61
|
out.puts(data)
|
|
59
62
|
end
|
|
60
63
|
|
|
64
|
+
def build_response(_request, _data, result)
|
|
65
|
+
IO::Response.new(result)
|
|
66
|
+
end
|
|
67
|
+
|
|
61
68
|
private
|
|
62
69
|
|
|
63
70
|
def send_default_request(out, request)
|
|
64
71
|
# Encode data
|
|
65
|
-
data =
|
|
72
|
+
data = @encode_block.call(encoder, request)
|
|
66
73
|
|
|
67
74
|
# Write to IO
|
|
68
|
-
result =
|
|
75
|
+
result = @write_block.call(out, data)
|
|
69
76
|
|
|
70
77
|
# Generate a response
|
|
71
|
-
|
|
78
|
+
@response_block.call(request, data, result)
|
|
72
79
|
end
|
|
73
80
|
end
|
|
74
81
|
end
|
|
@@ -6,14 +6,12 @@ module Datadog
|
|
|
6
6
|
# Response from HTTP transport for traces
|
|
7
7
|
class Response
|
|
8
8
|
include Transport::Response
|
|
9
|
-
include Transport::Traces::Response
|
|
10
9
|
|
|
11
10
|
attr_reader \
|
|
12
11
|
:result
|
|
13
12
|
|
|
14
|
-
def initialize(result
|
|
13
|
+
def initialize(result)
|
|
15
14
|
@result = result
|
|
16
|
-
@trace_count = trace_count
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
def ok?
|
|
@@ -10,6 +10,12 @@ module Datadog
|
|
|
10
10
|
module Traces
|
|
11
11
|
# Response from HTTP transport for traces
|
|
12
12
|
class Response < IO::Response
|
|
13
|
+
include Transport::Traces::Response
|
|
14
|
+
|
|
15
|
+
def initialize(result, trace_count = 1)
|
|
16
|
+
super(result)
|
|
17
|
+
@trace_count = trace_count
|
|
18
|
+
end
|
|
13
19
|
end
|
|
14
20
|
|
|
15
21
|
# Extensions for HTTP client
|
|
@@ -123,7 +123,21 @@ module Datadog
|
|
|
123
123
|
return send_traces(traces)
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
|
-
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Force resolution of lazy enumerator.
|
|
129
|
+
#
|
|
130
|
+
# The "correct" method to call here would be `#force`,
|
|
131
|
+
# as this method was created to force the eager loading
|
|
132
|
+
# of a lazy enumerator.
|
|
133
|
+
#
|
|
134
|
+
# Unfortunately, JRuby < 9.2.9.0 erroneously eagerly loads
|
|
135
|
+
# the lazy Enumerator during intermediate steps.
|
|
136
|
+
# This forces us to use `#to_a`, as this method works for both
|
|
137
|
+
# lazy and regular Enumerators.
|
|
138
|
+
# Using `#to_a` can mask the fact that we expect a lazy
|
|
139
|
+
# Enumerator.
|
|
140
|
+
responses = responses.to_a
|
|
127
141
|
|
|
128
142
|
Datadog.health_metrics.transport_chunked(responses.size)
|
|
129
143
|
|
|
@@ -142,17 +156,20 @@ module Datadog
|
|
|
142
156
|
|
|
143
157
|
def downgrade?(response)
|
|
144
158
|
return false unless apis.fallbacks.key?(@current_api_id)
|
|
159
|
+
|
|
145
160
|
response.not_found? || response.unsupported?
|
|
146
161
|
end
|
|
147
162
|
|
|
148
163
|
def downgrade!
|
|
149
164
|
downgrade_api_id = apis.fallbacks[@current_api_id]
|
|
150
165
|
raise NoDowngradeAvailableError, @current_api_id if downgrade_api_id.nil?
|
|
166
|
+
|
|
151
167
|
change_api!(downgrade_api_id)
|
|
152
168
|
end
|
|
153
169
|
|
|
154
170
|
def change_api!(api_id)
|
|
155
171
|
raise UnknownApiVersionError, api_id unless apis.key?(api_id)
|
|
172
|
+
|
|
156
173
|
@current_api_id = api_id
|
|
157
174
|
@client = HTTP::Client.new(current_api)
|
|
158
175
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'zlib'
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module Utils
|
|
5
|
+
# Common database-related utility functions.
|
|
6
|
+
module Compression
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def gzip(string, level: nil, strategy: nil)
|
|
10
|
+
sio = StringIO.new
|
|
11
|
+
sio.binmode
|
|
12
|
+
gz = Zlib::GzipWriter.new(sio, level, strategy)
|
|
13
|
+
gz.write(string)
|
|
14
|
+
gz.close
|
|
15
|
+
sio.string
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def gunzip(string, encoding = ::Encoding::ASCII_8BIT)
|
|
19
|
+
sio = StringIO.new(string)
|
|
20
|
+
gz = Zlib::GzipReader.new(sio, encoding: encoding)
|
|
21
|
+
gz.read
|
|
22
|
+
ensure
|
|
23
|
+
gz && gz.close
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'ddtrace/utils/sequence'
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module Utils
|
|
5
|
+
# Acts as a unique dictionary of objects
|
|
6
|
+
class ObjectSet
|
|
7
|
+
# You can provide a block that defines how the key
|
|
8
|
+
# for this message type is resolved.
|
|
9
|
+
def initialize(seed = 0, &block)
|
|
10
|
+
@sequence = Utils::Sequence.new(seed)
|
|
11
|
+
@items = {}
|
|
12
|
+
@key_block = block
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Submit an array of arguments that define the message.
|
|
16
|
+
# If they match an existing message, it will return the
|
|
17
|
+
# matching object. If it doesn't match, it will yield to
|
|
18
|
+
# the block with the next ID & args given.
|
|
19
|
+
def fetch(*args, &block)
|
|
20
|
+
key = @key_block ? @key_block.call(*args) : args.hash
|
|
21
|
+
# TODO: Ruby 2.0 doesn't like yielding here... switch when 2.0 is dropped.
|
|
22
|
+
# rubocop:disable Performance/RedundantBlockCall
|
|
23
|
+
@items[key] ||= block.call(@sequence.next, *args)
|
|
24
|
+
# rubocop:enable Performance/RedundantBlockCall
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def length
|
|
28
|
+
@items.length
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def objects
|
|
32
|
+
@items.values
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def freeze
|
|
36
|
+
super
|
|
37
|
+
@items.freeze
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module Utils
|
|
5
|
+
# Helper class to execute something only once such as not repeating warning logs, and instrumenting classes
|
|
6
|
+
# only once.
|
|
7
|
+
#
|
|
8
|
+
# Thread-safe when used correctly (e.g. be careful of races when lazily initializing instances of this class).
|
|
9
|
+
#
|
|
10
|
+
# Note: In its current state, this class is not Ractor-safe.
|
|
11
|
+
# In https://github.com/DataDog/dd-trace-rb/pull/1398#issuecomment-797378810 we have a discussion of alternatives,
|
|
12
|
+
# including an alternative implementation that is Ractor-safe once spent.
|
|
13
|
+
class OnlyOnce
|
|
14
|
+
def initialize
|
|
15
|
+
@mutex = Mutex.new
|
|
16
|
+
@ran_once = false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run
|
|
20
|
+
@mutex.synchronize do
|
|
21
|
+
return if @ran_once
|
|
22
|
+
|
|
23
|
+
@ran_once = true
|
|
24
|
+
|
|
25
|
+
yield
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def ran?
|
|
30
|
+
@mutex.synchronize { @ran_once }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def reset_ran_once_state_for_tests
|
|
36
|
+
@mutex.synchronize { @ran_once = false }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|