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
@@ -96,6 +96,7 @@ module Datadog
|
|
96
96
|
# @return [Hash]
|
97
97
|
def self.default_connection_config
|
98
98
|
return @default_connection_config if instance_variable_defined?(:@default_connection_config)
|
99
|
+
|
99
100
|
current_connection_name = if ::ActiveRecord::Base.respond_to?(:connection_specification_name)
|
100
101
|
::ActiveRecord::Base.connection_specification_name
|
101
102
|
else
|
@@ -9,7 +9,8 @@ module Datadog
|
|
9
9
|
:options
|
10
10
|
|
11
11
|
def initialize(tracer, span_name, options, &block)
|
12
|
-
raise ArgumentError, 'Must be given a block!' unless
|
12
|
+
raise ArgumentError, 'Must be given a block!' unless block
|
13
|
+
|
13
14
|
@tracer = tracer
|
14
15
|
@span_name = span_name
|
15
16
|
@options = options
|
@@ -38,21 +39,23 @@ module Datadog
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def before_trace(&block)
|
41
|
-
callbacks.add(:before_trace, &block) if
|
42
|
+
callbacks.add(:before_trace, &block) if block
|
42
43
|
end
|
43
44
|
|
44
45
|
def after_trace(&block)
|
45
|
-
callbacks.add(:after_trace, &block) if
|
46
|
+
callbacks.add(:after_trace, &block) if block
|
46
47
|
end
|
47
48
|
|
48
49
|
def subscribe(pattern)
|
49
50
|
return false if subscribers.key?(pattern)
|
51
|
+
|
50
52
|
subscribers[pattern] = ::ActiveSupport::Notifications.subscribe(pattern, self)
|
51
53
|
true
|
52
54
|
end
|
53
55
|
|
54
56
|
def unsubscribe(pattern)
|
55
57
|
return false unless subscribers.key?(pattern)
|
58
|
+
|
56
59
|
::ActiveSupport::Notifications.unsubscribe(subscribers[pattern])
|
57
60
|
subscribers.delete(pattern)
|
58
61
|
true
|
@@ -60,7 +63,8 @@ module Datadog
|
|
60
63
|
|
61
64
|
def unsubscribe_all
|
62
65
|
return false if subscribers.empty?
|
63
|
-
|
66
|
+
|
67
|
+
subscribers.each_key { |pattern| unsubscribe(pattern) }
|
64
68
|
true
|
65
69
|
end
|
66
70
|
|
@@ -131,7 +135,7 @@ module Datadog
|
|
131
135
|
end
|
132
136
|
|
133
137
|
def add(key, &block)
|
134
|
-
blocks_for(key) << block if
|
138
|
+
blocks_for(key) << block if block
|
135
139
|
end
|
136
140
|
|
137
141
|
def run(event, key, *args)
|
@@ -32,6 +32,7 @@ module Datadog
|
|
32
32
|
# cause undesirable service naming, so we exclude them based their auto_instrument? setting.
|
33
33
|
# we also don't want to mix rspec/cucumber integration in as rspec is env we run tests in.
|
34
34
|
next unless integration.klass.auto_instrument?
|
35
|
+
|
35
36
|
integrations << integration.name
|
36
37
|
end
|
37
38
|
|
@@ -11,7 +11,7 @@ module Datadog
|
|
11
11
|
return if patterns.empty?
|
12
12
|
|
13
13
|
# Try to find a matching pattern
|
14
|
-
|
14
|
+
patterns.find do |pattern|
|
15
15
|
if pattern.is_a?(Proc)
|
16
16
|
(pattern === name)
|
17
17
|
else
|
@@ -19,9 +19,6 @@ module Datadog
|
|
19
19
|
(pattern == name) # Only required during configuration time.
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
# Return match or default
|
24
|
-
matching_pattern
|
25
22
|
end
|
26
23
|
|
27
24
|
def add(pattern)
|
@@ -12,16 +12,6 @@ module Datadog
|
|
12
12
|
o.lazy
|
13
13
|
end
|
14
14
|
|
15
|
-
option :analytics_enabled do |o|
|
16
|
-
o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, true) }
|
17
|
-
o.lazy
|
18
|
-
end
|
19
|
-
|
20
|
-
option :analytics_sample_rate do |o|
|
21
|
-
o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
|
22
|
-
o.lazy
|
23
|
-
end
|
24
|
-
|
25
15
|
option :service_name do |o|
|
26
16
|
o.default { Datadog.configuration.service || Ext::SERVICE_NAME }
|
27
17
|
o.lazy
|
@@ -4,8 +4,6 @@ module Datadog
|
|
4
4
|
# Cucumber integration constants
|
5
5
|
module Ext
|
6
6
|
APP = 'cucumber'.freeze
|
7
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_CUCUMBER_ANALYTICS_ENABLED'.freeze
|
8
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_CUCUMBER_ANALYTICS_SAMPLE_RATE'.freeze
|
9
7
|
ENV_ENABLED = 'DD_TRACE_CUCUMBER_ENABLED'.freeze
|
10
8
|
ENV_OPERATION_NAME = 'DD_TRACE_CUCUMBER_OPERATION_NAME'.freeze
|
11
9
|
FRAMEWORK = 'cucumber'.freeze
|
@@ -9,10 +9,8 @@ module Datadog
|
|
9
9
|
module Cucumber
|
10
10
|
# Defines collection of instrumented Cucumber events
|
11
11
|
class Formatter
|
12
|
-
attr_reader :config
|
12
|
+
attr_reader :config, :current_feature_span, :current_step_span
|
13
13
|
private :config
|
14
|
-
|
15
|
-
attr_reader :current_feature_span, :current_step_span
|
16
14
|
private :current_feature_span, :current_step_span
|
17
15
|
|
18
16
|
def initialize(config)
|
@@ -43,17 +41,13 @@ module Datadog
|
|
43
41
|
@current_feature_span.set_tag(Datadog::Ext::Test::TAG_TYPE, Ext::TEST_TYPE)
|
44
42
|
@current_feature_span.set_tag(Datadog::Ext::Test::TAG_SPAN_KIND, Datadog::Ext::AppTypes::TEST)
|
45
43
|
|
46
|
-
# Set analytics sample rate
|
47
|
-
if Datadog::Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
48
|
-
Datadog::Contrib::Analytics.set_sample_rate(@current_feature_span, configuration[:analytics_sample_rate])
|
49
|
-
end
|
50
|
-
|
51
44
|
# Measure service stats
|
52
45
|
Contrib::Analytics.set_measured(@current_feature_span)
|
53
46
|
end
|
54
47
|
|
55
48
|
def on_test_case_finished(event)
|
56
49
|
return if @current_feature_span.nil?
|
50
|
+
|
57
51
|
@current_feature_span.status = 1 if event.result.failed?
|
58
52
|
@current_feature_span.set_tag(Datadog::Ext::Test::TAG_STATUS, status_from_result(event.result))
|
59
53
|
@current_feature_span.finish
|
@@ -69,9 +63,8 @@ module Datadog
|
|
69
63
|
|
70
64
|
def on_test_step_finished(event)
|
71
65
|
return if @current_step_span.nil?
|
72
|
-
|
73
|
-
|
74
|
-
end
|
66
|
+
|
67
|
+
@current_step_span.set_error event.result.exception unless event.result.passed?
|
75
68
|
@current_step_span.set_tag(Datadog::Ext::Test::TAG_STATUS, status_from_result(event.result))
|
76
69
|
@current_step_span.finish
|
77
70
|
end
|
@@ -84,6 +77,7 @@ module Datadog
|
|
84
77
|
elsif result.ok?
|
85
78
|
return Datadog::Ext::Test::Status::PASS
|
86
79
|
end
|
80
|
+
|
87
81
|
Datadog::Ext::Test::Status::FAIL
|
88
82
|
end
|
89
83
|
|
@@ -17,46 +17,8 @@ module Datadog
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def patch
|
20
|
-
add_pin!
|
21
20
|
::Dalli::Server.send(:include, Instrumentation)
|
22
21
|
end
|
23
|
-
|
24
|
-
# DEPRECATED: Only kept for users still using `Dalli.datadog_pin` to configure.
|
25
|
-
# Replaced by configuration API, i.e. `c.use :dalli`.
|
26
|
-
def add_pin!
|
27
|
-
DeprecatedPin
|
28
|
-
.new(
|
29
|
-
get_option(:service_name),
|
30
|
-
app: Ext::APP,
|
31
|
-
app_type: Datadog::Ext::AppTypes::CACHE,
|
32
|
-
tracer: -> { get_option(:tracer) }
|
33
|
-
).onto(::Dalli)
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_option(option)
|
37
|
-
Datadog.configuration[:dalli].get_option(option)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Implementation of deprecated Pin, which raises warnings when accessed.
|
41
|
-
# To be removed when support for Datadog::Pin with Dalli is removed.
|
42
|
-
class DeprecatedPin < Datadog::Pin
|
43
|
-
include Datadog::DeprecatedPin
|
44
|
-
|
45
|
-
DEPRECATION_WARNING = %(
|
46
|
-
Use of Datadog::Pin with Dalli is DEPRECATED.
|
47
|
-
Upgrade to the configuration API using the migration guide here:
|
48
|
-
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
49
|
-
|
50
|
-
def service_name=(service_name)
|
51
|
-
Datadog.configuration[:dalli][:service_name] = service_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def log_deprecation_warning(method_name)
|
55
|
-
do_once(method_name) do
|
56
|
-
Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
22
|
end
|
61
23
|
end
|
62
24
|
end
|
@@ -17,7 +17,7 @@ module Datadog
|
|
17
17
|
|
18
18
|
def format_url(url)
|
19
19
|
sanitize_fragment_with_id(url)
|
20
|
-
.gsub(/(
|
20
|
+
.gsub(/(?:\d+)/, PLACEHOLDER)
|
21
21
|
end
|
22
22
|
|
23
23
|
def format_body(body, options = {})
|
@@ -60,6 +60,7 @@ module Datadog
|
|
60
60
|
# If JSON parsing fails, it prints fail_value.
|
61
61
|
def reserialize_json(string, fail_value = PLACEHOLDER)
|
62
62
|
return string unless block_given?
|
63
|
+
|
63
64
|
begin
|
64
65
|
JSON.dump(yield(JSON.parse(string)))
|
65
66
|
rescue JSON::ParserError
|
@@ -72,7 +73,7 @@ module Datadog
|
|
72
73
|
# This is meant as simple heuristic that attempts to detect if particular fragment
|
73
74
|
# represents document Id. This is meant to reduce the cardinality in most frequent cases.
|
74
75
|
def sanitize_fragment_with_id(url)
|
75
|
-
url.gsub(%r{^(/?[^/]*/[^/]*/)(?:[
|
76
|
+
url.gsub(%r{^(/?[^/]*/[^/]*/)(?:[^?/\d]*\d+[^?/]*)}, ID_PLACEHOLDER)
|
76
77
|
end
|
77
78
|
end
|
78
79
|
end
|
@@ -13,8 +13,8 @@ module Datadog
|
|
13
13
|
def self.included(base)
|
14
14
|
base.send(:prepend, InstanceMethods)
|
15
15
|
end
|
16
|
+
|
16
17
|
# InstanceMethods - implementing instrumentation
|
17
|
-
# rubocop:disable Metrics/ModuleLength
|
18
18
|
module InstanceMethods
|
19
19
|
include Datadog::Contrib::HttpAnnotationHelper
|
20
20
|
|
@@ -36,12 +36,14 @@ module Datadog
|
|
36
36
|
def perform
|
37
37
|
load_datadog_configuration_for(url)
|
38
38
|
return super unless tracer_enabled?
|
39
|
+
|
39
40
|
datadog_before_request
|
40
41
|
super
|
41
42
|
end
|
42
43
|
|
43
44
|
def complete
|
44
45
|
return super unless tracer_enabled?
|
46
|
+
|
45
47
|
begin
|
46
48
|
response_options = mirror.options
|
47
49
|
response_code = (response_options[:response_code] || response_options[:code]).to_i
|
@@ -100,9 +102,7 @@ module Datadog
|
|
100
102
|
def datadog_tag_request
|
101
103
|
span = @datadog_span
|
102
104
|
method = Ext::NOT_APPLICABLE_METHOD
|
103
|
-
if instance_variable_defined?(:@datadog_method) && !@datadog_method.nil?
|
104
|
-
method = @datadog_method.to_s
|
105
|
-
end
|
105
|
+
method = @datadog_method.to_s if instance_variable_defined?(:@datadog_method) && !@datadog_method.nil?
|
106
106
|
span.resource = method
|
107
107
|
# Tag as an external peer service
|
108
108
|
span.set_tag(Datadog::Ext::Integration::TAG_PEER_SERVICE, span.service)
|
@@ -111,6 +111,7 @@ module Datadog
|
|
111
111
|
|
112
112
|
this_uri = uri
|
113
113
|
return unless this_uri
|
114
|
+
|
114
115
|
span.set_tag(Datadog::Ext::HTTP::URL, this_uri.path)
|
115
116
|
span.set_tag(Datadog::Ext::HTTP::METHOD, method)
|
116
117
|
span.set_tag(Datadog::Ext::NET::TARGET_HOST, this_uri.host)
|
@@ -125,7 +126,6 @@ module Datadog
|
|
125
126
|
|
126
127
|
def uri
|
127
128
|
URI.parse(url)
|
128
|
-
# rubocop:disable Lint/HandleExceptions
|
129
129
|
rescue URI::InvalidURIError
|
130
130
|
end
|
131
131
|
|
@@ -119,9 +119,7 @@ module Datadog
|
|
119
119
|
span.set_tag(Datadog::Ext::Integration::TAG_PEER_SERVICE, span.service)
|
120
120
|
|
121
121
|
# Set analytics sample rate
|
122
|
-
if analytics_enabled?
|
123
|
-
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
124
|
-
end
|
122
|
+
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
125
123
|
|
126
124
|
span.set_tag(Datadog::Ext::HTTP::URL, datum[:path])
|
127
125
|
span.set_tag(Datadog::Ext::HTTP::METHOD, datum[:method].to_s.upcase)
|
@@ -136,9 +134,7 @@ module Datadog
|
|
136
134
|
|
137
135
|
if datum.key?(:response)
|
138
136
|
response = datum[:response]
|
139
|
-
if error_handler.call(response)
|
140
|
-
span.set_error(["Error #{response[:status]}", response[:body]])
|
141
|
-
end
|
137
|
+
span.set_error(["Error #{response[:status]}", response[:body]]) if error_handler.call(response)
|
142
138
|
span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, response[:status])
|
143
139
|
end
|
144
140
|
span.set_error(datum[:error]) if datum.key?(:error)
|
@@ -30,6 +30,7 @@ module Datadog
|
|
30
30
|
reduce_verbosity = target.respond_to?(:reduce_verbosity?) ? target.reduce_verbosity? : false
|
31
31
|
target.integrations_pending_activation.each do |integration|
|
32
32
|
next unless integration.respond_to?(:patch)
|
33
|
+
|
33
34
|
# integration.patch returns either true or a hash of details on why patching failed
|
34
35
|
patch_results = integration.patch
|
35
36
|
|
@@ -57,9 +57,7 @@ module Datadog
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def handle_response(span, env, options)
|
60
|
-
if options.fetch(:error_handler).call(env)
|
61
|
-
span.set_error(["Error #{env[:status]}", env[:body]])
|
62
|
-
end
|
60
|
+
span.set_error(["Error #{env[:status]}", env[:body]]) if options.fetch(:error_handler).call(env)
|
63
61
|
|
64
62
|
span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, env[:status])
|
65
63
|
end
|
@@ -20,21 +20,10 @@ module Datadog
|
|
20
20
|
def patch
|
21
21
|
require 'ddtrace/contrib/faraday/middleware'
|
22
22
|
|
23
|
-
add_pin!
|
24
23
|
register_middleware!
|
25
24
|
add_default_middleware!
|
26
25
|
end
|
27
26
|
|
28
|
-
def add_pin!
|
29
|
-
DeprecatedPin
|
30
|
-
.new(
|
31
|
-
get_option(:service_name),
|
32
|
-
app: Ext::APP,
|
33
|
-
app_type: Datadog::Ext::HTTP::TYPE_OUTBOUND,
|
34
|
-
tracer: -> { get_option(:tracer) }
|
35
|
-
).onto(::Faraday)
|
36
|
-
end
|
37
|
-
|
38
27
|
def register_middleware!
|
39
28
|
::Faraday::Middleware.register_middleware(ddtrace: Middleware)
|
40
29
|
end
|
@@ -58,31 +47,6 @@ module Datadog
|
|
58
47
|
::Faraday::RackBuilder.send(:prepend, RackBuilder)
|
59
48
|
end
|
60
49
|
end
|
61
|
-
|
62
|
-
def get_option(option)
|
63
|
-
Datadog.configuration[:faraday].get_option(option)
|
64
|
-
end
|
65
|
-
|
66
|
-
# Implementation of deprecated Pin, which raises warnings when accessed.
|
67
|
-
# To be removed when support for Datadog::Pin with Faraday is removed.
|
68
|
-
class DeprecatedPin < Datadog::Pin
|
69
|
-
include Datadog::DeprecatedPin
|
70
|
-
|
71
|
-
DEPRECATION_WARNING = %(
|
72
|
-
Use of Datadog::Pin with Faraday is DEPRECATED.
|
73
|
-
Upgrade to the configuration API using the migration guide here:
|
74
|
-
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
75
|
-
|
76
|
-
def service_name=(service_name)
|
77
|
-
Datadog.configuration[:faraday][:service_name] = service_name
|
78
|
-
end
|
79
|
-
|
80
|
-
def log_deprecation_warning(method_name)
|
81
|
-
do_once(method_name) do
|
82
|
-
Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
50
|
end
|
87
51
|
end
|
88
52
|
end
|
@@ -51,6 +51,7 @@ module Datadog
|
|
51
51
|
|
52
52
|
def endpoint_run(name, start, finish, id, payload)
|
53
53
|
return unless Thread.current[KEY_RUN]
|
54
|
+
|
54
55
|
Thread.current[KEY_RUN] = false
|
55
56
|
|
56
57
|
return unless enabled?
|
@@ -76,18 +77,14 @@ module Datadog
|
|
76
77
|
end
|
77
78
|
|
78
79
|
# Set analytics sample rate
|
79
|
-
if analytics_enabled?
|
80
|
-
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
81
|
-
end
|
80
|
+
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
82
81
|
|
83
82
|
# Measure service stats
|
84
83
|
Contrib::Analytics.set_measured(span)
|
85
84
|
|
86
85
|
# catch thrown exceptions
|
87
86
|
|
88
|
-
if exception_is_error?(payload[:exception_object])
|
89
|
-
span.set_error(payload[:exception_object])
|
90
|
-
end
|
87
|
+
span.set_error(payload[:exception_object]) if exception_is_error?(payload[:exception_object])
|
91
88
|
|
92
89
|
# override the current span with this notification values
|
93
90
|
span.set_tag(Ext::TAG_ROUTE_ENDPOINT, api_view) unless api_view.nil?
|
@@ -122,6 +119,7 @@ module Datadog
|
|
122
119
|
|
123
120
|
def endpoint_render(name, start, finish, id, payload)
|
124
121
|
return unless Thread.current[KEY_RENDER]
|
122
|
+
|
125
123
|
Thread.current[KEY_RENDER] = false
|
126
124
|
|
127
125
|
return unless enabled?
|
@@ -134,9 +132,7 @@ module Datadog
|
|
134
132
|
# Measure service stats
|
135
133
|
Contrib::Analytics.set_measured(span)
|
136
134
|
|
137
|
-
if exception_is_error?(payload[:exception_object])
|
138
|
-
span.set_error(payload[:exception_object])
|
139
|
-
end
|
135
|
+
span.set_error(payload[:exception_object]) if exception_is_error?(payload[:exception_object])
|
140
136
|
ensure
|
141
137
|
span.start(start)
|
142
138
|
span.finish(finish)
|
@@ -163,17 +159,13 @@ module Datadog
|
|
163
159
|
|
164
160
|
begin
|
165
161
|
# Set analytics sample rate
|
166
|
-
if analytics_enabled?
|
167
|
-
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate)
|
168
|
-
end
|
162
|
+
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
169
163
|
|
170
164
|
# Measure service stats
|
171
165
|
Contrib::Analytics.set_measured(span)
|
172
166
|
|
173
167
|
# catch thrown exceptions
|
174
|
-
if exception_is_error?(payload[:exception_object])
|
175
|
-
span.set_error(payload[:exception_object])
|
176
|
-
end
|
168
|
+
span.set_error(payload[:exception_object]) if exception_is_error?(payload[:exception_object])
|
177
169
|
|
178
170
|
span.set_tag(Ext::TAG_FILTER_TYPE, type.to_s)
|
179
171
|
ensure
|
@@ -226,6 +218,7 @@ module Datadog
|
|
226
218
|
return false unless exception
|
227
219
|
return true unless matcher
|
228
220
|
return true unless exception.respond_to?('status')
|
221
|
+
|
229
222
|
matcher.include?(exception.status)
|
230
223
|
end
|
231
224
|
|