ddtrace 0.45.0 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +131 -12
- data/.circleci/images/primary/{Dockerfile-jruby-9.2 → Dockerfile-jruby-9.2-latest} +2 -1
- data/.circleci/images/primary/Dockerfile-jruby-9.2.0.0 +73 -0
- data/.circleci/images/primary/Dockerfile-truffleruby-21.0.0 +73 -0
- data/.github/workflows/create-next-milestone.yml +2 -2
- data/.rubocop.yml +250 -7
- data/.rubocop_todo.yml +397 -0
- data/.simplecov +6 -0
- data/Appraisals +16 -1
- data/CHANGELOG.md +150 -1
- data/Gemfile +53 -3
- data/LICENSE-3rdparty.csv +2 -0
- data/Rakefile +5 -23
- data/ddtrace.gemspec +6 -36
- data/docker-compose.yml +75 -7
- data/docs/DevelopmentGuide.md +28 -0
- data/docs/GettingStarted.md +69 -17
- 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 +0 -5
- data/lib/ddtrace/analytics.rb +2 -0
- data/lib/ddtrace/buffer.rb +4 -4
- data/lib/ddtrace/configuration.rb +92 -23
- 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 +4 -7
- data/lib/ddtrace/configuration/settings.rb +17 -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_pack/action_controller/instrumentation.rb +1 -3
- data/lib/ddtrace/contrib/action_view/event.rb +1 -1
- data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +101 -18
- data/lib/ddtrace/contrib/active_record/utils.rb +1 -0
- 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 +1 -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/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 +5 -5
- data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
- data/lib/ddtrace/contrib/extensions.rb +27 -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/instrumentation.rb +14 -19
- data/lib/ddtrace/contrib/httpclient/patcher.rb +5 -2
- 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/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/middlewares.rb +5 -10
- data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
- data/lib/ddtrace/contrib/rails/patcher.rb +6 -2
- data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
- 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/integration.rb +1 -1
- data/lib/ddtrace/contrib/resque/resque_job.rb +2 -0
- 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 +1 -1
- data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
- data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -1
- 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 +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/ci.rb +2 -2
- data/lib/ddtrace/ext/distributed.rb +1 -1
- data/lib/ddtrace/ext/http.rb +1 -1
- data/lib/ddtrace/ext/runtime.rb +3 -1
- 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 +25 -4
- data/lib/ddtrace/pin.rb +8 -61
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +2 -2
- data/lib/ddtrace/runtime/container.rb +27 -29
- data/lib/ddtrace/runtime/identity.rb +8 -0
- data/lib/ddtrace/sampler.rb +1 -1
- data/lib/ddtrace/sampling/rule_sampler.rb +1 -0
- data/lib/ddtrace/span.rb +7 -7
- data/lib/ddtrace/sync_writer.rb +12 -12
- data/lib/ddtrace/tracer.rb +7 -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/response.rb +1 -3
- data/lib/ddtrace/transport/io/traces.rb +6 -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 +1 -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/trace_writer.rb +10 -10
- data/lib/ddtrace/writer.rb +7 -4
- metadata +152 -402
- 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
@@ -0,0 +1 @@
|
|
1
|
+
wrk.method = "GET"
|
@@ -0,0 +1 @@
|
|
1
|
+
wrk.method = "GET"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
|
4
|
+
INTEGRATION_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
5
|
+
INTEGRATION_DIR=${INTEGRATION_SCRIPT_DIR%/script}
|
6
|
+
cd $INTEGRATION_DIR
|
7
|
+
|
8
|
+
# Parse options
|
9
|
+
while getopts ":v:" opt; do
|
10
|
+
case $opt in
|
11
|
+
v)
|
12
|
+
APP_RUBY_VERSION=$OPTARG
|
13
|
+
;;
|
14
|
+
\?)
|
15
|
+
echo "Invalid option: -$OPTARG" >&2
|
16
|
+
exit 1
|
17
|
+
;;
|
18
|
+
:)
|
19
|
+
echo "Option -$OPTARG requires an argument." >&2
|
20
|
+
exit 1
|
21
|
+
;;
|
22
|
+
esac
|
23
|
+
done
|
24
|
+
|
25
|
+
echo "== Building base images... =="
|
26
|
+
# "wrk" not necessary for CI: will be auto-built by local apps via docker-compose.
|
27
|
+
# docker build -t datadog/dd-apm-demo:wrk -f $INTEGRATION_DIR/images/wrk/Dockerfile $INTEGRATION_DIR/images
|
28
|
+
docker build -t datadog/dd-apm-demo:agent -f $INTEGRATION_DIR/images/agent/Dockerfile $INTEGRATION_DIR/images/agent
|
29
|
+
|
30
|
+
if [ -v APP_RUBY_VERSION ]; then
|
31
|
+
docker build -t datadog/dd-apm-demo:rb-$APP_RUBY_VERSION -f $INTEGRATION_DIR/images/ruby/$APP_RUBY_VERSION/Dockerfile $INTEGRATION_DIR/images
|
32
|
+
else
|
33
|
+
docker build -t datadog/dd-apm-demo:rb-2.0 -f $INTEGRATION_DIR/images/ruby/2.0/Dockerfile $INTEGRATION_DIR/images
|
34
|
+
docker build -t datadog/dd-apm-demo:rb-2.1 -f $INTEGRATION_DIR/images/ruby/2.1/Dockerfile $INTEGRATION_DIR/images
|
35
|
+
docker build -t datadog/dd-apm-demo:rb-2.2 -f $INTEGRATION_DIR/images/ruby/2.2/Dockerfile $INTEGRATION_DIR/images
|
36
|
+
docker build -t datadog/dd-apm-demo:rb-2.3 -f $INTEGRATION_DIR/images/ruby/2.3/Dockerfile $INTEGRATION_DIR/images
|
37
|
+
docker build -t datadog/dd-apm-demo:rb-2.4 -f $INTEGRATION_DIR/images/ruby/2.4/Dockerfile $INTEGRATION_DIR/images
|
38
|
+
docker build -t datadog/dd-apm-demo:rb-2.5 -f $INTEGRATION_DIR/images/ruby/2.5/Dockerfile $INTEGRATION_DIR/images
|
39
|
+
docker build -t datadog/dd-apm-demo:rb-2.6 -f $INTEGRATION_DIR/images/ruby/2.6/Dockerfile $INTEGRATION_DIR/images
|
40
|
+
docker build -t datadog/dd-apm-demo:rb-2.7 -f $INTEGRATION_DIR/images/ruby/2.7/Dockerfile $INTEGRATION_DIR/images
|
41
|
+
docker build -t datadog/dd-apm-demo:rb-3.0 -f $INTEGRATION_DIR/images/ruby/3.0/Dockerfile $INTEGRATION_DIR/images
|
42
|
+
fi
|
43
|
+
echo "== Done building base images. =="
|
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,11 @@ 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'
|
20
17
|
require 'ddtrace/auto_instrument_base'
|
21
18
|
|
22
19
|
# \Datadog global namespace that includes all tracing functionality for Tracer and Span classes.
|
23
20
|
module Datadog
|
24
|
-
extend Augmentation
|
25
21
|
extend Configuration
|
26
22
|
extend AutoInstrumentBase
|
27
23
|
|
@@ -85,4 +81,3 @@ require 'ddtrace/contrib/sidekiq/integration'
|
|
85
81
|
require 'ddtrace/contrib/sinatra/integration'
|
86
82
|
require 'ddtrace/contrib/sneakers/integration'
|
87
83
|
require 'ddtrace/contrib/sucker_punch/integration'
|
88
|
-
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,5 +1,4 @@
|
|
1
1
|
require 'forwardable'
|
2
|
-
|
3
2
|
require 'ddtrace/configuration/pin_setup'
|
4
3
|
require 'ddtrace/configuration/settings'
|
5
4
|
require 'ddtrace/configuration/components'
|
@@ -9,6 +8,33 @@ module Datadog
|
|
9
8
|
module Configuration
|
10
9
|
extend Forwardable
|
11
10
|
|
11
|
+
# Used to ensure that @components initialization/reconfiguration is performed one-at-a-time, by a single thread.
|
12
|
+
#
|
13
|
+
# This is important because components can end up being accessed from multiple application threads (for instance on
|
14
|
+
# a threaded webserver), and we don't want their initialization to clash (for instance, starting two profilers...).
|
15
|
+
#
|
16
|
+
# Note that a Mutex **IS NOT** reentrant: the same thread cannot grab the same Mutex more than once.
|
17
|
+
# This means below we are careful not to nest calls to methods that would trigger initialization and grab the lock.
|
18
|
+
#
|
19
|
+
# Every method that directly or indirectly mutates @components should be holding the lock (through
|
20
|
+
# #safely_synchronize) while doing so.
|
21
|
+
COMPONENTS_WRITE_LOCK = Mutex.new
|
22
|
+
private_constant :COMPONENTS_WRITE_LOCK
|
23
|
+
|
24
|
+
# We use a separate lock when reading the @components, so that they continue to be accessible during reconfiguration.
|
25
|
+
# This was needed because we ran into several issues where we still needed to read the old
|
26
|
+
# components while the COMPONENTS_WRITE_LOCK was being held (see https://github.com/DataDog/dd-trace-rb/pull/1387
|
27
|
+
# and https://github.com/DataDog/dd-trace-rb/pull/1373#issuecomment-799593022 ).
|
28
|
+
#
|
29
|
+
# Technically on MRI we could get away without this lock, but on non-MRI Rubies, we may run into issues because
|
30
|
+
# we fall into the "UnsafeDCLFactory" case of https://shipilev.net/blog/2014/safe-public-construction/ .
|
31
|
+
# Specifically, on JRuby reads from the @components do NOT have volatile semantics, and on TruffleRuby they do
|
32
|
+
# BUT just as an implementation detail, see https://github.com/jruby/jruby/wiki/Concurrency-in-jruby#volatility and
|
33
|
+
# https://github.com/DataDog/dd-trace-rb/pull/1329#issuecomment-776750377 .
|
34
|
+
# Concurrency is hard.
|
35
|
+
COMPONENTS_READ_LOCK = Mutex.new
|
36
|
+
private_constant :COMPONENTS_READ_LOCK
|
37
|
+
|
12
38
|
attr_writer :configuration
|
13
39
|
|
14
40
|
def configuration
|
@@ -19,13 +45,15 @@ module Datadog
|
|
19
45
|
if target.is_a?(Settings)
|
20
46
|
yield(target) if block_given?
|
21
47
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
48
|
+
safely_synchronize do |write_components|
|
49
|
+
write_components.call(
|
50
|
+
if components?
|
51
|
+
replace_components!(target, @components)
|
52
|
+
else
|
53
|
+
build_components(target)
|
54
|
+
end
|
55
|
+
)
|
56
|
+
end
|
29
57
|
|
30
58
|
target
|
31
59
|
else
|
@@ -40,18 +68,14 @@ module Datadog
|
|
40
68
|
:tracer
|
41
69
|
|
42
70
|
def logger
|
43
|
-
|
71
|
+
# avoid initializing components if they didn't already exist
|
72
|
+
current_components = components(allow_initialization: false)
|
73
|
+
|
74
|
+
if current_components
|
44
75
|
@temp_logger = nil
|
45
|
-
|
76
|
+
current_components.logger
|
46
77
|
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
|
78
|
+
logger_without_components
|
55
79
|
end
|
56
80
|
end
|
57
81
|
|
@@ -65,7 +89,9 @@ module Datadog
|
|
65
89
|
#
|
66
90
|
# Components won't be automatically reinitialized after a shutdown.
|
67
91
|
def shutdown!
|
68
|
-
|
92
|
+
safely_synchronize do
|
93
|
+
@components.shutdown! if components?
|
94
|
+
end
|
69
95
|
end
|
70
96
|
|
71
97
|
# Gracefully shuts down the tracer and disposes of component references,
|
@@ -74,18 +100,51 @@ module Datadog
|
|
74
100
|
# In contrast with +#shutdown!+, components will be automatically
|
75
101
|
# reinitialized after a reset.
|
76
102
|
def reset!
|
77
|
-
|
78
|
-
|
103
|
+
safely_synchronize do |write_components|
|
104
|
+
@components.shutdown! if components?
|
105
|
+
write_components.call(nil)
|
106
|
+
end
|
79
107
|
end
|
80
108
|
|
81
109
|
protected
|
82
110
|
|
83
|
-
def components
|
84
|
-
@components
|
111
|
+
def components(allow_initialization: true)
|
112
|
+
current_components = COMPONENTS_READ_LOCK.synchronize { defined?(@components) && @components }
|
113
|
+
return current_components if current_components || !allow_initialization
|
114
|
+
|
115
|
+
safely_synchronize do |write_components|
|
116
|
+
(defined?(@components) && @components) || write_components.call(build_components(configuration))
|
117
|
+
end
|
85
118
|
end
|
86
119
|
|
87
120
|
private
|
88
121
|
|
122
|
+
def safely_synchronize
|
123
|
+
# Writes to @components should only happen through this proc. Because this proc is only accessible to callers of
|
124
|
+
# safely_synchronize, this forces all writers to go through this method.
|
125
|
+
write_components = proc do |new_value|
|
126
|
+
COMPONENTS_READ_LOCK.synchronize { @components = new_value }
|
127
|
+
end
|
128
|
+
|
129
|
+
COMPONENTS_WRITE_LOCK.synchronize do
|
130
|
+
begin
|
131
|
+
yield write_components
|
132
|
+
rescue ThreadError => e
|
133
|
+
logger_without_components.error(
|
134
|
+
'Detected deadlock during ddtrace initialization. ' \
|
135
|
+
'Please report this at https://github.com/DataDog/dd-trace-rb/blob/master/CONTRIBUTING.md#found-a-bug' \
|
136
|
+
"\n\tSource:\n\t#{e.backtrace.join("\n\t")}"
|
137
|
+
)
|
138
|
+
nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def components?
|
144
|
+
# This does not need to grab the COMPONENTS_READ_LOCK because it's not returning the components
|
145
|
+
(defined?(@components) && @components) != nil
|
146
|
+
end
|
147
|
+
|
89
148
|
def build_components(settings)
|
90
149
|
components = Components.new(settings)
|
91
150
|
components.startup!(settings)
|
@@ -99,5 +158,15 @@ module Datadog
|
|
99
158
|
components.startup!(settings)
|
100
159
|
components
|
101
160
|
end
|
161
|
+
|
162
|
+
def logger_without_components
|
163
|
+
# Use default logger without initializing components.
|
164
|
+
# This enables logging during initialization, otherwise we'd run into deadlocks.
|
165
|
+
@temp_logger ||= begin
|
166
|
+
logger = configuration.logger.instance || Datadog::Logger.new($stdout)
|
167
|
+
logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
|
168
|
+
logger
|
169
|
+
end
|
170
|
+
end
|
102
171
|
end
|
103
172
|
end
|
@@ -7,7 +7,7 @@ require 'ddtrace/workers/runtime_metrics'
|
|
7
7
|
module Datadog
|
8
8
|
module Configuration
|
9
9
|
# Global components for the trace library.
|
10
|
-
# rubocop:disable
|
10
|
+
# rubocop:disable Layout/LineLength
|
11
11
|
class Components
|
12
12
|
class << self
|
13
13
|
def build_health_metrics(settings)
|
@@ -19,7 +19,7 @@ module Datadog
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_logger(settings)
|
22
|
-
logger = settings.logger.instance || Datadog::Logger.new(
|
22
|
+
logger = settings.logger.instance || Datadog::Logger.new($stdout)
|
23
23
|
logger.level = settings.diagnostics.debug ? ::Logger::DEBUG : settings.logger.level
|
24
24
|
|
25
25
|
logger
|
@@ -60,7 +60,7 @@ module Datadog
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def default(value = nil, &block)
|
63
|
-
@default =
|
63
|
+
@default = block || value
|
64
64
|
end
|
65
65
|
|
66
66
|
def delegate_to(&block)
|
@@ -71,8 +71,6 @@ module Datadog
|
|
71
71
|
@helpers[name] = block
|
72
72
|
end
|
73
73
|
|
74
|
-
# rubocop:disable Style/TrivialAccessors
|
75
|
-
# (Rubocop erroneously thinks #lazy == #lazy= )
|
76
74
|
def lazy(value = true)
|
77
75
|
@lazy = value
|
78
76
|
end
|
@@ -14,10 +14,8 @@ module Datadog
|
|
14
14
|
# Class behavior for a configuration object with options
|
15
15
|
module ClassMethods
|
16
16
|
def options
|
17
|
-
|
18
|
-
|
19
|
-
superclass <= Options ? superclass.options.dup : OptionDefinitionSet.new
|
20
|
-
end
|
17
|
+
# Allows for class inheritance of option definitions
|
18
|
+
@options ||= superclass <= Options ? superclass.options.dup : OptionDefinitionSet.new
|
21
19
|
end
|
22
20
|
|
23
21
|
protected
|
@@ -51,6 +49,7 @@ module Datadog
|
|
51
49
|
def define_helpers(helpers)
|
52
50
|
helpers.each do |name, block|
|
53
51
|
next unless block.is_a?(Proc)
|
52
|
+
|
54
53
|
define_method(name, &block)
|
55
54
|
end
|
56
55
|
end
|
@@ -102,9 +101,7 @@ module Datadog
|
|
102
101
|
end
|
103
102
|
|
104
103
|
def assert_valid_option!(name)
|
105
|
-
unless option_defined?(name)
|
106
|
-
raise(InvalidOptionError, "#{self.class.name} doesn't define the option: #{name}")
|
107
|
-
end
|
104
|
+
raise(InvalidOptionError, "#{self.class.name} doesn't define the option: #{name}") unless option_defined?(name)
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
@@ -187,9 +187,7 @@ module Datadog
|
|
187
187
|
string_tags = Hash[new_value.collect { |k, v| [k.to_s, v] }]
|
188
188
|
|
189
189
|
# Cross-populate tag values with other settings
|
190
|
-
if env.nil? && string_tags.key?(Ext::Environment::TAG_ENV)
|
191
|
-
self.env = string_tags[Ext::Environment::TAG_ENV]
|
192
|
-
end
|
190
|
+
self.env = string_tags[Ext::Environment::TAG_ENV] if env.nil? && string_tags.key?(Ext::Environment::TAG_ENV)
|
193
191
|
|
194
192
|
if version.nil? && string_tags.key?(Ext::Environment::TAG_VERSION)
|
195
193
|
self.version = string_tags[Ext::Environment::TAG_VERSION]
|
@@ -206,6 +204,22 @@ module Datadog
|
|
206
204
|
o.lazy
|
207
205
|
end
|
208
206
|
|
207
|
+
option :time_now_provider do |o|
|
208
|
+
o.default { ::Time.now }
|
209
|
+
|
210
|
+
o.on_set do |time_provider|
|
211
|
+
Utils::Time.now_provider = time_provider
|
212
|
+
end
|
213
|
+
|
214
|
+
o.resetter do |_value|
|
215
|
+
# TODO: Resetter needs access to the default value
|
216
|
+
# TODO: to help reduce duplication.
|
217
|
+
-> { ::Time.now }.tap do |default|
|
218
|
+
Utils::Time.now_provider = default
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
209
223
|
settings :tracer do
|
210
224
|
option :enabled do |o|
|
211
225
|
o.default { env_to_bool(Datadog::Ext::Diagnostics::DD_TRACE_ENABLED, true) }
|
data/lib/ddtrace/context.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'thread'
|
2
1
|
require 'ddtrace/diagnostics/health'
|
3
2
|
|
4
3
|
require 'ddtrace/context_flush'
|
@@ -126,6 +125,7 @@ module Datadog
|
|
126
125
|
# on per-instrumentation code to retrieve handle parent/child relations.
|
127
126
|
set_current_span(span.parent)
|
128
127
|
return if span.tracer.nil?
|
128
|
+
|
129
129
|
if span.parent.nil? && !all_spans_finished?
|
130
130
|
if Datadog.configuration.diagnostics.debug
|
131
131
|
opened_spans = @trace.length - @finished_spans
|
@@ -230,7 +230,7 @@ module Datadog
|
|
230
230
|
# Return a string representation of the context.
|
231
231
|
def to_s
|
232
232
|
@mutex.synchronize do
|
233
|
-
# rubocop:disable
|
233
|
+
# rubocop:disable Layout/LineLength
|
234
234
|
"Context(trace.length:#{@trace.length},sampled:#{@sampled},finished_spans:#{@finished_spans},current_span:#{@current_span})"
|
235
235
|
end
|
236
236
|
end
|
@@ -300,6 +300,7 @@ module Datadog
|
|
300
300
|
def start_time
|
301
301
|
@mutex.synchronize do
|
302
302
|
return nil if @trace.empty?
|
303
|
+
|
303
304
|
@trace[0].start_time
|
304
305
|
end
|
305
306
|
end
|
@@ -312,11 +313,9 @@ module Datadog
|
|
312
313
|
end
|
313
314
|
|
314
315
|
# Iterate on each span within the trace. This is thread safe.
|
315
|
-
def each_span
|
316
|
+
def each_span(&block)
|
316
317
|
@mutex.synchronize do
|
317
|
-
@trace.each
|
318
|
-
yield span
|
319
|
-
end
|
318
|
+
@trace.each(&block)
|
320
319
|
end
|
321
320
|
end
|
322
321
|
end
|