ddtrace 0.45.0 → 0.46.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +79 -0
- data/.rubocop.yml +250 -7
- data/.rubocop_todo.yml +396 -0
- data/Appraisals +15 -0
- data/CHANGELOG.md +68 -1
- data/Gemfile +38 -3
- data/Rakefile +5 -23
- data/ddtrace.gemspec +6 -36
- data/docs/DevelopmentGuide.md +28 -0
- data/docs/GettingStarted.md +8 -9
- 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 +1 -1
- data/lib/ddtrace/configuration/base.rb +1 -1
- data/lib/ddtrace/configuration/components.rb +2 -2
- data/lib/ddtrace/configuration/option_definition.rb +1 -3
- data/lib/ddtrace/configuration/options.rb +2 -3
- data/lib/ddtrace/configuration/settings.rb +17 -3
- data/lib/ddtrace/context.rb +5 -6
- data/lib/ddtrace/context_provider.rb +1 -0
- 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 +17 -5
- 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 +1 -0
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +1 -4
- 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/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 +1 -0
- 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 +2 -3
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +2 -3
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
- data/lib/ddtrace/contrib/patcher.rb +1 -1
- 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/rake/instrumentation.rb +4 -2
- 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/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 +1 -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 +2 -3
- data/lib/ddtrace/pin.rb +3 -52
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +1 -1
- data/lib/ddtrace/runtime/container.rb +2 -2
- data/lib/ddtrace/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 +7 -10
- data/lib/ddtrace/tracer.rb +1 -1
- data/lib/ddtrace/transport/http.rb +1 -3
- data/lib/ddtrace/transport/http/adapters/net.rb +9 -4
- data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
- data/lib/ddtrace/transport/http/builder.rb +2 -0
- data/lib/ddtrace/transport/http/traces.rb +2 -3
- data/lib/ddtrace/transport/io.rb +1 -1
- data/lib/ddtrace/transport/traces.rb +3 -0
- data/lib/ddtrace/utils/time.rb +25 -1
- data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace/workers.rb +5 -0
- data/lib/ddtrace/workers/async.rb +8 -0
- data/lib/ddtrace/workers/loop.rb +3 -0
- data/lib/ddtrace/workers/polling.rb +1 -0
- data/lib/ddtrace/workers/trace_writer.rb +9 -10
- data/lib/ddtrace/writer.rb +3 -3
- metadata +133 -400
- 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,54 @@
|
|
1
|
+
FROM ruby:3.0
|
2
|
+
|
3
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
4
|
+
|
5
|
+
# Install prerequisites
|
6
|
+
RUN set -ex && \
|
7
|
+
echo "===> Installing dependencies" && \
|
8
|
+
apt-get -y update && \
|
9
|
+
apt-get install -y --force-yes --no-install-recommends \
|
10
|
+
curl wget tar gzip gnupg apt-transport-https ca-certificates tzdata locales && \
|
11
|
+
\
|
12
|
+
echo "===> Installing NodeJS" && \
|
13
|
+
apt-get install -y --force-yes --no-install-recommends nodejs && \
|
14
|
+
\
|
15
|
+
echo "===> Installing Yarn" && \
|
16
|
+
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
17
|
+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
18
|
+
apt-get update && \
|
19
|
+
apt-get install -y --force-yes --no-install-recommends yarn && \
|
20
|
+
\
|
21
|
+
echo "===> Installing database libraries" && \
|
22
|
+
apt-get install -y --force-yes --no-install-recommends \
|
23
|
+
postgresql-client sqlite3 && \
|
24
|
+
\
|
25
|
+
echo "===> Installing dev tools" && \
|
26
|
+
mkdir -p /usr/share/man/man1 && \
|
27
|
+
apt-get install -y --force-yes --no-install-recommends \
|
28
|
+
sudo git openssh-client rsync vim \
|
29
|
+
net-tools netcat parallel unzip zip bzip2 && \
|
30
|
+
\
|
31
|
+
echo "===> Cleaning up" && \
|
32
|
+
rm -rf /var/lib/apt/lists/*;
|
33
|
+
|
34
|
+
# Set timezone to UTC by default
|
35
|
+
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
|
36
|
+
|
37
|
+
# Set language
|
38
|
+
RUN locale-gen en_US.UTF-8
|
39
|
+
ENV LANG en_US.UTF-8
|
40
|
+
ENV LANGUAGE en_US:en
|
41
|
+
|
42
|
+
# Install RubyGems
|
43
|
+
RUN gem update --system
|
44
|
+
RUN mkdir -p "$GEM_HOME" && chmod -R 777 "$GEM_HOME"
|
45
|
+
|
46
|
+
# Upgrade RubyGems and Bundler
|
47
|
+
RUN gem update --system
|
48
|
+
RUN gem install bundler
|
49
|
+
ENV BUNDLE_SILENCE_ROOT_WARNING 1
|
50
|
+
|
51
|
+
# Setup demo environment includes
|
52
|
+
COPY ./include /vendor/dd-demo
|
53
|
+
ENV RUBYLIB /vendor/dd-demo
|
54
|
+
ENV RUBYOPT -rdatadog/demo_env
|
@@ -0,0 +1,33 @@
|
|
1
|
+
FROM debian:jessie
|
2
|
+
|
3
|
+
RUN echo "===> Installing tools..." && \
|
4
|
+
apt-get -y update && \
|
5
|
+
apt-get -y install build-essential curl && \
|
6
|
+
\
|
7
|
+
echo "===> Installing wrk" && \
|
8
|
+
WRK_VERSION=$(curl -L https://github.com/wg/wrk/raw/master/CHANGES 2>/dev/null | \
|
9
|
+
egrep '^wrk' | head -n 1 | awk '{print $2}') && \
|
10
|
+
echo $WRK_VERSION && \
|
11
|
+
mkdir /opt/wrk && \
|
12
|
+
cd /opt/wrk && \
|
13
|
+
curl -L https://github.com/wg/wrk/archive/$WRK_VERSION.tar.gz | \
|
14
|
+
tar zx --strip 1 && \
|
15
|
+
make && \
|
16
|
+
cp wrk /usr/local/bin/ && \
|
17
|
+
\
|
18
|
+
echo "===> Cleaning the system" && \
|
19
|
+
apt-get -f -y --auto-remove remove build-essential && \
|
20
|
+
apt-get clean && \
|
21
|
+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /opt/wrk/
|
22
|
+
|
23
|
+
# Setup directory
|
24
|
+
RUN mkdir /scripts
|
25
|
+
RUN mkdir /data
|
26
|
+
WORKDIR /scripts
|
27
|
+
|
28
|
+
# Add scripts
|
29
|
+
COPY ./include /vendor/dd-demo
|
30
|
+
COPY ./wrk/scripts /scripts
|
31
|
+
|
32
|
+
# Set entrypoint
|
33
|
+
ENTRYPOINT ["./entrypoint.sh"]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
bash /vendor/dd-demo/http-health-check
|
3
|
+
|
4
|
+
# Start the load test
|
5
|
+
echo "== Starting load test... =="
|
6
|
+
|
7
|
+
if [[ $# -eq 0 ]] ; then
|
8
|
+
echo "** No load test specified: pass wrk args as a command. **"
|
9
|
+
echo "== Load test aborted. =="
|
10
|
+
exit 1
|
11
|
+
else
|
12
|
+
COMMAND="wrk $@"
|
13
|
+
echo "Command: $COMMAND"
|
14
|
+
/bin/bash -c "$COMMAND"
|
15
|
+
echo "== Load test done. =="
|
16
|
+
exit 0
|
17
|
+
fi
|
@@ -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
|
@@ -48,7 +48,7 @@ module Datadog
|
|
48
48
|
# This prevents recursive loops while initializing.
|
49
49
|
# e.g. Get logger --> Build components --> Log message --> Repeat...
|
50
50
|
@temp_logger ||= begin
|
51
|
-
logger = configuration.logger.instance || Datadog::Logger.new(
|
51
|
+
logger = configuration.logger.instance || Datadog::Logger.new($stdout)
|
52
52
|
logger.level = configuration.diagnostics.debug ? ::Logger::DEBUG : configuration.logger.level
|
53
53
|
logger
|
54
54
|
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
|
@@ -51,6 +51,7 @@ module Datadog
|
|
51
51
|
def define_helpers(helpers)
|
52
52
|
helpers.each do |name, block|
|
53
53
|
next unless block.is_a?(Proc)
|
54
|
+
|
54
55
|
define_method(name, &block)
|
55
56
|
end
|
56
57
|
end
|
@@ -102,9 +103,7 @@ module Datadog
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def assert_valid_option!(name)
|
105
|
-
unless option_defined?(name)
|
106
|
-
raise(InvalidOptionError, "#{self.class.name} doesn't define the option: #{name}")
|
107
|
-
end
|
106
|
+
raise(InvalidOptionError, "#{self.class.name} doesn't define the option: #{name}") unless option_defined?(name)
|
108
107
|
end
|
109
108
|
end
|
110
109
|
|
@@ -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
|
@@ -36,9 +36,7 @@ module Datadog
|
|
36
36
|
|
37
37
|
begin
|
38
38
|
# Set the resource name, if it's still the default name
|
39
|
-
if span.resource == span.name
|
40
|
-
span.resource = "#{payload.fetch(:controller)}##{payload.fetch(:action)}"
|
41
|
-
end
|
39
|
+
span.resource = "#{payload.fetch(:controller)}##{payload.fetch(:action)}" if span.resource == span.name
|
42
40
|
|
43
41
|
# Set the resource name of the Rack request span unless this is an exception controller.
|
44
42
|
unless exception_controller?(payload)
|
@@ -12,7 +12,17 @@ module Datadog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def resolve(key)
|
15
|
-
normalize(
|
15
|
+
normalize(resolve_connection_key(key).symbolize_keys)
|
16
|
+
end
|
17
|
+
|
18
|
+
def resolve_connection_key(key)
|
19
|
+
result = connection_resolver.resolve(key)
|
20
|
+
|
21
|
+
if result.respond_to?(:configuration_hash) # Rails >= 6.1
|
22
|
+
result.configuration_hash
|
23
|
+
else # Rails < 6.1
|
24
|
+
result
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
def configurations
|
@@ -21,7 +31,9 @@ module Datadog
|
|
21
31
|
|
22
32
|
def connection_resolver
|
23
33
|
@resolver ||= begin
|
24
|
-
if defined?(::ActiveRecord::
|
34
|
+
if defined?(::ActiveRecord::Base.configurations.resolve)
|
35
|
+
::ActiveRecord::DatabaseConfigurations.new(configurations)
|
36
|
+
elsif defined?(::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver)
|
25
37
|
::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations)
|
26
38
|
else
|
27
39
|
::Datadog::Vendor::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations)
|
@@ -31,9 +43,9 @@ module Datadog
|
|
31
43
|
|
32
44
|
def normalize(hash)
|
33
45
|
{
|
34
|
-
adapter:
|
35
|
-
host:
|
36
|
-
port:
|
46
|
+
adapter: hash[:adapter],
|
47
|
+
host: hash[:host],
|
48
|
+
port: hash[:port],
|
37
49
|
database: hash[:database],
|
38
50
|
username: hash[:username]
|
39
51
|
}
|