ddtrace 0.45.0 → 0.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +79 -0
  3. data/.rubocop.yml +250 -7
  4. data/.rubocop_todo.yml +396 -0
  5. data/Appraisals +15 -0
  6. data/CHANGELOG.md +68 -1
  7. data/Gemfile +38 -3
  8. data/Rakefile +5 -23
  9. data/ddtrace.gemspec +6 -36
  10. data/docs/DevelopmentGuide.md +28 -0
  11. data/docs/GettingStarted.md +8 -9
  12. data/integration/README.md +68 -0
  13. data/integration/apps/rack/.dockerignore +1 -0
  14. data/integration/apps/rack/.envrc.sample +1 -0
  15. data/integration/apps/rack/.gitignore +4 -0
  16. data/integration/apps/rack/.rspec +1 -0
  17. data/integration/apps/rack/Dockerfile +25 -0
  18. data/integration/apps/rack/Dockerfile-ci +11 -0
  19. data/integration/apps/rack/Gemfile +24 -0
  20. data/integration/apps/rack/README.md +93 -0
  21. data/integration/apps/rack/app/acme.rb +80 -0
  22. data/integration/apps/rack/app/datadog.rb +17 -0
  23. data/integration/apps/rack/bin/run +22 -0
  24. data/integration/apps/rack/bin/setup +17 -0
  25. data/integration/apps/rack/bin/test +24 -0
  26. data/integration/apps/rack/config.ru +6 -0
  27. data/integration/apps/rack/config/puma.rb +14 -0
  28. data/integration/apps/rack/config/unicorn.rb +23 -0
  29. data/integration/apps/rack/docker-compose.ci.yml +62 -0
  30. data/integration/apps/rack/docker-compose.yml +78 -0
  31. data/integration/apps/rack/script/build-images +38 -0
  32. data/integration/apps/rack/script/ci +50 -0
  33. data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
  34. data/integration/apps/rack/spec/spec_helper.rb +16 -0
  35. data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
  36. data/integration/apps/rails-five/.dockerignore +1 -0
  37. data/integration/apps/rails-five/.env +3 -0
  38. data/integration/apps/rails-five/.envrc.sample +1 -0
  39. data/integration/apps/rails-five/.gitignore +30 -0
  40. data/integration/apps/rails-five/Dockerfile +25 -0
  41. data/integration/apps/rails-five/Dockerfile-ci +11 -0
  42. data/integration/apps/rails-five/Gemfile +104 -0
  43. data/integration/apps/rails-five/README.md +94 -0
  44. data/integration/apps/rails-five/Rakefile +6 -0
  45. data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
  46. data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
  47. data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
  48. data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
  49. data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
  50. data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
  51. data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
  52. data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
  53. data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
  54. data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
  55. data/integration/apps/rails-five/app/models/application_record.rb +3 -0
  56. data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
  57. data/integration/apps/rails-five/app/models/test.rb +2 -0
  58. data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
  59. data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
  60. data/integration/apps/rails-five/bin/bundle +3 -0
  61. data/integration/apps/rails-five/bin/rails +9 -0
  62. data/integration/apps/rails-five/bin/rake +9 -0
  63. data/integration/apps/rails-five/bin/run +24 -0
  64. data/integration/apps/rails-five/bin/setup +27 -0
  65. data/integration/apps/rails-five/bin/spring +17 -0
  66. data/integration/apps/rails-five/bin/test +21 -0
  67. data/integration/apps/rails-five/bin/update +28 -0
  68. data/integration/apps/rails-five/config.ru +5 -0
  69. data/integration/apps/rails-five/config/application.rb +97 -0
  70. data/integration/apps/rails-five/config/boot.rb +4 -0
  71. data/integration/apps/rails-five/config/cable.yml +10 -0
  72. data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
  73. data/integration/apps/rails-five/config/database.yml +28 -0
  74. data/integration/apps/rails-five/config/environment.rb +5 -0
  75. data/integration/apps/rails-five/config/environments/development.rb +51 -0
  76. data/integration/apps/rails-five/config/environments/production.rb +82 -0
  77. data/integration/apps/rails-five/config/environments/test.rb +43 -0
  78. data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
  79. data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
  80. data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
  81. data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
  82. data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
  83. data/integration/apps/rails-five/config/locales/en.yml +33 -0
  84. data/integration/apps/rails-five/config/puma.rb +24 -0
  85. data/integration/apps/rails-five/config/routes.rb +11 -0
  86. data/integration/apps/rails-five/config/spring.rb +6 -0
  87. data/integration/apps/rails-five/config/unicorn.rb +29 -0
  88. data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
  89. data/integration/apps/rails-five/db/schema.rb +23 -0
  90. data/integration/apps/rails-five/db/seeds.rb +7 -0
  91. data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
  92. data/integration/apps/rails-five/docker-compose.yml +100 -0
  93. data/integration/apps/rails-five/lib/tasks/.keep +0 -0
  94. data/integration/apps/rails-five/log/.keep +0 -0
  95. data/integration/apps/rails-five/public/robots.txt +1 -0
  96. data/integration/apps/rails-five/script/build-images +35 -0
  97. data/integration/apps/rails-five/script/ci +50 -0
  98. data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
  99. data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
  100. data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
  101. data/integration/apps/rails-five/storage/.keep +0 -0
  102. data/integration/apps/rails-five/tmp/.keep +0 -0
  103. data/integration/apps/rails-five/vendor/.keep +0 -0
  104. data/integration/apps/ruby/.dockerignore +1 -0
  105. data/integration/apps/ruby/.envrc.sample +1 -0
  106. data/integration/apps/ruby/.gitignore +2 -0
  107. data/integration/apps/ruby/Dockerfile +25 -0
  108. data/integration/apps/ruby/Dockerfile-ci +11 -0
  109. data/integration/apps/ruby/Gemfile +11 -0
  110. data/integration/apps/ruby/README.md +70 -0
  111. data/integration/apps/ruby/agent.yaml +3 -0
  112. data/integration/apps/ruby/app/datadog.rb +13 -0
  113. data/integration/apps/ruby/app/fibonacci.rb +58 -0
  114. data/integration/apps/ruby/bin/run +20 -0
  115. data/integration/apps/ruby/bin/setup +17 -0
  116. data/integration/apps/ruby/bin/test +21 -0
  117. data/integration/apps/ruby/docker-compose.ci.yml +51 -0
  118. data/integration/apps/ruby/docker-compose.yml +63 -0
  119. data/integration/apps/ruby/script/build-images +38 -0
  120. data/integration/apps/ruby/script/ci +50 -0
  121. data/integration/images/agent/Dockerfile +2 -0
  122. data/integration/images/agent/agent.yaml +3 -0
  123. data/integration/images/include/datadog/analyzer.rb +71 -0
  124. data/integration/images/include/datadog/demo_env.rb +101 -0
  125. data/integration/images/include/http-health-check +33 -0
  126. data/integration/images/ruby/2.0/Dockerfile +54 -0
  127. data/integration/images/ruby/2.1/Dockerfile +54 -0
  128. data/integration/images/ruby/2.2/Dockerfile +54 -0
  129. data/integration/images/ruby/2.3/Dockerfile +70 -0
  130. data/integration/images/ruby/2.4/Dockerfile +54 -0
  131. data/integration/images/ruby/2.5/Dockerfile +54 -0
  132. data/integration/images/ruby/2.6/Dockerfile +54 -0
  133. data/integration/images/ruby/2.7/Dockerfile +54 -0
  134. data/integration/images/ruby/3.0/Dockerfile +54 -0
  135. data/integration/images/wrk/Dockerfile +33 -0
  136. data/integration/images/wrk/scripts/entrypoint.sh +17 -0
  137. data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
  138. data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
  139. data/integration/script/build-images +43 -0
  140. data/lib/ddtrace.rb +0 -5
  141. data/lib/ddtrace/analytics.rb +2 -0
  142. data/lib/ddtrace/buffer.rb +4 -4
  143. data/lib/ddtrace/configuration.rb +1 -1
  144. data/lib/ddtrace/configuration/base.rb +1 -1
  145. data/lib/ddtrace/configuration/components.rb +2 -2
  146. data/lib/ddtrace/configuration/option_definition.rb +1 -3
  147. data/lib/ddtrace/configuration/options.rb +2 -3
  148. data/lib/ddtrace/configuration/settings.rb +17 -3
  149. data/lib/ddtrace/context.rb +5 -6
  150. data/lib/ddtrace/context_provider.rb +1 -0
  151. data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
  152. data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
  153. data/lib/ddtrace/contrib/action_view/event.rb +1 -1
  154. data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
  155. data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +17 -5
  156. data/lib/ddtrace/contrib/active_record/utils.rb +1 -0
  157. data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -1
  158. data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
  159. data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
  160. data/lib/ddtrace/contrib/auto_instrument.rb +1 -0
  161. data/lib/ddtrace/contrib/aws/patcher.rb +1 -0
  162. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  163. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +1 -4
  164. data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
  165. data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
  166. data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
  167. data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
  168. data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
  169. data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
  170. data/lib/ddtrace/contrib/ethon/easy_patch.rb +5 -5
  171. data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
  172. data/lib/ddtrace/contrib/extensions.rb +1 -0
  173. data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
  174. data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
  175. data/lib/ddtrace/contrib/grape/endpoint.rb +8 -15
  176. data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
  177. data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
  178. data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
  179. data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
  180. data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
  181. data/lib/ddtrace/contrib/http/instrumentation.rb +5 -5
  182. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +2 -3
  183. data/lib/ddtrace/contrib/httprb/instrumentation.rb +2 -3
  184. data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
  185. data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
  186. data/lib/ddtrace/contrib/patcher.rb +1 -1
  187. data/lib/ddtrace/contrib/qless/qless_job.rb +1 -0
  188. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +1 -0
  189. data/lib/ddtrace/contrib/que/ext.rb +19 -19
  190. data/lib/ddtrace/contrib/que/tracer.rb +1 -1
  191. data/lib/ddtrace/contrib/racecar/event.rb +1 -0
  192. data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
  193. data/lib/ddtrace/contrib/rack/middlewares.rb +5 -10
  194. data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
  195. data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
  196. data/lib/ddtrace/contrib/redis/quantize.rb +1 -0
  197. data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
  198. data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
  199. data/lib/ddtrace/contrib/registry.rb +2 -2
  200. data/lib/ddtrace/contrib/resque/resque_job.rb +2 -0
  201. data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
  202. data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
  203. data/lib/ddtrace/contrib/rspec/example.rb +24 -10
  204. data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
  205. data/lib/ddtrace/contrib/rspec/integration.rb +1 -1
  206. data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
  207. data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
  208. data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -1
  209. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -7
  210. data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
  211. data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
  212. data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
  213. data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
  214. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +3 -3
  215. data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
  216. data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
  217. data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
  218. data/lib/ddtrace/correlation.rb +1 -0
  219. data/lib/ddtrace/diagnostics/environment_logger.rb +2 -1
  220. data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
  221. data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
  222. data/lib/ddtrace/ext/ci.rb +2 -2
  223. data/lib/ddtrace/ext/distributed.rb +1 -1
  224. data/lib/ddtrace/ext/http.rb +1 -1
  225. data/lib/ddtrace/ext/runtime.rb +1 -1
  226. data/lib/ddtrace/forced_tracing.rb +2 -0
  227. data/lib/ddtrace/logger.rb +1 -1
  228. data/lib/ddtrace/metrics.rb +10 -6
  229. data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
  230. data/lib/ddtrace/opentracer/span.rb +2 -6
  231. data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
  232. data/lib/ddtrace/patcher.rb +2 -3
  233. data/lib/ddtrace/pin.rb +3 -52
  234. data/lib/ddtrace/pipeline/span_filter.rb +1 -1
  235. data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
  236. data/lib/ddtrace/quantization/http.rb +1 -0
  237. data/lib/ddtrace/runtime/cgroup.rb +1 -1
  238. data/lib/ddtrace/runtime/container.rb +2 -2
  239. data/lib/ddtrace/sampler.rb +1 -1
  240. data/lib/ddtrace/sampling/rule_sampler.rb +1 -0
  241. data/lib/ddtrace/span.rb +7 -7
  242. data/lib/ddtrace/sync_writer.rb +7 -10
  243. data/lib/ddtrace/tracer.rb +1 -1
  244. data/lib/ddtrace/transport/http.rb +1 -3
  245. data/lib/ddtrace/transport/http/adapters/net.rb +9 -4
  246. data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
  247. data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
  248. data/lib/ddtrace/transport/http/builder.rb +2 -0
  249. data/lib/ddtrace/transport/http/traces.rb +2 -3
  250. data/lib/ddtrace/transport/io.rb +1 -1
  251. data/lib/ddtrace/transport/traces.rb +3 -0
  252. data/lib/ddtrace/utils/time.rb +25 -1
  253. data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
  254. data/lib/ddtrace/version.rb +1 -1
  255. data/lib/ddtrace/workers.rb +5 -0
  256. data/lib/ddtrace/workers/async.rb +8 -0
  257. data/lib/ddtrace/workers/loop.rb +3 -0
  258. data/lib/ddtrace/workers/polling.rb +1 -0
  259. data/lib/ddtrace/workers/trace_writer.rb +9 -10
  260. data/lib/ddtrace/writer.rb +3 -3
  261. metadata +133 -400
  262. data/lib/ddtrace/augmentation.rb +0 -13
  263. data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
  264. data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
  265. data/lib/ddtrace/augmentation/shim.rb +0 -102
  266. data/lib/ddtrace/contrib/rspec/example_group.rb +0 -61
  267. data/lib/ddtrace/monkey.rb +0 -58
