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,13 @@
|
|
1
|
+
require 'datadog/demo_env'
|
2
|
+
require 'ddtrace'
|
3
|
+
|
4
|
+
Datadog.configure do |c|
|
5
|
+
c.diagnostics.debug = true if Datadog::DemoEnv.feature?('debug')
|
6
|
+
c.analytics_enabled = true if Datadog::DemoEnv.feature?('analytics')
|
7
|
+
c.runtime_metrics.enabled = true if Datadog::DemoEnv.feature?('runtime_metrics')
|
8
|
+
|
9
|
+
if Datadog::DemoEnv.feature?('pprof_to_file')
|
10
|
+
# Reconfigure transport to write pprof to file
|
11
|
+
c.profiling.exporter.transport = Datadog::DemoEnv.profiler_file_transport
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'datadog'
|
2
|
+
|
3
|
+
def fib(n)
|
4
|
+
n <= 1 ? n : fib(n-1) + fib(n-2)
|
5
|
+
end
|
6
|
+
|
7
|
+
def trace(*options, &block)
|
8
|
+
raise ArgumentError('Must provide trace block') unless block_given?
|
9
|
+
|
10
|
+
if Datadog::DemoEnv.feature?('tracing')
|
11
|
+
Datadog.tracer.trace(*options, &block)
|
12
|
+
else
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_fib
|
18
|
+
loop do
|
19
|
+
n = rand(25..35)
|
20
|
+
|
21
|
+
trace('compute.fibonacci') do |span|
|
22
|
+
result = fib(n)
|
23
|
+
span.set_metric('operation.fibonacci.n', n)
|
24
|
+
span.set_metric('operation.fibonacci.result', result)
|
25
|
+
yield(span) if block_given?
|
26
|
+
end
|
27
|
+
|
28
|
+
sleep(0.1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if defined?(Ractor)
|
33
|
+
# Ractor version
|
34
|
+
# DEV: Disabled for now because Ractors cannot access ENV.
|
35
|
+
# This results in a shareable-object violation.
|
36
|
+
# Enable when we figure out how to make DemoEnv ractor-safe.
|
37
|
+
|
38
|
+
# require 'securerandom'
|
39
|
+
# ractors = []
|
40
|
+
|
41
|
+
# 3.times do |i|
|
42
|
+
# ractors << Ractor.new do
|
43
|
+
# ractor_id = SecureRandom.uuid
|
44
|
+
# generate_fib { |span| span.set_tag('ractor.id', ractor_id) }
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
# # Wait indefinitely for ractors
|
49
|
+
# loop do
|
50
|
+
# ractors.collect(&:take)
|
51
|
+
# end
|
52
|
+
|
53
|
+
# DEV: Use single-threaded version instead for now...
|
54
|
+
generate_fib
|
55
|
+
else
|
56
|
+
# Single-threaded version
|
57
|
+
generate_fib
|
58
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Start application process
|
4
|
+
puts "\n== Starting application process =="
|
5
|
+
|
6
|
+
profiling = Datadog::DemoEnv.feature?('profiling') ? 'DD_PROFILING_ENABLED=true ddtracerb exec ' : ''
|
7
|
+
process = (ARGV[0] || Datadog::DemoEnv.process)
|
8
|
+
command = case process
|
9
|
+
when 'fibonacci'
|
10
|
+
'bundle exec ruby app/fibonacci.rb'
|
11
|
+
when 'irb'
|
12
|
+
"bundle exec #{profiling}irb"
|
13
|
+
when nil, ''
|
14
|
+
abort("\n== ERROR: Must specify a application process! ==")
|
15
|
+
else
|
16
|
+
abort("\n== ERROR: Unknown application process '#{process}' ==")
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Run: #{command}"
|
20
|
+
Kernel.exec(command)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
puts "Run: #{args.join(' ')}"
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
puts "\n== Installing dependencies =="
|
15
|
+
system! 'gem install bundler --conservative'
|
16
|
+
system('bundle check') || system!('bundle install')
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
puts "Run: #{args.join(' ')}"
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
puts "\n== Performing setup =="
|
15
|
+
system!('./bin/setup')
|
16
|
+
|
17
|
+
puts "\n== Run test suite =="
|
18
|
+
# DEV: There are no RSpec tests right now.
|
19
|
+
# Re-enable this when we have something worth testing.
|
20
|
+
# system!('rspec')
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
version: '3.4'
|
2
|
+
services:
|
3
|
+
app:
|
4
|
+
# Build at dd-trace-rb level to copy in current code
|
5
|
+
# and use it as the `ddtrace` gem.
|
6
|
+
build:
|
7
|
+
context: ../../..
|
8
|
+
dockerfile: integration/apps/ruby/Dockerfile-ci
|
9
|
+
args:
|
10
|
+
BASE_IMAGE: ${APP_IMAGE}
|
11
|
+
depends_on:
|
12
|
+
- ddagent
|
13
|
+
environment:
|
14
|
+
- BUNDLE_GEMFILE=/app/Gemfile
|
15
|
+
- DD_AGENT_HOST=ddagent
|
16
|
+
- DD_METRIC_AGENT_PORT=8125
|
17
|
+
- DD_TRACE_AGENT_PORT=8126
|
18
|
+
- DD_HEALTH_METRICS_ENABLED=true
|
19
|
+
- DD_SERVICE=acme-ruby
|
20
|
+
- DD_PROFILING_ENABLED=true
|
21
|
+
# Use these to choose what is run
|
22
|
+
- DD_DEMO_ENV_PROCESS=fibonacci
|
23
|
+
- DD_DEMO_ENV_FEATURES=tracing
|
24
|
+
stdin_open: true
|
25
|
+
tty: true
|
26
|
+
ddagent:
|
27
|
+
image: datadog/dd-apm-demo:agent
|
28
|
+
environment:
|
29
|
+
- DD_APM_ENABLED=true
|
30
|
+
- DD_PROCESS_AGENT_ENABLED=false
|
31
|
+
- DD_BIND_HOST=0.0.0.0
|
32
|
+
- DD_API_KEY=invalid_api_key
|
33
|
+
- LOG_LEVEL=DEBUG
|
34
|
+
- DD_LOGS_STDOUT=yes
|
35
|
+
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
|
36
|
+
expose:
|
37
|
+
- "8125/udp"
|
38
|
+
- "8126"
|
39
|
+
# Build at dd-trace-rb level to copy in current code
|
40
|
+
# and use it as the `ddtrace` gem.
|
41
|
+
integration-tester:
|
42
|
+
build:
|
43
|
+
context: ../../..
|
44
|
+
dockerfile: integration/apps/ruby/Dockerfile-ci
|
45
|
+
args:
|
46
|
+
BASE_IMAGE: ${APP_IMAGE}
|
47
|
+
command: bin/test
|
48
|
+
# volumes:
|
49
|
+
# - .:/app
|
50
|
+
# - ../../images/include:/vendor/dd-demo
|
51
|
+
# - ../../..:/vendor/dd-trace-rb
|
@@ -0,0 +1,63 @@
|
|
1
|
+
version: '3.4'
|
2
|
+
services:
|
3
|
+
app:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
args:
|
7
|
+
BASE_IMAGE: datadog/dd-apm-demo:rb-3.0
|
8
|
+
depends_on:
|
9
|
+
- ddagent
|
10
|
+
environment:
|
11
|
+
- BUNDLE_GEMFILE=/app/Gemfile
|
12
|
+
- DD_AGENT_HOST=ddagent
|
13
|
+
- DD_METRIC_AGENT_PORT=8125
|
14
|
+
- DD_TRACE_AGENT_PORT=8126
|
15
|
+
- DD_HEALTH_METRICS_ENABLED=true
|
16
|
+
- DD_SERVICE=acme-ruby
|
17
|
+
- DD_PROFILING_ENABLED=true
|
18
|
+
# Use these to choose what is run
|
19
|
+
- DD_DEMO_ENV_PROCESS=fibonacci
|
20
|
+
- DD_DEMO_ENV_FEATURES=tracing
|
21
|
+
# Use this for a local version of ddtrace
|
22
|
+
- DD_DEMO_ENV_GEM_LOCAL_DDTRACE=/vendor/dd-trace-rb
|
23
|
+
# Use these for a specific revision of ddtrace
|
24
|
+
# - DD_DEMO_ENV_GEM_GIT_DDTRACE=https://github.com/DataDog/dd-trace-rb.git
|
25
|
+
# - DD_DEMO_ENV_GEM_REF_DDTRACE=f233336994315bfa04dac581387a8152bab8b85a
|
26
|
+
stdin_open: true
|
27
|
+
tty: true
|
28
|
+
volumes:
|
29
|
+
- .:/app
|
30
|
+
- ./data/app:/data/app
|
31
|
+
- bundle:/usr/local/bundle
|
32
|
+
- ../../images/include:/vendor/dd-demo
|
33
|
+
- ../../..:/vendor/dd-trace-rb
|
34
|
+
ddagent:
|
35
|
+
image: datadog/dd-apm-demo:agent
|
36
|
+
environment:
|
37
|
+
- DD_APM_ENABLED=true
|
38
|
+
- DD_PROCESS_AGENT_ENABLED=false
|
39
|
+
- DD_BIND_HOST=0.0.0.0
|
40
|
+
- DD_API_KEY
|
41
|
+
- LOG_LEVEL=DEBUG
|
42
|
+
- DD_LOGS_STDOUT=yes
|
43
|
+
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
|
44
|
+
expose:
|
45
|
+
- "8125/udp"
|
46
|
+
- "8126"
|
47
|
+
volumes:
|
48
|
+
- ../../images/agent/agent.yaml:/etc/datadog-agent/datadog.yaml
|
49
|
+
# For monitoring performance of containers (e.g. CPU, Memory, etc...)
|
50
|
+
# - type: bind
|
51
|
+
# source: ../../images/agent/agent.yaml
|
52
|
+
# target: /etc/datadog-agent/datadog.yaml
|
53
|
+
# - type: bind
|
54
|
+
# source: /var/run/docker.sock
|
55
|
+
# target: /var/run/docker.sock:ro
|
56
|
+
# - type: bind
|
57
|
+
# source: /proc/
|
58
|
+
# target: /host/proc/:ro
|
59
|
+
# - type: bind
|
60
|
+
# source: /sys/fs/cgroup/
|
61
|
+
# target: /host/sys/fs/cgroup:ro
|
62
|
+
volumes:
|
63
|
+
bundle:
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
|
4
|
+
APP_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
5
|
+
APP_DIR=${APP_SCRIPT_DIR%/script}
|
6
|
+
cd $APP_DIR
|
7
|
+
|
8
|
+
while getopts ":v:" opt; do
|
9
|
+
case $opt in
|
10
|
+
v)
|
11
|
+
APP_RUBY_VERSION=$OPTARG
|
12
|
+
;;
|
13
|
+
\?)
|
14
|
+
echo "Invalid option: -$OPTARG" >&2
|
15
|
+
exit 1
|
16
|
+
;;
|
17
|
+
:)
|
18
|
+
echo "Option -$OPTARG requires an argument." >&2
|
19
|
+
exit 1
|
20
|
+
;;
|
21
|
+
esac
|
22
|
+
done
|
23
|
+
|
24
|
+
echo "== Building Ruby app images... =="
|
25
|
+
if [ -v APP_RUBY_VERSION ]; then
|
26
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-$APP_RUBY_VERSION -t datadog/dd-apm-demo:rb-$APP_RUBY_VERSION-ruby .
|
27
|
+
else
|
28
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.0 -t datadog/dd-apm-demo:rb-2.0-ruby .
|
29
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.1 -t datadog/dd-apm-demo:rb-2.1-ruby .
|
30
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.2 -t datadog/dd-apm-demo:rb-2.2-ruby .
|
31
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.3 -t datadog/dd-apm-demo:rb-2.3-ruby .
|
32
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.4 -t datadog/dd-apm-demo:rb-2.4-ruby .
|
33
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.5 -t datadog/dd-apm-demo:rb-2.5-ruby .
|
34
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.6 -t datadog/dd-apm-demo:rb-2.6-ruby .
|
35
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.7 -t datadog/dd-apm-demo:rb-2.7-ruby .
|
36
|
+
docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-3.0 -t datadog/dd-apm-demo:rb-3.0-ruby .
|
37
|
+
fi
|
38
|
+
echo "== Done building Ruby app images. =="
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
|
4
|
+
APP_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
5
|
+
APP_DIR=${APP_SCRIPT_DIR%/script}
|
6
|
+
cd $APP_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
|
+
# Validate options
|
26
|
+
if [ -z ${APP_RUBY_VERSION+x} ]; then
|
27
|
+
echo "You must specify a Ruby version with -v. (e.g. 2.7)" >&2
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
|
31
|
+
# Set configuration
|
32
|
+
APP_BASE_IMAGE=${APP_BASE_IMAGE:-datadog/dd-apm-demo:rb-$APP_RUBY_VERSION}
|
33
|
+
APP_IMAGE=${APP_IMAGE:-$APP_BASE_IMAGE-ruby}
|
34
|
+
APP_COMPOSE_FILES="-f docker-compose.ci.yml"
|
35
|
+
|
36
|
+
echo "== Running integration tests... =="
|
37
|
+
echo " - App: ruby"
|
38
|
+
echo " - Ruby version: $APP_RUBY_VERSION"
|
39
|
+
echo " - Base image: $APP_BASE_IMAGE"
|
40
|
+
echo " - App image: $APP_IMAGE"
|
41
|
+
echo ""
|
42
|
+
|
43
|
+
# Pull/build any missing images
|
44
|
+
APP_IMAGE=$APP_IMAGE docker-compose $APP_COMPOSE_FILES build
|
45
|
+
|
46
|
+
# Run the test suite
|
47
|
+
APP_IMAGE=$APP_IMAGE docker-compose $APP_COMPOSE_FILES run integration-tester
|
48
|
+
|
49
|
+
# Cleanup
|
50
|
+
APP_IMAGE=$APP_IMAGE docker-compose $APP_COMPOSE_FILES down -t 0 --remove-orphans
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Analyzer
|
4
|
+
def initialize(filename)
|
5
|
+
@filename = filename
|
6
|
+
end
|
7
|
+
|
8
|
+
def analyze
|
9
|
+
data = []
|
10
|
+
File.open(@filename) do |f|
|
11
|
+
f.each_line do |line|
|
12
|
+
data << (parsed=JSON.parse(line))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
data.group_by{ |row| row['generation'] }
|
17
|
+
.sort{|a,b| a[0].to_i <=> b[0].to_i }
|
18
|
+
.each do |k,v|
|
19
|
+
puts "location #{k} objects #{v.count}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def analyze_objects(gen_range = nil)
|
24
|
+
data = []
|
25
|
+
File.open(@filename) do |f|
|
26
|
+
f.each_line do |line|
|
27
|
+
parsed = JSON.parse(line)
|
28
|
+
if gen_range && gen_range.include?(parsed['generation'].to_i)
|
29
|
+
data << parsed
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
data.group_by{ |row| "#{row['file']}:#{row['line']}" }
|
35
|
+
.sort{|a,b| b[1].length <=> a[1].length }
|
36
|
+
.each do |k,v|
|
37
|
+
puts "line #{k} objects #{v.count}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def analyze_generation(gen)
|
42
|
+
data = []
|
43
|
+
File.open(@filename) do |f|
|
44
|
+
f.each_line do |line|
|
45
|
+
parsed=JSON.parse(line)
|
46
|
+
data << parsed if parsed["generation"] == gen
|
47
|
+
end
|
48
|
+
end
|
49
|
+
data.group_by{|row| "#{row["file"]}:#{row["line"]}"}
|
50
|
+
.sort{|a,b| b[1].count <=> a[1].count}
|
51
|
+
.each do |k,v|
|
52
|
+
puts "#{k} * #{v.count}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if ARGV[1]
|
58
|
+
if ARGV[1] == 'objects'
|
59
|
+
range = nil
|
60
|
+
if ARGV[2]
|
61
|
+
range_end = ARGV[2].to_i
|
62
|
+
range_start = ARGV[3].to_i
|
63
|
+
range = Range.new(range_start, range_end)
|
64
|
+
end
|
65
|
+
Analyzer.new(ARGV[0]).analyze_objects(range)
|
66
|
+
else
|
67
|
+
Analyzer.new(ARGV[0]).analyze_generation(ARGV[1].to_i)
|
68
|
+
end
|
69
|
+
else
|
70
|
+
Analyzer.new(ARGV[0]).analyze
|
71
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Datadog
|
2
|
+
module DemoEnv
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def gem_spec(gem_name, defaults = {})
|
6
|
+
args = if local_gem(gem_name)
|
7
|
+
[local_gem(gem_name)]
|
8
|
+
elsif git_gem(gem_name)
|
9
|
+
[git_gem(gem_name)]
|
10
|
+
else
|
11
|
+
[]
|
12
|
+
end
|
13
|
+
|
14
|
+
yield(args) if block_given?
|
15
|
+
|
16
|
+
args
|
17
|
+
end
|
18
|
+
|
19
|
+
def gem_env_name(gem_name)
|
20
|
+
gem_name.upcase.gsub('-', '_')
|
21
|
+
end
|
22
|
+
|
23
|
+
def local_gem(gem_name)
|
24
|
+
local_env_name = "DD_DEMO_ENV_GEM_LOCAL_#{gem_env_name(gem_name)}"
|
25
|
+
|
26
|
+
return unless ENV.key?(local_env_name)
|
27
|
+
|
28
|
+
{ path: ENV[local_env_name] }
|
29
|
+
end
|
30
|
+
|
31
|
+
def git_gem(gem_name)
|
32
|
+
git_env_name = "DD_DEMO_ENV_GEM_GIT_#{gem_env_name(gem_name)}"
|
33
|
+
ref_env_name = "DD_DEMO_ENV_GEM_REF_#{gem_env_name(gem_name)}"
|
34
|
+
|
35
|
+
return unless [git_env_name, ref_env_name].all? { |var| ENV.key?(var) && !ENV[var].empty? }
|
36
|
+
|
37
|
+
{ git: ENV[git_env_name], ref: ENV[ref_env_name] }
|
38
|
+
end
|
39
|
+
|
40
|
+
def process
|
41
|
+
ENV['DD_DEMO_ENV_PROCESS']
|
42
|
+
end
|
43
|
+
|
44
|
+
def features
|
45
|
+
(ENV['DD_DEMO_ENV_FEATURES'] || '').split(',')
|
46
|
+
end
|
47
|
+
|
48
|
+
def feature?(feature)
|
49
|
+
features.include?(feature)
|
50
|
+
end
|
51
|
+
|
52
|
+
def print_env(header = 'Datadog test environment')
|
53
|
+
puts "\n==== #{header} ===="
|
54
|
+
puts "Process: #{process}"
|
55
|
+
puts "Features: #{features}"
|
56
|
+
puts "Rails env: #{ENV['RAILS_ENV']}" if ENV['RAILS_ENV']
|
57
|
+
puts "PID: #{Process.pid}"
|
58
|
+
if ddtrace = Gem.loaded_specs['ddtrace']
|
59
|
+
puts "Runtime ID: #{Datadog::Runtime::Identity.id}" if defined?(Datadog::Runtime::Identity)
|
60
|
+
puts "ddtrace version: #{ddtrace.version}"
|
61
|
+
puts "ddtrace path: #{ddtrace.full_gem_path}"
|
62
|
+
if git_spec = git_gem('ddtrace')
|
63
|
+
puts "ddtrace git: #{git_spec[:git]}"
|
64
|
+
puts "ddtrace ref: #{git_spec[:ref]}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
puts "\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
def profiler_file_transport(dump_path = "/data/profile-pid-#{Process.pid}.pprof")
|
71
|
+
Datadog::Profiling::Transport::IO.default(
|
72
|
+
write: ->(out, data) do
|
73
|
+
result = nil
|
74
|
+
puts "Writing pprof #{dump_path}..."
|
75
|
+
File.open(dump_path, "w") { |f| result = f.write(data) }
|
76
|
+
puts "Pprof #{dump_path} written!"
|
77
|
+
result
|
78
|
+
end
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def start_mem_dump!
|
83
|
+
require 'objspace'
|
84
|
+
ObjectSpace.trace_object_allocations_start
|
85
|
+
end
|
86
|
+
|
87
|
+
def finish_mem_dump!(dump_path = "/data/mem-pid-#{Process.pid}.dump")
|
88
|
+
File.delete(dump_path) if File.exist?(dump_path)
|
89
|
+
File.open(dump_path, "w") do |io|
|
90
|
+
ObjectSpace.dump_all(output: io)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def mem_dump!(dump_path = "/data/mem-pid-#{Process.pid}.dump")
|
95
|
+
start_mem_dump!
|
96
|
+
result = yield
|
97
|
+
finish_mem_dump!
|
98
|
+
result
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|