ddtrace 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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
|
@@ -23,6 +23,7 @@ module Datadog
|
|
|
23
23
|
return unless respond_to? :cluster
|
|
24
24
|
return unless cluster.respond_to? :addresses
|
|
25
25
|
return unless cluster.addresses.respond_to? :first
|
|
26
|
+
|
|
26
27
|
Datadog::Pin.get_from(cluster.addresses.first)
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -31,6 +32,7 @@ module Datadog
|
|
|
31
32
|
return unless respond_to? :cluster
|
|
32
33
|
return unless cluster.respond_to? :addresses
|
|
33
34
|
return unless cluster.addresses.respond_to? :each
|
|
35
|
+
|
|
34
36
|
# attach the PIN to all cluster addresses. One of them is used
|
|
35
37
|
# when executing a Command and it is attached to the Monitoring
|
|
36
38
|
# Event instance.
|
|
@@ -29,9 +29,7 @@ module Datadog
|
|
|
29
29
|
span.set_tag(Datadog::Ext::Integration::TAG_PEER_SERVICE, span.service)
|
|
30
30
|
|
|
31
31
|
# Set analytics sample rate
|
|
32
|
-
if analytics_enabled?
|
|
33
|
-
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
|
34
|
-
end
|
|
32
|
+
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
|
35
33
|
|
|
36
34
|
# add operation tags; the full query is stored and used as a resource,
|
|
37
35
|
# since it has been quantized and reduced
|
|
@@ -92,6 +90,7 @@ module Datadog
|
|
|
92
90
|
|
|
93
91
|
def clear_span(event)
|
|
94
92
|
return if Thread.current[:datadog_mongo_span].nil?
|
|
93
|
+
|
|
95
94
|
Thread.current[:datadog_mongo_span].delete(event.request_id)
|
|
96
95
|
end
|
|
97
96
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
require 'ddtrace/
|
|
1
|
+
require 'ddtrace/utils/only_once'
|
|
2
2
|
|
|
3
3
|
module Datadog
|
|
4
4
|
module Contrib
|
|
5
5
|
# Common behavior for patcher modules
|
|
6
6
|
module Patcher
|
|
7
7
|
def self.included(base)
|
|
8
|
-
base.send(:include, Datadog::Patcher)
|
|
9
|
-
|
|
10
8
|
base.singleton_class.send(:prepend, CommonMethods)
|
|
11
|
-
base.send(:prepend, CommonMethods) if base.
|
|
9
|
+
base.send(:prepend, CommonMethods) if base.instance_of?(Class)
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
# Prepended instance methods for all patchers
|
|
@@ -18,13 +16,13 @@ module Datadog
|
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
def patched?
|
|
21
|
-
|
|
19
|
+
patch_only_once.ran?
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
def patch
|
|
25
23
|
return unless defined?(super)
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
patch_only_once.run do
|
|
28
26
|
begin
|
|
29
27
|
super.tap do
|
|
30
28
|
# Emit a metric
|
|
@@ -56,6 +54,11 @@ module Datadog
|
|
|
56
54
|
tags << "target_version:#{target_version}" if respond_to?(:target_version) && !target_version.nil?
|
|
57
55
|
end
|
|
58
56
|
end
|
|
57
|
+
|
|
58
|
+
def patch_only_once
|
|
59
|
+
# NOTE: This is not thread-safe
|
|
60
|
+
@patch_only_once ||= Datadog::Utils::OnlyOnce.new
|
|
61
|
+
end
|
|
59
62
|
end
|
|
60
63
|
end
|
|
61
64
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'ddtrace/contrib/patcher'
|
|
2
2
|
require 'ddtrace/contrib/presto/ext'
|
|
3
3
|
require 'ddtrace/contrib/presto/instrumentation'
|
|
4
|
+
require 'ddtrace/utils/only_once'
|
|
4
5
|
|
|
5
6
|
module Datadog
|
|
6
7
|
module Contrib
|
|
@@ -9,14 +10,16 @@ module Datadog
|
|
|
9
10
|
module Patcher
|
|
10
11
|
include Contrib::Patcher
|
|
11
12
|
|
|
13
|
+
PATCH_ONLY_ONCE = Datadog::Utils::OnlyOnce.new
|
|
14
|
+
|
|
12
15
|
module_function
|
|
13
16
|
|
|
14
17
|
def patched?
|
|
15
|
-
|
|
18
|
+
PATCH_ONLY_ONCE.ran?
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def patch
|
|
19
|
-
|
|
22
|
+
PATCH_ONLY_ONCE.run do
|
|
20
23
|
begin
|
|
21
24
|
::Presto::Client::Client.send(:include, Instrumentation::Client)
|
|
22
25
|
rescue StandardError => e
|
|
@@ -5,25 +5,25 @@ module Datadog
|
|
|
5
5
|
module Que
|
|
6
6
|
# Que integration constants
|
|
7
7
|
module Ext
|
|
8
|
-
APP = 'que'
|
|
9
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_QUE_ANALYTICS_ENABLED'
|
|
10
|
-
ENV_ANALYTICS_ENABLED_OLD = 'DD_QUE_ANALYTICS_ENABLED'
|
|
11
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_QUE_ANALYTICS_SAMPLE_RATE'
|
|
12
|
-
ENV_ANALYTICS_SAMPLE_RATE_OLD = 'DD_QUE_ANALYTICS_SAMPLE_RATE'
|
|
13
|
-
ENV_ENABLED = 'DD_TRACE_QUE_ENABLED'
|
|
14
|
-
ENV_TAG_ARGS_ENABLED = 'DD_TRACE_QUE_TAG_ARGS_ENABLED'
|
|
15
|
-
ENV_TAG_DATA_ENABLED = 'DD_TRACE_QUE_TAG_DATA_ENABLED'
|
|
16
|
-
SERVICE_NAME = 'que'
|
|
17
|
-
SPAN_JOB = 'que.job'
|
|
18
|
-
TAG_JOB_ARGS = 'que.job.args'
|
|
19
|
-
TAG_JOB_DATA = 'que.job.data'
|
|
20
|
-
TAG_JOB_ERROR_COUNT = 'que.job.error_count'
|
|
21
|
-
TAG_JOB_EXPIRED_AT = 'que.job.expired_at'
|
|
22
|
-
TAG_JOB_FINISHED_AT = 'que.job.finished_at'
|
|
23
|
-
TAG_JOB_ID = 'que.job.id'
|
|
24
|
-
TAG_JOB_PRIORITY = 'que.job.priority'
|
|
25
|
-
TAG_JOB_QUEUE = 'que.job.queue'
|
|
26
|
-
TAG_JOB_RUN_AT = 'que.job.run_at'
|
|
8
|
+
APP = 'que'
|
|
9
|
+
ENV_ANALYTICS_ENABLED = 'DD_TRACE_QUE_ANALYTICS_ENABLED'
|
|
10
|
+
ENV_ANALYTICS_ENABLED_OLD = 'DD_QUE_ANALYTICS_ENABLED'
|
|
11
|
+
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_QUE_ANALYTICS_SAMPLE_RATE'
|
|
12
|
+
ENV_ANALYTICS_SAMPLE_RATE_OLD = 'DD_QUE_ANALYTICS_SAMPLE_RATE'
|
|
13
|
+
ENV_ENABLED = 'DD_TRACE_QUE_ENABLED'
|
|
14
|
+
ENV_TAG_ARGS_ENABLED = 'DD_TRACE_QUE_TAG_ARGS_ENABLED'
|
|
15
|
+
ENV_TAG_DATA_ENABLED = 'DD_TRACE_QUE_TAG_DATA_ENABLED'
|
|
16
|
+
SERVICE_NAME = 'que'
|
|
17
|
+
SPAN_JOB = 'que.job'
|
|
18
|
+
TAG_JOB_ARGS = 'que.job.args'
|
|
19
|
+
TAG_JOB_DATA = 'que.job.data'
|
|
20
|
+
TAG_JOB_ERROR_COUNT = 'que.job.error_count'
|
|
21
|
+
TAG_JOB_EXPIRED_AT = 'que.job.expired_at'
|
|
22
|
+
TAG_JOB_FINISHED_AT = 'que.job.finished_at'
|
|
23
|
+
TAG_JOB_ID = 'que.job.id'
|
|
24
|
+
TAG_JOB_PRIORITY = 'que.job.priority'
|
|
25
|
+
TAG_JOB_QUEUE = 'que.job.queue'
|
|
26
|
+
TAG_JOB_RUN_AT = 'que.job.run_at'
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -131,7 +131,8 @@ module Datadog
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
# rubocop:disable Metrics/AbcSize
|
|
134
|
-
# rubocop:disable Metrics/
|
|
134
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
|
135
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
135
136
|
def set_request_tags!(request_span, env, status, headers, response, original_env)
|
|
136
137
|
# http://www.rubydoc.info/github/rack/rack/file/SPEC
|
|
137
138
|
# The source of truth in Rack is the PATH_INFO key that holds the
|
|
@@ -199,9 +200,7 @@ module Datadog
|
|
|
199
200
|
|
|
200
201
|
# detect if the status code is a 5xx and flag the request span as an error
|
|
201
202
|
# unless it has been already set by the underlying framework
|
|
202
|
-
if status.to_s.start_with?('5') && request_span.status.zero?
|
|
203
|
-
request_span.status = 1
|
|
204
|
-
end
|
|
203
|
+
request_span.status = 1 if status.to_s.start_with?('5') && request_span.status.zero?
|
|
205
204
|
end
|
|
206
205
|
|
|
207
206
|
private
|
|
@@ -258,9 +257,7 @@ module Datadog
|
|
|
258
257
|
whitelist = configuration[:headers][:request] || []
|
|
259
258
|
whitelist.each do |header|
|
|
260
259
|
rack_header = header_to_rack_header(header)
|
|
261
|
-
if env.key?(rack_header)
|
|
262
|
-
result[Datadog::Ext::HTTP::RequestHeaders.to_tag(header)] = env[rack_header]
|
|
263
|
-
end
|
|
260
|
+
result[Datadog::Ext::HTTP::RequestHeaders.to_tag(header)] = env[rack_header] if env.key?(rack_header)
|
|
264
261
|
end
|
|
265
262
|
end
|
|
266
263
|
end
|
|
@@ -275,9 +272,7 @@ module Datadog
|
|
|
275
272
|
# Try a case-insensitive lookup
|
|
276
273
|
uppercased_header = header.to_s.upcase
|
|
277
274
|
matching_header = headers.keys.find { |h| h.upcase == uppercased_header }
|
|
278
|
-
if matching_header
|
|
279
|
-
result[Datadog::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header]
|
|
280
|
-
end
|
|
275
|
+
result[Datadog::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header] if matching_header
|
|
281
276
|
end
|
|
282
277
|
end
|
|
283
278
|
end
|
|
@@ -53,9 +53,7 @@ module Datadog
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
following = if middleware.instance_variable_defined?('@app')
|
|
57
|
-
middleware.instance_variable_get('@app')
|
|
58
|
-
end
|
|
56
|
+
following = (middleware.instance_variable_get('@app') if middleware.instance_variable_defined?('@app'))
|
|
59
57
|
|
|
60
58
|
retain_middleware_name(following)
|
|
61
59
|
end
|
|
@@ -3,6 +3,7 @@ require 'ddtrace/contrib/rails/framework'
|
|
|
3
3
|
require 'ddtrace/contrib/rails/middlewares'
|
|
4
4
|
require 'ddtrace/contrib/rails/log_injection'
|
|
5
5
|
require 'ddtrace/contrib/rack/middlewares'
|
|
6
|
+
require 'ddtrace/utils/only_once'
|
|
6
7
|
|
|
7
8
|
module Datadog
|
|
8
9
|
module Contrib
|
|
@@ -11,6 +12,9 @@ module Datadog
|
|
|
11
12
|
module Patcher
|
|
12
13
|
include Contrib::Patcher
|
|
13
14
|
|
|
15
|
+
BEFORE_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Utils::OnlyOnce.new }
|
|
16
|
+
AFTER_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Utils::OnlyOnce.new }
|
|
17
|
+
|
|
14
18
|
module_function
|
|
15
19
|
|
|
16
20
|
def target_version
|
|
@@ -29,7 +33,7 @@ module Datadog
|
|
|
29
33
|
end
|
|
30
34
|
|
|
31
35
|
def before_intialize(app)
|
|
32
|
-
|
|
36
|
+
BEFORE_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
|
|
33
37
|
# Middleware must be added before the application is initialized.
|
|
34
38
|
# Otherwise the middleware stack will be frozen.
|
|
35
39
|
# Sometimes we don't want to activate middleware e.g. OpenTracing, etc.
|
|
@@ -86,7 +90,7 @@ module Datadog
|
|
|
86
90
|
end
|
|
87
91
|
|
|
88
92
|
def after_intialize(app)
|
|
89
|
-
|
|
93
|
+
AFTER_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
|
|
90
94
|
# Finish configuring the tracer after the application is initialized.
|
|
91
95
|
# We need to wait for some things, like application name, middleware stack, etc.
|
|
92
96
|
setup_tracer
|
|
@@ -16,7 +16,8 @@ module Datadog
|
|
|
16
16
|
return super unless enabled?
|
|
17
17
|
|
|
18
18
|
tracer.trace(Ext::SPAN_INVOKE, span_options) do |span|
|
|
19
|
-
|
|
19
|
+
annotate_invoke!(span, args)
|
|
20
|
+
super
|
|
20
21
|
end
|
|
21
22
|
ensure
|
|
22
23
|
shutdown_tracer!
|
|
@@ -26,7 +27,8 @@ module Datadog
|
|
|
26
27
|
return super unless enabled?
|
|
27
28
|
|
|
28
29
|
tracer.trace(Ext::SPAN_EXECUTE, span_options) do |span|
|
|
29
|
-
|
|
30
|
+
annotate_execute!(span, args)
|
|
31
|
+
super
|
|
30
32
|
end
|
|
31
33
|
ensure
|
|
32
34
|
shutdown_tracer!
|
|
@@ -6,12 +6,19 @@ module Datadog
|
|
|
6
6
|
module Configuration
|
|
7
7
|
UNIX_SCHEME = 'unix'.freeze
|
|
8
8
|
|
|
9
|
-
# Converts
|
|
9
|
+
# Converts String URLs and Hashes to a normalized connection settings Hash.
|
|
10
10
|
class Resolver < Contrib::Configuration::Resolver
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
# @param [Hash,String] Redis connection information
|
|
12
|
+
def resolve(hash)
|
|
13
|
+
super(parse_matcher(hash))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
protected
|
|
17
|
+
|
|
18
|
+
def parse_matcher(matcher)
|
|
19
|
+
matcher = { url: matcher } if matcher.is_a?(String)
|
|
13
20
|
|
|
14
|
-
normalize(connection_resolver.resolve(
|
|
21
|
+
normalize(connection_resolver.resolve(matcher))
|
|
15
22
|
end
|
|
16
23
|
|
|
17
24
|
def normalize(hash)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 Ezra Zygmuntowicz
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -56,11 +56,9 @@ module Datadog
|
|
|
56
56
|
defaults = DEFAULTS.dup
|
|
57
57
|
options = options.dup
|
|
58
58
|
|
|
59
|
-
defaults.
|
|
59
|
+
defaults.each_key do |key|
|
|
60
60
|
# Fill in defaults if needed
|
|
61
|
-
if defaults[key].respond_to?(:call)
|
|
62
|
-
defaults[key] = defaults[key].call
|
|
63
|
-
end
|
|
61
|
+
defaults[key] = defaults[key].call if defaults[key].respond_to?(:call)
|
|
64
62
|
|
|
65
63
|
# Symbolize only keys that are needed
|
|
66
64
|
options[key] = options[key.to_s] if options.key?(key.to_s)
|
|
@@ -73,9 +71,10 @@ module Datadog
|
|
|
73
71
|
if url
|
|
74
72
|
uri = URI(url)
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
case uri.scheme
|
|
75
|
+
when 'unix'
|
|
77
76
|
defaults[:path] = uri.path
|
|
78
|
-
|
|
77
|
+
when 'redis', 'rediss'
|
|
79
78
|
defaults[:scheme] = uri.scheme
|
|
80
79
|
defaults[:host] = uri.host if uri.host
|
|
81
80
|
defaults[:port] = uri.port if uri.port
|
|
@@ -90,7 +89,7 @@ module Datadog
|
|
|
90
89
|
end
|
|
91
90
|
|
|
92
91
|
# Use default when option is not specified or nil
|
|
93
|
-
defaults.
|
|
92
|
+
defaults.each_key do |key|
|
|
94
93
|
options[key] = defaults[key] if options[key].nil?
|
|
95
94
|
end
|
|
96
95
|
|
|
@@ -44,6 +44,7 @@ module Datadog
|
|
|
44
44
|
def forked?
|
|
45
45
|
pin = Datadog::Pin.get_from(::Resque)
|
|
46
46
|
return false unless pin
|
|
47
|
+
|
|
47
48
|
pin.config[:forked] == true
|
|
48
49
|
end
|
|
49
50
|
|
|
@@ -76,5 +77,6 @@ Resque.after_fork do
|
|
|
76
77
|
|
|
77
78
|
# Clean the state so no CoW happens
|
|
78
79
|
next if configuration[:tracer].nil?
|
|
80
|
+
|
|
79
81
|
configuration[:tracer].provider.context = nil
|
|
80
82
|
end
|