ddtrace 1.12.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +109 -9
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +97 -14
- data/ext/ddtrace_profiling_native_extension/extconf.rb +6 -0
- data/ext/ddtrace_profiling_native_extension/http_transport.c +19 -6
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -1
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +41 -2
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +6 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +6 -10
- data/ext/ddtrace_profiling_native_extension/time_helpers.c +40 -4
- data/ext/ddtrace_profiling_native_extension/time_helpers.h +14 -0
- data/lib/datadog/appsec/component.rb +9 -0
- data/lib/datadog/appsec/configuration/settings.rb +104 -195
- data/lib/datadog/appsec/configuration.rb +0 -79
- data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -4
- data/lib/datadog/appsec/contrib/devise/event.rb +57 -0
- data/lib/datadog/appsec/contrib/devise/ext.rb +13 -0
- data/lib/datadog/appsec/contrib/devise/integration.rb +42 -0
- data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +76 -0
- data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +52 -0
- data/lib/datadog/appsec/contrib/devise/patcher.rb +45 -0
- data/lib/datadog/appsec/contrib/devise/resource.rb +35 -0
- data/lib/datadog/appsec/contrib/devise/tracking.rb +49 -0
- data/lib/datadog/appsec/contrib/rack/ext.rb +2 -1
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +12 -7
- data/lib/datadog/appsec/contrib/rails/ext.rb +3 -2
- data/lib/datadog/appsec/contrib/rails/framework.rb +1 -3
- data/lib/datadog/appsec/contrib/rails/patcher.rb +8 -8
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/ext.rb +2 -1
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -3
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +1 -1
- data/lib/datadog/appsec/event.rb +1 -1
- data/lib/datadog/appsec/extensions.rb +1 -130
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +1 -1
- data/lib/datadog/appsec/processor.rb +1 -1
- data/lib/datadog/appsec/rate_limiter.rb +1 -1
- data/lib/datadog/appsec/remote.rb +1 -1
- data/lib/datadog/appsec.rb +1 -2
- data/lib/datadog/ci/configuration/settings.rb +6 -8
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +7 -5
- data/lib/datadog/ci/contrib/cucumber/ext.rb +10 -8
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +35 -0
- data/lib/datadog/ci/contrib/minitest/ext.rb +21 -0
- data/lib/datadog/ci/contrib/minitest/integration.rb +49 -0
- data/lib/datadog/ci/contrib/minitest/patcher.rb +27 -0
- data/lib/datadog/ci/contrib/minitest/test_helper.rb +68 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +7 -5
- data/lib/datadog/ci/contrib/rspec/ext.rb +9 -7
- data/lib/datadog/ci.rb +1 -0
- data/lib/datadog/core/backport.rb +51 -0
- data/lib/datadog/core/configuration/base.rb +5 -5
- data/lib/datadog/core/configuration/components.rb +6 -1
- data/lib/datadog/core/configuration/ext.rb +7 -5
- data/lib/datadog/core/configuration/option.rb +269 -19
- data/lib/datadog/core/configuration/option_definition.rb +76 -11
- data/lib/datadog/core/configuration/options.rb +22 -10
- data/lib/datadog/core/configuration/settings.rb +116 -61
- data/lib/datadog/core/environment/ext.rb +13 -11
- data/lib/datadog/core/environment/yjit.rb +58 -0
- data/lib/datadog/core/git/ext.rb +24 -22
- data/lib/datadog/core/logging/ext.rb +3 -1
- data/lib/datadog/core/metrics/ext.rb +7 -5
- data/lib/datadog/core/remote/client/capabilities.rb +5 -0
- data/lib/datadog/core/remote/client.rb +3 -0
- data/lib/datadog/core/remote/component.rb +25 -34
- data/lib/datadog/core/remote/configuration/content.rb +28 -1
- data/lib/datadog/core/remote/configuration/repository.rb +3 -1
- data/lib/datadog/core/remote/ext.rb +1 -1
- data/lib/datadog/core/remote/negotiation.rb +17 -4
- data/lib/datadog/core/runtime/ext.rb +22 -12
- data/lib/datadog/core/runtime/metrics.rb +43 -0
- data/lib/datadog/core/telemetry/client.rb +12 -2
- data/lib/datadog/core/telemetry/emitter.rb +4 -2
- data/lib/datadog/core/telemetry/event.rb +19 -4
- data/lib/datadog/core/telemetry/ext.rb +4 -1
- data/lib/datadog/core/telemetry/heartbeat.rb +2 -4
- data/lib/datadog/core/telemetry/http/ext.rb +10 -8
- data/lib/datadog/core/telemetry/http/transport.rb +1 -0
- data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
- data/lib/datadog/core/telemetry/v2/request.rb +29 -0
- data/lib/datadog/core/transport/http/client.rb +1 -1
- data/lib/datadog/core/transport/http/config.rb +10 -0
- data/lib/datadog/core/utils/duration.rb +52 -0
- data/lib/datadog/core/utils/hash.rb +47 -0
- data/lib/datadog/core/utils/network.rb +1 -1
- data/lib/datadog/core/utils/safe_dup.rb +27 -20
- data/lib/datadog/core/utils.rb +1 -1
- data/lib/datadog/core/workers/async.rb +2 -2
- data/lib/datadog/kit/appsec/events.rb +139 -89
- data/lib/datadog/kit/identity.rb +80 -65
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +3 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +9 -2
- data/lib/datadog/profiling/component.rb +41 -9
- data/lib/datadog/profiling/exporter.rb +5 -1
- data/lib/datadog/profiling/flush.rb +9 -2
- data/lib/datadog/profiling/http_transport.rb +4 -1
- data/lib/datadog/profiling/load_native_extension.rb +7 -1
- data/lib/datadog/profiling.rb +11 -1
- data/lib/datadog/tracing/component.rb +58 -6
- data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
- data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
- data/lib/datadog/tracing/configuration/ext.rb +35 -32
- data/lib/datadog/tracing/configuration/http.rb +74 -0
- data/lib/datadog/tracing/configuration/settings.rb +106 -92
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_cable/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_mailer/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +8 -6
- data/lib/datadog/tracing/contrib/action_pack/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/action_view/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/active_job/ext.rb +25 -23
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +1 -1
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +0 -8
- data/lib/datadog/tracing/contrib/active_record/ext.rb +17 -15
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +0 -5
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/active_support/ext.rb +18 -16
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/aws/ext.rb +37 -24
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +9 -5
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +4 -2
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/dalli/ext.rb +19 -11
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +8 -6
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/delayed_job/ext.rb +16 -14
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +21 -15
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +8 -5
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +16 -9
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +43 -3
- data/lib/datadog/tracing/contrib/ethon/ext.rb +19 -11
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +0 -5
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +19 -10
- data/lib/datadog/tracing/contrib/excon/ext.rb +16 -8
- data/lib/datadog/tracing/contrib/excon/middleware.rb +20 -5
- data/lib/datadog/tracing/contrib/ext.rb +23 -1
- data/lib/datadog/tracing/contrib/extensions.rb +32 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +20 -10
- data/lib/datadog/tracing/contrib/faraday/ext.rb +16 -8
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +16 -5
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +8 -6
- data/lib/datadog/tracing/contrib/grape/ext.rb +16 -14
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +8 -6
- data/lib/datadog/tracing/contrib/graphql/ext.rb +7 -5
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +19 -9
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +29 -20
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +21 -20
- data/lib/datadog/tracing/contrib/grpc/ext.rb +16 -13
- data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/hanami/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +4 -7
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/http/ext.rb +16 -9
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +17 -5
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/httpclient/ext.rb +17 -9
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +17 -5
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +33 -11
- data/lib/datadog/tracing/contrib/httprb/ext.rb +16 -9
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +17 -5
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/kafka/ext.rb +42 -39
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/lograge/ext.rb +3 -1
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +20 -16
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +9 -5
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +17 -14
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +15 -10
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +9 -5
- data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +52 -0
- data/lib/datadog/tracing/contrib/opensearch/ext.rb +37 -0
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +128 -0
- data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +17 -14
- data/lib/datadog/tracing/contrib/pg/ext.rb +22 -19
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +9 -5
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/presto/ext.rb +25 -20
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +9 -5
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +12 -10
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +12 -8
- data/lib/datadog/tracing/contrib/qless/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +21 -12
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -7
- data/lib/datadog/tracing/contrib/racecar/event.rb +0 -5
- data/lib/datadog/tracing/contrib/racecar/ext.rb +20 -18
- data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +16 -12
- data/lib/datadog/tracing/contrib/rack/ext.rb +18 -16
- data/lib/datadog/tracing/contrib/rack/header_collection.rb +3 -0
- data/lib/datadog/tracing/contrib/rack/header_tagging.rb +53 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +8 -49
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +15 -11
- data/lib/datadog/tracing/contrib/rails/ext.rb +7 -5
- data/lib/datadog/tracing/contrib/rails/log_injection.rb +4 -10
- data/lib/datadog/tracing/contrib/rails/patcher.rb +10 -41
- data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +12 -9
- data/lib/datadog/tracing/contrib/rake/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +17 -9
- data/lib/datadog/tracing/contrib/redis/ext.rb +22 -15
- data/lib/datadog/tracing/contrib/redis/tags.rb +9 -5
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +13 -7
- data/lib/datadog/tracing/contrib/resque/ext.rb +9 -7
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +16 -9
- data/lib/datadog/tracing/contrib/rest_client/ext.rb +15 -8
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +20 -5
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +3 -2
- data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +3 -1
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +1 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sequel/ext.rb +10 -8
- data/lib/datadog/tracing/contrib/sequel/utils.rb +2 -7
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +14 -8
- data/lib/datadog/tracing/contrib/shoryuken/ext.rb +14 -12
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +18 -11
- data/lib/datadog/tracing/contrib/sidekiq/ext.rb +32 -30
- data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +11 -9
- data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +21 -19
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +14 -8
- data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/sneakers/tracer.rb +1 -1
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +74 -10
- data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +9 -6
- data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +15 -13
- data/lib/datadog/tracing/contrib/utils/database.rb +5 -3
- data/lib/datadog/tracing/correlation.rb +9 -12
- data/lib/datadog/tracing/diagnostics/ext.rb +21 -19
- data/lib/datadog/tracing/distributed/b3_multi.rb +2 -2
- data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
- data/lib/datadog/tracing/distributed/trace_context.rb +52 -17
- data/lib/datadog/tracing/metadata/ext.rb +9 -6
- data/lib/datadog/tracing/remote.rb +78 -0
- data/lib/datadog/tracing/sampling/rule_sampler.rb +29 -0
- data/lib/datadog/tracing/span_operation.rb +3 -15
- data/lib/datadog/tracing/trace_operation.rb +16 -3
- data/lib/datadog/tracing/trace_segment.rb +5 -2
- data/lib/datadog/tracing/tracer.rb +10 -1
- data/lib/ddtrace/transport/ext.rb +15 -9
- data/lib/ddtrace/transport/trace_formatter.rb +9 -0
- data/lib/ddtrace/version.rb +9 -12
- metadata +38 -10
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +0 -35
@@ -12,18 +12,21 @@ module Datadog
|
|
12
12
|
# @public_api
|
13
13
|
class Settings < Contrib::Configuration::Settings
|
14
14
|
option :enabled do |o|
|
15
|
-
o.
|
16
|
-
o.
|
15
|
+
o.type :bool
|
16
|
+
o.env Ext::ENV_ENABLED
|
17
|
+
o.default true
|
17
18
|
end
|
18
19
|
|
19
20
|
option :analytics_enabled do |o|
|
20
|
-
o.
|
21
|
-
o.
|
21
|
+
o.type :bool
|
22
|
+
o.env Ext::ENV_ANALYTICS_ENABLED
|
23
|
+
o.default false
|
22
24
|
end
|
23
25
|
|
24
26
|
option :analytics_sample_rate do |o|
|
25
|
-
o.
|
26
|
-
o.
|
27
|
+
o.type :float
|
28
|
+
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
|
29
|
+
o.default 1.0
|
27
30
|
end
|
28
31
|
|
29
32
|
option :service_name do |o|
|
@@ -33,7 +36,6 @@ module Datadog
|
|
33
36
|
Ext::DEFAULT_PEER_SERVICE_NAME
|
34
37
|
)
|
35
38
|
end
|
36
|
-
o.lazy
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -40,11 +40,6 @@ module Datadog
|
|
40
40
|
span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_MESSAGING_SYSTEM)
|
41
41
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
42
42
|
|
43
|
-
# Tag as an external peer service
|
44
|
-
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
45
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
|
46
|
-
end
|
47
|
-
|
48
43
|
# Set analytics sample rate
|
49
44
|
if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
|
50
45
|
Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Tracing
|
3
5
|
module Contrib
|
@@ -5,24 +7,24 @@ module Datadog
|
|
5
7
|
# Racecar integration constants
|
6
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
7
9
|
module Ext
|
8
|
-
ENV_ENABLED = 'DD_TRACE_RACECAR_ENABLED'
|
9
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACECAR_ANALYTICS_ENABLED'
|
10
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'
|
11
|
-
DEFAULT_PEER_SERVICE_NAME = 'racecar'
|
12
|
-
SPAN_CONSUME = 'racecar.consume'
|
13
|
-
SPAN_BATCH = 'racecar.batch'
|
14
|
-
SPAN_MESSAGE = 'racecar.message'
|
15
|
-
TAG_CONSUMER = 'kafka.consumer'
|
16
|
-
TAG_FIRST_OFFSET = 'kafka.first_offset'
|
17
|
-
TAG_MESSAGE_COUNT = 'kafka.message_count'
|
18
|
-
TAG_OFFSET = 'kafka.offset'
|
19
|
-
TAG_PARTITION = 'kafka.partition'
|
20
|
-
TAG_TOPIC = 'kafka.topic'
|
21
|
-
TAG_COMPONENT = 'racecar'
|
22
|
-
TAG_OPERATION_CONSUME = 'consume'
|
23
|
-
TAG_OPERATION_BATCH = 'batch'
|
24
|
-
TAG_OPERATION_MESSAGE = 'message'
|
25
|
-
TAG_MESSAGING_SYSTEM = 'kafka'
|
10
|
+
ENV_ENABLED = 'DD_TRACE_RACECAR_ENABLED'
|
11
|
+
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACECAR_ANALYTICS_ENABLED'
|
12
|
+
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'
|
13
|
+
DEFAULT_PEER_SERVICE_NAME = 'racecar'
|
14
|
+
SPAN_CONSUME = 'racecar.consume'
|
15
|
+
SPAN_BATCH = 'racecar.batch'
|
16
|
+
SPAN_MESSAGE = 'racecar.message'
|
17
|
+
TAG_CONSUMER = 'kafka.consumer'
|
18
|
+
TAG_FIRST_OFFSET = 'kafka.first_offset'
|
19
|
+
TAG_MESSAGE_COUNT = 'kafka.message_count'
|
20
|
+
TAG_OFFSET = 'kafka.offset'
|
21
|
+
TAG_PARTITION = 'kafka.partition'
|
22
|
+
TAG_TOPIC = 'kafka.topic'
|
23
|
+
TAG_COMPONENT = 'racecar'
|
24
|
+
TAG_OPERATION_CONSUME = 'consume'
|
25
|
+
TAG_OPERATION_BATCH = 'batch'
|
26
|
+
TAG_OPERATION_MESSAGE = 'message'
|
27
|
+
TAG_MESSAGING_SYSTEM = 'kafka'
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|
@@ -17,30 +17,34 @@ module Datadog
|
|
17
17
|
}.freeze
|
18
18
|
|
19
19
|
option :enabled do |o|
|
20
|
-
o.
|
21
|
-
o.
|
20
|
+
o.type :bool
|
21
|
+
o.env Ext::ENV_ENABLED
|
22
|
+
o.default true
|
22
23
|
end
|
23
24
|
|
24
25
|
option :analytics_enabled do |o|
|
25
|
-
o.
|
26
|
-
o.
|
26
|
+
o.type :bool, nilable: true
|
27
|
+
o.env Ext::ENV_ANALYTICS_ENABLED
|
27
28
|
end
|
28
29
|
|
29
30
|
option :analytics_sample_rate do |o|
|
30
|
-
o.
|
31
|
-
o.
|
31
|
+
o.type :float
|
32
|
+
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
|
33
|
+
o.default 1.0
|
32
34
|
end
|
33
35
|
|
34
36
|
option :application
|
35
|
-
option :distributed_tracing, default: true
|
36
|
-
option :headers, default: DEFAULT_HEADERS
|
37
|
-
option :middleware_names, default: false
|
38
|
-
option :quantize, default: {}
|
39
|
-
option :request_queuing
|
37
|
+
option :distributed_tracing, default: true, type: :bool
|
38
|
+
option :headers, default: DEFAULT_HEADERS, type: :hash
|
39
|
+
option :middleware_names, default: false, type: :bool
|
40
|
+
option :quantize, default: {}, type: :hash
|
41
|
+
option :request_queuing do |o|
|
42
|
+
o.default false
|
43
|
+
end
|
40
44
|
|
41
45
|
option :service_name
|
42
46
|
|
43
|
-
option :web_service_name, default: Ext::DEFAULT_PEER_WEBSERVER_SERVICE_NAME
|
47
|
+
option :web_service_name, default: Ext::DEFAULT_PEER_WEBSERVER_SERVICE_NAME, type: :string
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Tracing
|
3
5
|
module Contrib
|
@@ -5,22 +7,22 @@ module Datadog
|
|
5
7
|
# Rack integration constants
|
6
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
7
9
|
module Ext
|
8
|
-
ENV_ENABLED = 'DD_TRACE_RACK_ENABLED'
|
9
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACK_ANALYTICS_ENABLED'
|
10
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACK_ANALYTICS_SAMPLE_RATE'
|
11
|
-
RACK_ENV_REQUEST_SPAN = 'datadog.rack_request_span'
|
12
|
-
SPAN_HTTP_PROXY_REQUEST = 'http.proxy.request'
|
13
|
-
SPAN_HTTP_PROXY_QUEUE = 'http.proxy.queue'
|
14
|
-
SPAN_HTTP_SERVER_QUEUE = 'http_server.queue'
|
15
|
-
SPAN_REQUEST = 'rack.request'
|
16
|
-
TAG_COMPONENT = 'rack'
|
17
|
-
TAG_COMPONENT_HTTP_PROXY = 'http_proxy'
|
18
|
-
TAG_OPERATION_REQUEST = 'request'
|
19
|
-
TAG_OPERATION_HTTP_PROXY_REQUEST = 'request'
|
20
|
-
TAG_OPERATION_HTTP_PROXY_QUEUE = 'queue'
|
21
|
-
TAG_OPERATION_HTTP_SERVER_QUEUE = 'queue'
|
22
|
-
WEBSERVER_APP = 'webserver'
|
23
|
-
DEFAULT_PEER_WEBSERVER_SERVICE_NAME = 'web-server'
|
10
|
+
ENV_ENABLED = 'DD_TRACE_RACK_ENABLED'
|
11
|
+
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RACK_ANALYTICS_ENABLED'
|
12
|
+
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACK_ANALYTICS_SAMPLE_RATE'
|
13
|
+
RACK_ENV_REQUEST_SPAN = 'datadog.rack_request_span'
|
14
|
+
SPAN_HTTP_PROXY_REQUEST = 'http.proxy.request'
|
15
|
+
SPAN_HTTP_PROXY_QUEUE = 'http.proxy.queue'
|
16
|
+
SPAN_HTTP_SERVER_QUEUE = 'http_server.queue'
|
17
|
+
SPAN_REQUEST = 'rack.request'
|
18
|
+
TAG_COMPONENT = 'rack'
|
19
|
+
TAG_COMPONENT_HTTP_PROXY = 'http_proxy'
|
20
|
+
TAG_OPERATION_REQUEST = 'request'
|
21
|
+
TAG_OPERATION_HTTP_PROXY_REQUEST = 'request'
|
22
|
+
TAG_OPERATION_HTTP_PROXY_QUEUE = 'queue'
|
23
|
+
TAG_OPERATION_HTTP_SERVER_QUEUE = 'queue'
|
24
|
+
WEBSERVER_APP = 'webserver'
|
25
|
+
DEFAULT_PEER_WEBSERVER_SERVICE_NAME = 'web-server'
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -19,6 +19,9 @@ module Datadog
|
|
19
19
|
@env[Header.to_rack_header(header_name)]
|
20
20
|
end
|
21
21
|
|
22
|
+
# Allows this class to have a similar API to a {Hash}.
|
23
|
+
alias [] get
|
24
|
+
|
22
25
|
# Tests whether a header with the given name exists in the environment.
|
23
26
|
def key?(header_name)
|
24
27
|
@env.key?(Header.to_rack_header(header_name))
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module Tracing
|
5
|
+
module Contrib
|
6
|
+
module Rack
|
7
|
+
# Matches Rack-style headers with a matcher and sets matching headers into a span.
|
8
|
+
module HeaderTagging
|
9
|
+
def self.tag_request_headers(span, env, configuration)
|
10
|
+
# Wrap env in a case-insensitive Rack-style accessor.
|
11
|
+
headers = env.is_a?(Header::RequestHeaderCollection) ? env : Header::RequestHeaderCollection.new(env)
|
12
|
+
|
13
|
+
# Use global DD_TRACE_HEADER_TAGS if integration-level configuration is not provided
|
14
|
+
tags = if configuration.using_default?(:headers) && !Datadog.configuration.tracing.using_default?(:header_tags)
|
15
|
+
Datadog.configuration.tracing.header_tags.request_tags(headers)
|
16
|
+
else
|
17
|
+
whitelist = configuration[:headers][:request] || []
|
18
|
+
whitelist.each_with_object({}) do |header, result|
|
19
|
+
header_value = headers.get(header)
|
20
|
+
unless header_value.nil?
|
21
|
+
header_tag = Tracing::Metadata::Ext::HTTP::RequestHeaders.to_tag(header)
|
22
|
+
result[header_tag] = header_value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
span.set_tags(tags)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.tag_response_headers(span, headers, configuration)
|
31
|
+
headers = Core::Utils::Hash::CaseInsensitiveWrapper.new(headers) # Make header access case-insensitive
|
32
|
+
|
33
|
+
# Use global DD_TRACE_HEADER_TAGS if integration-level configuration is not provided
|
34
|
+
tags = if configuration.using_default?(:headers) && !Datadog.configuration.tracing.using_default?(:header_tags)
|
35
|
+
Datadog.configuration.tracing.header_tags.response_tags(headers)
|
36
|
+
else
|
37
|
+
whitelist = configuration[:headers][:response] || []
|
38
|
+
whitelist.each_with_object({}) do |header, result|
|
39
|
+
header_value = headers[header]
|
40
|
+
unless header_value.nil?
|
41
|
+
header_tag = Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)
|
42
|
+
result[header_tag] = header_value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
span.set_tags(tags)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
3
|
require_relative '../../../core/environment/variable_helpers'
|
4
|
+
require_relative '../../../core/backport'
|
4
5
|
require_relative '../../client_ip'
|
5
6
|
require_relative '../../metadata/ext'
|
6
7
|
require_relative '../../propagation/http'
|
@@ -8,6 +9,7 @@ require_relative '../analytics'
|
|
8
9
|
require_relative '../utils/quantization/http'
|
9
10
|
require_relative 'ext'
|
10
11
|
require_relative 'header_collection'
|
12
|
+
require_relative 'header_tagging'
|
11
13
|
require_relative 'request_queue'
|
12
14
|
|
13
15
|
module Datadog
|
@@ -69,6 +71,8 @@ module Datadog
|
|
69
71
|
|
70
72
|
return @app.call(env) if previous_request_span
|
71
73
|
|
74
|
+
Datadog::Core::Remote.active_remote.barrier(:once) unless Datadog::Core::Remote.active_remote.nil?
|
75
|
+
|
72
76
|
# Extract distributed tracing context before creating any spans,
|
73
77
|
# so that all spans will be added to the distributed trace.
|
74
78
|
if configuration[:distributed_tracing]
|
@@ -137,8 +141,6 @@ module Datadog
|
|
137
141
|
# rubocop:disable Metrics/MethodLength
|
138
142
|
def set_request_tags!(trace, request_span, env, status, headers, response, original_env)
|
139
143
|
request_header_collection = Header::RequestHeaderCollection.new(env)
|
140
|
-
request_headers_tags = parse_request_headers(request_header_collection)
|
141
|
-
response_headers_tags = parse_response_headers(headers || {})
|
142
144
|
|
143
145
|
# Since it could be mutated, it would be more accurate to fetch from the original env,
|
144
146
|
# e.g. ActionDispatch::ShowExceptions middleware with Rails exceptions_app configuration
|
@@ -227,15 +229,8 @@ module Datadog
|
|
227
229
|
request_span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_USER_AGENT, user_agent)
|
228
230
|
end
|
229
231
|
|
230
|
-
|
231
|
-
|
232
|
-
request_span.set_tag(name, value) if request_span.get_tag(name).nil?
|
233
|
-
end
|
234
|
-
|
235
|
-
# Response headers
|
236
|
-
response_headers_tags.each do |name, value|
|
237
|
-
request_span.set_tag(name, value) if request_span.get_tag(name).nil?
|
238
|
-
end
|
232
|
+
HeaderTagging.tag_request_headers(request_span, request_header_collection, configuration)
|
233
|
+
HeaderTagging.tag_response_headers(request_span, headers, configuration) if headers
|
239
234
|
|
240
235
|
# detect if the status code is a 5xx and flag the request span as an error
|
241
236
|
# unless it has been already set by the underlying framework
|
@@ -253,19 +248,12 @@ module Datadog
|
|
253
248
|
end
|
254
249
|
|
255
250
|
def trace_http_server(span_name, start_time:)
|
256
|
-
|
251
|
+
Tracing.trace(
|
257
252
|
span_name,
|
258
253
|
span_type: Tracing::Metadata::Ext::HTTP::TYPE_PROXY,
|
259
254
|
start_time: start_time,
|
260
255
|
service: configuration[:web_service_name]
|
261
256
|
)
|
262
|
-
|
263
|
-
# Set peer service (so its not believed to belong to this app)
|
264
|
-
if Contrib::SpanAttributeSchema.default_span_attribute_schema?
|
265
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, configuration[:web_service_name])
|
266
|
-
end
|
267
|
-
|
268
|
-
span
|
269
257
|
end
|
270
258
|
|
271
259
|
def parse_url(env, original_env)
|
@@ -304,7 +292,7 @@ module Datadog
|
|
304
292
|
else
|
305
293
|
# normally REQUEST_URI starts at the path, but it
|
306
294
|
# might contain the full URL in some cases (e.g WEBrick)
|
307
|
-
|
295
|
+
Datadog::Core::BackportFrom25.string_delete_prefix(request_uri, base_url)
|
308
296
|
end
|
309
297
|
|
310
298
|
base_url + fullpath
|
@@ -313,35 +301,6 @@ module Datadog
|
|
313
301
|
def parse_user_agent_header(headers)
|
314
302
|
headers.get(Tracing::Metadata::Ext::HTTP::HEADER_USER_AGENT)
|
315
303
|
end
|
316
|
-
|
317
|
-
def parse_request_headers(headers)
|
318
|
-
whitelist = configuration[:headers][:request] || []
|
319
|
-
whitelist.each_with_object({}) do |header, result|
|
320
|
-
header_value = headers.get(header)
|
321
|
-
unless header_value.nil?
|
322
|
-
header_tag = Tracing::Metadata::Ext::HTTP::RequestHeaders.to_tag(header)
|
323
|
-
result[header_tag] = header_value
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
def parse_response_headers(headers)
|
329
|
-
{}.tap do |result|
|
330
|
-
whitelist = configuration[:headers][:response] || []
|
331
|
-
whitelist.each do |header|
|
332
|
-
if headers.key?(header)
|
333
|
-
result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[header]
|
334
|
-
else
|
335
|
-
# Try a case-insensitive lookup
|
336
|
-
uppercased_header = header.to_s.upcase
|
337
|
-
matching_header = headers.keys.find { |h| h.upcase == uppercased_header }
|
338
|
-
if matching_header
|
339
|
-
result[Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)] = headers[matching_header]
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
304
|
end
|
346
305
|
end
|
347
306
|
end
|
@@ -24,13 +24,14 @@ module Datadog
|
|
24
24
|
end
|
25
25
|
|
26
26
|
option :enabled do |o|
|
27
|
-
o.
|
28
|
-
o.
|
27
|
+
o.type :bool
|
28
|
+
o.env Ext::ENV_ENABLED
|
29
|
+
o.default true
|
29
30
|
end
|
30
31
|
|
31
32
|
option :analytics_enabled do |o|
|
32
|
-
o.
|
33
|
-
o.
|
33
|
+
o.type :bool, nilable: true
|
34
|
+
o.env Ext::ENV_ANALYTICS_ENABLED
|
34
35
|
o.on_set do |value|
|
35
36
|
# Update ActionPack analytics too
|
36
37
|
Datadog.configuration.tracing[:action_pack][:analytics_enabled] = value
|
@@ -38,18 +39,20 @@ module Datadog
|
|
38
39
|
end
|
39
40
|
|
40
41
|
option :analytics_sample_rate do |o|
|
41
|
-
o.
|
42
|
-
o.
|
42
|
+
o.type :float
|
43
|
+
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
|
44
|
+
o.default 1.0
|
43
45
|
o.on_set do |value|
|
44
46
|
# Update ActionPack analytics too
|
45
47
|
Datadog.configuration.tracing[:action_pack][:analytics_sample_rate] = value
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
option :distributed_tracing, default: true
|
50
|
-
|
51
|
-
option :request_queuing, default: false
|
51
|
+
option :distributed_tracing, default: true, type: :bool
|
52
52
|
|
53
|
+
option :request_queuing do |o|
|
54
|
+
o.default false
|
55
|
+
end
|
53
56
|
# DEV-2.0: Breaking changes for removal.
|
54
57
|
option :exception_controller do |o|
|
55
58
|
o.on_set do |value|
|
@@ -62,9 +65,10 @@ module Datadog
|
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
|
-
option :middleware, default: true
|
66
|
-
option :middleware_names, default: false
|
68
|
+
option :middleware, default: true, type: :bool
|
69
|
+
option :middleware_names, default: false, type: :bool
|
67
70
|
option :template_base_path do |o|
|
71
|
+
o.type :string
|
68
72
|
o.default 'views/'
|
69
73
|
o.on_set do |value|
|
70
74
|
# Update ActionView template base path too
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Tracing
|
3
5
|
module Contrib
|
@@ -5,11 +7,11 @@ module Datadog
|
|
5
7
|
# Rails integration constants
|
6
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
7
9
|
module Ext
|
8
|
-
APP = 'rails'
|
9
|
-
ENV_ENABLED = 'DD_TRACE_RAILS_ENABLED'
|
10
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAILS_ANALYTICS_ENABLED'
|
11
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAILS_ANALYTICS_SAMPLE_RATE'
|
12
|
-
ENV_DISABLE = 'DISABLE_DATADOG_RAILS'
|
10
|
+
APP = 'rails'
|
11
|
+
ENV_ENABLED = 'DD_TRACE_RAILS_ENABLED'
|
12
|
+
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAILS_ANALYTICS_ENABLED'
|
13
|
+
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAILS_ANALYTICS_SAMPLE_RATE'
|
14
|
+
ENV_DISABLE = 'DISABLE_DATADOG_RAILS'
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -7,17 +7,11 @@ module Datadog
|
|
7
7
|
module LogInjection
|
8
8
|
module_function
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
app.config.log_tags = [proc { Tracing.log_correlation }]
|
15
|
-
# if existing log_tags configuration exists, append to the end of the array
|
16
|
-
elsif log_tags.is_a?(Array)
|
17
|
-
app.config.log_tags << proc { Tracing.log_correlation }
|
18
|
-
end
|
10
|
+
# Use `app.config.log_tags` to inject propagation tags into the default Rails logger.
|
11
|
+
def configure_log_tags(app)
|
12
|
+
app.config.log_tags ||= [] # Can be nil, we initialized it if so
|
13
|
+
app.config.log_tags << proc { Tracing.log_correlation if Datadog.configuration.tracing.log_injection }
|
19
14
|
rescue StandardError => e
|
20
|
-
# TODO: can we use Datadog.logger at this point?
|
21
15
|
Datadog.logger.warn(
|
22
16
|
"Unable to add Datadog Trace context to ActiveSupport::TaggedLogging: #{e.class.name} #{e.message}"
|
23
17
|
)
|
@@ -24,23 +24,24 @@ module Datadog
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def patch
|
27
|
-
|
28
|
-
|
27
|
+
patch_before_initialize
|
28
|
+
patch_after_initialize
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def patch_before_initialize
|
32
32
|
::ActiveSupport.on_load(:before_initialize) do
|
33
|
-
Contrib::Rails::Patcher.
|
33
|
+
Contrib::Rails::Patcher.before_initialize(self)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def before_initialize(app)
|
38
38
|
BEFORE_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
|
39
39
|
# Middleware must be added before the application is initialized.
|
40
40
|
# Otherwise the middleware stack will be frozen.
|
41
41
|
# Sometimes we don't want to activate middleware e.g. OpenTracing, etc.
|
42
42
|
add_middleware(app) if Datadog.configuration.tracing[:rails][:middleware]
|
43
|
-
|
43
|
+
|
44
|
+
Rails::LogInjection.configure_log_tags(app)
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
@@ -61,45 +62,13 @@ module Datadog
|
|
61
62
|
app.middleware.insert_after(::ActionDispatch::DebugExceptions, Contrib::Rails::ExceptionMiddleware)
|
62
63
|
end
|
63
64
|
|
64
|
-
def
|
65
|
-
should_warn = true
|
66
|
-
# check if lograge key exists
|
67
|
-
# Note: Rails executes initializers sequentially based on alphabetical order,
|
68
|
-
# and lograge config could occur after datadog config.
|
69
|
-
# So checking for `app.config.lograge.enabled` may yield a false negative,
|
70
|
-
# and adding custom options naively if `config.lograge` exists from the lograge Railtie,
|
71
|
-
# is inconsistent since a lograge initializer would override it.
|
72
|
-
# Instead, we patch Lograge `custom_options` internals directly
|
73
|
-
# as part of Rails framework patching
|
74
|
-
# and just flag off the warning log here.
|
75
|
-
# SemanticLogger we similarly patch in the after_initiaize block, and should flag
|
76
|
-
# off the warning log here if we know we'll patch this gem later.
|
77
|
-
should_warn = false if app.config.respond_to?(:lograge) || defined?(::SemanticLogger)
|
78
|
-
|
79
|
-
# if lograge isn't set, check if tagged logged is enabled.
|
80
|
-
# if so, add proc that injects trace identifiers for tagged logging.
|
81
|
-
logger = app.config.logger || ::Rails.logger
|
82
|
-
|
83
|
-
if logger \
|
84
|
-
&& defined?(::ActiveSupport::TaggedLogging) \
|
85
|
-
&& logger.is_a?(::ActiveSupport::TaggedLogging)
|
86
|
-
|
87
|
-
Contrib::Rails::LogInjection.add_as_tagged_logging_logger(app)
|
88
|
-
should_warn = false
|
89
|
-
end
|
90
|
-
|
91
|
-
if should_warn
|
92
|
-
Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger.class} is not supported")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def patch_after_intialize
|
65
|
+
def patch_after_initialize
|
97
66
|
::ActiveSupport.on_load(:after_initialize) do
|
98
|
-
Contrib::Rails::Patcher.
|
67
|
+
Contrib::Rails::Patcher.after_initialize(self)
|
99
68
|
end
|
100
69
|
end
|
101
70
|
|
102
|
-
def
|
71
|
+
def after_initialize(app)
|
103
72
|
AFTER_INITIALIZE_ONLY_ONCE_PER_APP[app].run do
|
104
73
|
# Finish configuring the tracer after the application is initialized.
|
105
74
|
# We need to wait for some things, like application name, middleware stack, etc.
|
@@ -6,12 +6,12 @@ module Datadog
|
|
6
6
|
# Railtie class initializes
|
7
7
|
class Railtie < Rails::Railtie
|
8
8
|
# Add the trace middleware to the application stack
|
9
|
-
initializer 'datadog.
|
10
|
-
Tracing::Contrib::Rails::Patcher.
|
9
|
+
initializer 'datadog.before_initialize' do |app|
|
10
|
+
Tracing::Contrib::Rails::Patcher.before_initialize(app)
|
11
11
|
end
|
12
12
|
|
13
13
|
config.after_initialize do
|
14
|
-
Tracing::Contrib::Rails::Patcher.
|
14
|
+
Tracing::Contrib::Rails::Patcher.after_initialize(self)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -14,21 +14,24 @@ module Datadog
|
|
14
14
|
# @public_api
|
15
15
|
class Settings < Contrib::Configuration::Settings
|
16
16
|
option :enabled do |o|
|
17
|
-
o.
|
18
|
-
o.
|
17
|
+
o.type :bool
|
18
|
+
o.env Ext::ENV_ENABLED
|
19
|
+
o.default true
|
19
20
|
end
|
20
21
|
|
21
22
|
option :analytics_enabled do |o|
|
22
|
-
o.
|
23
|
-
o.
|
23
|
+
o.type :bool
|
24
|
+
o.env Ext::ENV_ANALYTICS_ENABLED
|
25
|
+
o.default false
|
24
26
|
end
|
25
27
|
|
26
28
|
option :analytics_sample_rate do |o|
|
27
|
-
o.
|
28
|
-
o.
|
29
|
+
o.type :float
|
30
|
+
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
|
31
|
+
o.default 1.0
|
29
32
|
end
|
30
33
|
|
31
|
-
option :quantize, default: {}
|
34
|
+
option :quantize, default: {}, type: :hash
|
32
35
|
option :service_name
|
33
36
|
|
34
37
|
# A list of rake tasks, using their string names, to be instrumented.
|
@@ -36,8 +39,8 @@ module Datadog
|
|
36
39
|
# Automatically instrumenting all Rake tasks can lead to long-running tasks
|
37
40
|
# causing undue memory accumulation, as the trace for such tasks is never flushed.
|
38
41
|
option :tasks do |o|
|
39
|
-
o.
|
40
|
-
o.
|
42
|
+
o.type :array
|
43
|
+
o.default []
|
41
44
|
o.on_set do |value|
|
42
45
|
# DEV: It should be possible to modify the value after it's set. E.g. for normalization.
|
43
46
|
options[:tasks].instance_variable_set(:@value, value.map(&:to_s).to_set)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Datadog
|
2
4
|
module Tracing
|
3
5
|
module Contrib
|
@@ -5,18 +7,18 @@ module Datadog
|
|
5
7
|
# Rake integration constants
|
6
8
|
# @public_api Changing resource names, tag names, or environment variables creates breaking changes.
|
7
9
|
module Ext
|
8
|
-
ENV_ENABLED = 'DD_TRACE_RAKE_ENABLED'
|
9
|
-
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAKE_ANALYTICS_ENABLED'
|
10
|
-
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAKE_ANALYTICS_SAMPLE_RATE'
|
11
|
-
SERVICE_NAME = 'rake'
|
12
|
-
SPAN_INVOKE = 'rake.invoke'
|
13
|
-
SPAN_EXECUTE = 'rake.execute'
|
14
|
-
TAG_EXECUTE_ARGS = 'rake.execute.args'
|
15
|
-
TAG_INVOKE_ARGS = 'rake.invoke.args'
|
16
|
-
TAG_TASK_ARG_NAMES = 'rake.task.arg_names'
|
17
|
-
TAG_COMPONENT = 'rake'
|
18
|
-
TAG_OPERATION_EXECUTE = 'execute'
|
19
|
-
TAG_OPERATION_INVOKE = 'invoke'
|
10
|
+
ENV_ENABLED = 'DD_TRACE_RAKE_ENABLED'
|
11
|
+
ENV_ANALYTICS_ENABLED = 'DD_TRACE_RAKE_ANALYTICS_ENABLED'
|
12
|
+
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RAKE_ANALYTICS_SAMPLE_RATE'
|
13
|
+
SERVICE_NAME = 'rake'
|
14
|
+
SPAN_INVOKE = 'rake.invoke'
|
15
|
+
SPAN_EXECUTE = 'rake.execute'
|
16
|
+
TAG_EXECUTE_ARGS = 'rake.execute.args'
|
17
|
+
TAG_INVOKE_ARGS = 'rake.invoke.args'
|
18
|
+
TAG_TASK_ARG_NAMES = 'rake.task.arg_names'
|
19
|
+
TAG_COMPONENT = 'rake'
|
20
|
+
TAG_OPERATION_EXECUTE = 'execute'
|
21
|
+
TAG_OPERATION_INVOKE = 'invoke'
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|