@@ -0,0 +1,62 @@
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/rack/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-rack
20
+ - DD_PROFILING_ENABLED=true
21
+ # Use these to choose what is run
22
+ - DD_DEMO_ENV_PROCESS=puma
23
+ - DD_DEMO_ENV_FEATURES=tracing
24
+ expose:
25
+ - "80"
26
+ stdin_open: true
27
+ tty: true
28
+ ddagent:
29
+ image: datadog/dd-apm-demo:agent
30
+ environment:
31
+ - DD_APM_ENABLED=true
32
+ - DD_PROCESS_AGENT_ENABLED=false
33
+ - DD_BIND_HOST=0.0.0.0
34
+ - DD_API_KEY=invalid_api_key
35
+ - LOG_LEVEL=DEBUG
36
+ - DD_LOGS_STDOUT=yes
37
+ - DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
38
+ expose:
39
+ - "8125/udp"
40
+ - "8126"
41
+ # Build at dd-trace-rb level to copy in current code
42
+ # and use it as the `ddtrace` gem.
43
+ integration-tester:
44
+ build:
45
+ context: ../../..
46
+ dockerfile: integration/apps/rack/Dockerfile-ci
47
+ args:
48
+ BASE_IMAGE: ${APP_IMAGE}
49
+ command: bin/test
50
+ depends_on:
51
+ - app
52
+ environment:
53
+ - TEST_HOSTNAME=app
54
+ - TEST_PORT=80
55
+ - TEST_INTEGRATION=true
56
+ - HEALTH_CHECK_URL=http://app/health
57
+ - HEALTH_CHECK_INTERVAL=1
58
+ - HEALTH_CHECK_MAX_ATTEMPTS=30
59
+ # volumes:
60
+ # - .:/app
61
+ # - ../../images/include:/vendor/dd-demo
62
+ # - ../../..:/vendor/dd-trace-rb
@@ -0,0 +1,78 @@
1
+ version: '3.4'
2
+ services:
3
+ app:
4
+ build:
5
+ context: .
6
+ args:
7
+ BASE_IMAGE: datadog/dd-apm-demo:rb-2.7
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-rack
17
+ - DD_PROFILING_ENABLED=true
18
+ # Use these to choose what is run
19
+ - DD_DEMO_ENV_PROCESS=puma
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
+ expose:
27
+ - "80"
28
+ stdin_open: true
29
+ tty: true
30
+ volumes:
31
+ - .:/app
32
+ - ./data/app:/data/app
33
+ - bundle:/usr/local/bundle
34
+ - ../../images/include:/vendor/dd-demo
35
+ - ../../..:/vendor/dd-trace-rb
36
+ ddagent:
37
+ image: datadog/dd-apm-demo:agent
38
+ environment:
39
+ - DD_APM_ENABLED=true
40
+ - DD_PROCESS_AGENT_ENABLED=false
41
+ - DD_BIND_HOST=0.0.0.0
42
+ - DD_API_KEY
43
+ - LOG_LEVEL=DEBUG
44
+ - DD_LOGS_STDOUT=yes
45
+ - DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
46
+ expose:
47
+ - "8125/udp"
48
+ - "8126"
49
+ volumes:
50
+ - ../../images/agent/agent.yaml:/etc/datadog-agent/datadog.yaml
51
+ # For monitoring performance of containers (e.g. CPU, Memory, etc...)
52
+ # - type: bind
53
+ # source: ../../images/agent/agent.yaml
54
+ # target: /etc/datadog-agent/datadog.yaml
55
+ # - type: bind
56
+ # source: /var/run/docker.sock
57
+ # target: /var/run/docker.sock:ro
58
+ # - type: bind
59
+ # source: /proc/
60
+ # target: /host/proc/:ro
61
+ # - type: bind
62
+ # source: /sys/fs/cgroup/
63
+ # target: /host/sys/fs/cgroup:ro
64
+ load-tester:
65
+ build:
66
+ context: ../../images
67
+ dockerfile: wrk/Dockerfile
68
+ command: -t10 -c10 -d43200s -s /scripts/scenarios/basic/default.lua http://app/basic/default
69
+ depends_on:
70
+ - app
71
+ environment:
72
+ - HEALTH_CHECK_URL=http://app/health
73
+ - HEALTH_CHECK_INTERVAL=1
74
+ - HEALTH_CHECK_MAX_ATTEMPTS=30
75
+ volumes:
76
+ - ../../images/wrk/scripts:/scripts
77
+ volumes:
78
+ 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 Rack 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-rack .
27
+ else
28
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.0 -t datadog/dd-apm-demo:rb-2.0-rack .
29
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.1 -t datadog/dd-apm-demo:rb-2.1-rack .
30
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.2 -t datadog/dd-apm-demo:rb-2.2-rack .
31
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.3 -t datadog/dd-apm-demo:rb-2.3-rack .
32
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.4 -t datadog/dd-apm-demo:rb-2.4-rack .
33
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.5 -t datadog/dd-apm-demo:rb-2.5-rack .
34
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.6 -t datadog/dd-apm-demo:rb-2.6-rack .
35
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-2.7 -t datadog/dd-apm-demo:rb-2.7-rack .
36
+ docker build --build-arg BASE_IMAGE=datadog/dd-apm-demo:rb-3.0 -t datadog/dd-apm-demo:rb-3.0-rack .
37
+ fi
38
+ echo "== Done building Rack 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-rack}
34
+ APP_COMPOSE_FILES="-f docker-compose.ci.yml"
35
+
36
+ echo "== Running integration tests... =="
37
+ echo " - App: rack"
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,10 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Basic scenarios' do
4
+ include_context 'integration test'
5
+
6
+ context 'default' do
7
+ subject { get('basic/default') }
8
+ it { is_expected.to be_a_kind_of(Net::HTTPOK) }
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ require 'byebug'
2
+ require 'support/integration_helper'
3
+
4
+ RSpec.configure do |config|
5
+ config.include IntegrationHelper
6
+
7
+ config.expect_with :rspec do |expectations|
8
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
+ end
10
+
11
+ config.mock_with :rspec do |mocks|
12
+ mocks.verify_partial_doubles = true
13
+ end
14
+
15
+ config.shared_context_metadata_behavior = :apply_to_host_groups
16
+ end
@@ -0,0 +1,22 @@
1
+ require 'net/http'
2
+
3
+ module IntegrationHelper
4
+ shared_context 'integration test' do
5
+ before do
6
+ skip 'Integration tests not enabled.' unless ENV['TEST_INTEGRATION']
7
+ end
8
+
9
+ def hostname
10
+ ENV['TEST_HOSTNAME']
11
+ end
12
+
13
+ def port
14
+ ENV['TEST_PORT']
15
+ end
16
+
17
+ def get(path)
18
+ uri = URI("http://#{hostname}:#{port}/#{path}")
19
+ Net::HTTP.get_response(uri)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ DD_AGENT_HOST=localhost
2
+ DD_METRIC_AGENT_PORT=8125
3
+ DD_TRACE_AGENT_PORT=8126
@@ -0,0 +1 @@
1
+ export DD_API_KEY=<Your Datadog API key here>
@@ -0,0 +1,30 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*
12
+ /tmp/*
13
+ !/log/.keep
14
+ !/tmp/.keep
15
+
16
+ # Ignore uploaded files in development
17
+ /storage/*
18
+ !/storage/.keep
19
+
20
+ .byebug_history
21
+
22
+ # Ignore master key for decrypting credentials and more.
23
+ /config/master.key
24
+
25
+ # Ignore local data
26
+ /data
27
+ *.pprof
28
+
29
+ # Ignore local variables
30
+ .envrc
@@ -0,0 +1,25 @@
1
+ # Select base image
2
+ ARG BASE_IMAGE
3
+ FROM ${BASE_IMAGE}
4
+
5
+ # Setup directory
6
+ RUN mkdir /app
7
+ WORKDIR /app
8
+
9
+ # Setup specific version of ddtrace, if specified.
10
+ ARG ddtrace_git
11
+ ENV DD_DEMO_ENV_GEM_GIT_DDTRACE ${ddtrace_git}
12
+
13
+ ARG ddtrace_ref
14
+ ENV DD_DEMO_ENV_GEM_REF_DDTRACE ${ddtrace_ref}
15
+
16
+ # Install dependencies
17
+ COPY Gemfile /app/Gemfile
18
+ RUN bundle install
19
+
20
+ # Add files
21
+ COPY . /app
22
+
23
+ # Set entrypoint
24
+ ENTRYPOINT ["/bin/bash", "-c"]
25
+ CMD ["bin/setup && bin/run"]
@@ -0,0 +1,11 @@
1
+ # Select base image
2
+ ARG BASE_IMAGE
3
+ FROM ${BASE_IMAGE}
4
+
5
+ # Add gem
6
+ COPY . /vendor/dd-trace-rb
7
+
8
+ # Install dependencies
9
+ # Setup specific version of ddtrace, if specified.
10
+ ENV DD_DEMO_ENV_GEM_LOCAL_DDTRACE /vendor/dd-trace-rb
11
+ RUN bundle install
@@ -0,0 +1,104 @@
1
+ require 'datadog/demo_env'
2
+
3
+ source 'https://rubygems.org' do
4
+ # Framework dependent gems
5
+ # gem 'rails', '5.2.2'
6
+
7
+ google_protobuf_versions = [
8
+ '~> 3.0',
9
+ '!= 3.7.0.rc.2',
10
+ '!= 3.7.0.rc.3',
11
+ '!= 3.7.0',
12
+ '!= 3.7.1',
13
+ '!= 3.8.0.rc.1'
14
+ ]
15
+
16
+ # gem 'rack', '2.1.4' # Ruby 2.2 compatibility
17
+ gem 'actioncable', '5.2.2'
18
+ gem 'actionmailer', '5.2.2'
19
+ gem 'actionpack', '5.2.2'
20
+ gem 'actionview', '5.2.2'
21
+ gem 'activejob', '5.2.2'
22
+ gem 'activemodel', '5.2.2'
23
+ gem 'activerecord', '5.2.2'
24
+ gem 'railties', '5.2.2'
25
+
26
+ gem 'mysql2'
27
+ gem 'puma'
28
+ gem 'unicorn'
29
+
30
+ # Choose correct specs for 'ddtrace' demo environment
31
+ gem 'ddtrace', *Datadog::DemoEnv.gem_spec('ddtrace')
32
+
33
+ gem 'dogstatsd-ruby'
34
+ gem 'ffi'
35
+ gem 'google-protobuf', *google_protobuf_versions # Ruby 2.2 compatibility
36
+ # gem 'rbtrace'
37
+ # gem 'ruby-prof'
38
+
39
+ # Fixes conflict with profiling (patch overwrite in Thread)
40
+ # Upgrade this to latest when this patch is merged & released.
41
+ # https://github.com/rollbar/rollbar-gem/pull/1018
42
+ gem 'rollbar', git: 'https://github.com/rollbar/rollbar-gem.git', ref: '310a9d1743bb44031480b49e8e0cef79ddc870c3'
43
+
44
+ # Gems which give aide to higher performance
45
+ gem 'hiredis', '~> 0.6', platform: :ruby
46
+ gem 'multi_json'
47
+ gem 'oj', '3.3', platform: :ruby
48
+
49
+ gem 'active_model_serializers', '0.9.3'
50
+ gem 'activerecord-import' # Speeds up mass imports
51
+ gem 'aws-sdk', '< 2.0'
52
+ gem 'bcrypt-ruby', platform: :ruby
53
+ gem 'connection_pool'
54
+ gem 'devise'
55
+ gem 'faker', require: false # Make up fake data to put in models for load testing
56
+ gem 'geoip'
57
+ gem 'hawk-auth'
58
+ gem 'httparty'
59
+ gem 'ipaddress'
60
+ # gem 'i18n', '1.5.1' # Ruby 2.2 compatibility
61
+ # gem 'newrelic_rpm', platform: :ruby
62
+ gem 'rabl', platform: :ruby
63
+ gem 'rack-cors'
64
+ gem 'rake'
65
+ gem 'redis'
66
+ gem 'resque'
67
+ # gem 'resque-pool' # Incompatible with Redis 4.0+
68
+ gem 'resque-scheduler'
69
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
70
+ gem 'validates_timeliness', '~> 3.0.8' # Date comparisons
71
+ gem 'versionist'
72
+ gem 'warden'
73
+
74
+ group :development do
75
+ gem 'annotate'
76
+ gem 'awesome_print'
77
+ gem 'bullet'
78
+ end
79
+
80
+ group :test do
81
+ gem 'ci_reporter_rspec'
82
+ gem 'database_cleaner'
83
+ gem 'factory_girl_rails', '4.5.0'
84
+ gem 'rspec'
85
+ gem 'rspec-collection_matchers'
86
+ gem 'rspec-rails'
87
+ gem 'shoulda-matchers', '4.0.1'
88
+ gem 'simplecov', require: false # Will install simplecov-html as a dependency
89
+ gem 'timecop'
90
+ gem 'webmock'
91
+ end
92
+
93
+ group :test, :development do
94
+ # gem 'pry-rails', platform: :ruby
95
+ # gem 'pry-rescue', platform: :ruby
96
+ # gem 'pry-stack_explorer', platform: :ruby
97
+ # gem 'pry-byebug', platform: :ruby
98
+ gem 'byebug', platform: :ruby
99
+ gem 'mock_redis', '0.19.0'
100
+ gem 'parallel_tests'
101
+
102
+ gem 'listen'
103
+ end
104
+ end