ddtrace 1.14.0 → 1.16.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 +4 -4
- data/CHANGELOG.md +146 -2
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +3 -5
- data/ext/ddtrace_profiling_native_extension/clock_id.h +0 -3
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +0 -22
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +0 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +41 -6
- data/ext/ddtrace_profiling_native_extension/collectors_idle_sampling_helper.c +3 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +76 -24
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +207 -32
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.h +1 -1
- data/ext/ddtrace_profiling_native_extension/extconf.rb +8 -2
- data/ext/ddtrace_profiling_native_extension/http_transport.c +26 -10
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.c +42 -0
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +6 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -16
- data/ext/ddtrace_profiling_native_extension/pid_controller.c +57 -0
- data/ext/ddtrace_profiling_native_extension/pid_controller.h +45 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +17 -12
- data/ext/ddtrace_profiling_native_extension/profiling.c +0 -2
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +74 -37
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +13 -3
- data/lib/datadog/appsec/assets/waf_rules/processors.json +92 -0
- data/lib/datadog/appsec/assets/waf_rules/recommended.json +698 -75
- data/lib/datadog/appsec/assets/waf_rules/scanners.json +114 -0
- data/lib/datadog/appsec/assets/waf_rules/strict.json +98 -8
- data/lib/datadog/appsec/assets.rb +8 -0
- data/lib/datadog/appsec/component.rb +9 -2
- data/lib/datadog/appsec/configuration/settings.rb +67 -2
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +6 -2
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +46 -0
- data/lib/datadog/appsec/contrib/rack/gateway/watcher.rb +8 -6
- data/lib/datadog/appsec/contrib/rack/reactive/request.rb +2 -7
- data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +2 -5
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +7 -5
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +3 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +34 -10
- data/lib/datadog/appsec/contrib/rails/gateway/watcher.rb +3 -2
- data/lib/datadog/appsec/contrib/rails/patcher.rb +9 -3
- data/lib/datadog/appsec/contrib/rails/reactive/action.rb +2 -5
- data/lib/datadog/appsec/contrib/sinatra/gateway/watcher.rb +6 -4
- data/lib/datadog/appsec/contrib/sinatra/patcher.rb +13 -7
- data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +2 -5
- data/lib/datadog/appsec/event.rb +106 -50
- data/lib/datadog/appsec/monitor/gateway/watcher.rb +3 -3
- data/lib/datadog/appsec/monitor/reactive/set_user.rb +2 -5
- data/lib/datadog/appsec/processor/actions.rb +49 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +22 -2
- data/lib/datadog/appsec/processor.rb +34 -6
- data/lib/datadog/appsec/remote.rb +4 -1
- data/lib/datadog/appsec/response.rb +82 -4
- data/lib/datadog/appsec/sample_rate.rb +21 -0
- data/lib/datadog/appsec.rb +2 -2
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +29 -24
- data/lib/datadog/core/configuration/base.rb +1 -11
- data/lib/datadog/core/configuration/components.rb +7 -2
- data/lib/datadog/core/configuration/ext.rb +21 -0
- data/lib/datadog/core/configuration/option.rb +2 -4
- data/lib/datadog/core/configuration/option_definition.rb +17 -41
- data/lib/datadog/core/configuration/options.rb +5 -5
- data/lib/datadog/core/configuration/settings.rb +47 -45
- data/lib/datadog/core/environment/execution.rb +47 -9
- data/lib/datadog/core/environment/variable_helpers.rb +0 -69
- data/lib/datadog/core/error.rb +1 -0
- data/lib/datadog/core/git/ext.rb +2 -0
- data/lib/datadog/core/remote/client/capabilities.rb +1 -1
- data/lib/datadog/core/remote/component.rb +2 -2
- data/lib/datadog/core/remote/negotiation.rb +2 -2
- data/lib/datadog/core/remote/transport/config.rb +60 -0
- data/lib/datadog/core/remote/transport/http/api/instance.rb +39 -0
- data/lib/datadog/core/remote/transport/http/api/spec.rb +21 -0
- data/lib/datadog/core/remote/transport/http/api.rb +58 -0
- data/lib/datadog/core/remote/transport/http/builder.rb +219 -0
- data/lib/datadog/core/remote/transport/http/client.rb +48 -0
- data/lib/datadog/core/remote/transport/http/config.rb +280 -0
- data/lib/datadog/core/remote/transport/http/negotiation.rb +146 -0
- data/lib/datadog/core/remote/transport/http.rb +179 -0
- data/lib/datadog/core/{transport → remote/transport}/negotiation.rb +25 -23
- data/lib/datadog/core/remote/worker.rb +3 -1
- data/lib/datadog/core/telemetry/collector.rb +3 -2
- data/lib/datadog/core/telemetry/http/transport.rb +2 -1
- data/lib/datadog/core/transport/ext.rb +47 -0
- data/lib/datadog/core/transport/http/adapters/net.rb +168 -0
- data/lib/datadog/core/transport/http/adapters/registry.rb +29 -0
- data/lib/datadog/core/transport/http/adapters/test.rb +89 -0
- data/lib/datadog/core/transport/http/adapters/unix_socket.rb +83 -0
- data/lib/datadog/core/transport/http/api/endpoint.rb +31 -0
- data/lib/datadog/core/transport/http/api/fallbacks.rb +26 -0
- data/lib/datadog/core/transport/http/api/map.rb +18 -0
- data/lib/datadog/core/transport/http/env.rb +62 -0
- data/lib/datadog/core/transport/http/response.rb +60 -0
- data/lib/datadog/core/transport/parcel.rb +22 -0
- data/lib/datadog/core/transport/request.rb +17 -0
- data/lib/datadog/core/transport/response.rb +64 -0
- data/lib/datadog/core/workers/polling.rb +2 -2
- data/lib/datadog/opentelemetry/api/context.rb +10 -3
- data/lib/datadog/opentelemetry/sdk/propagator.rb +2 -1
- data/lib/datadog/opentelemetry/sdk/span_processor.rb +14 -2
- data/lib/datadog/opentelemetry/sdk/trace/span.rb +68 -0
- data/lib/datadog/opentelemetry/trace.rb +58 -0
- data/lib/datadog/opentelemetry.rb +1 -0
- data/lib/datadog/opentracer.rb +9 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +14 -19
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/thread_context.rb +9 -1
- data/lib/datadog/profiling/component.rb +24 -99
- data/lib/datadog/profiling/ext.rb +0 -12
- data/lib/datadog/profiling/flush.rb +0 -3
- data/lib/datadog/profiling/http_transport.rb +6 -3
- data/lib/datadog/profiling/native_extension.rb +0 -21
- data/lib/datadog/profiling/profiler.rb +36 -13
- data/lib/datadog/profiling/scheduler.rb +16 -9
- data/lib/datadog/profiling.rb +8 -81
- data/lib/datadog/tracing/component.rb +10 -4
- data/lib/datadog/tracing/configuration/agent_settings_resolver.rb +13 -0
- data/lib/datadog/tracing/configuration/ext.rb +4 -2
- data/lib/datadog/tracing/configuration/settings.rb +14 -7
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +106 -197
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +3 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +7 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +14 -14
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +3 -10
- data/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +2 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +8 -1
- data/lib/datadog/tracing/contrib/concurrent_ruby/promises_future_patch.rb +22 -0
- data/lib/datadog/tracing/contrib/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +6 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +7 -0
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +9 -2
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +5 -0
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +5 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +8 -0
- data/lib/datadog/tracing/contrib/excon/middleware.rb +5 -0
- data/lib/datadog/tracing/contrib/ext.rb +3 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +5 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +21 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +11 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +18 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +0 -4
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +3 -3
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +7 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +13 -3
- data/lib/datadog/tracing/contrib/opensearch/integration.rb +2 -2
- data/lib/datadog/tracing/contrib/opensearch/patcher.rb +7 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/presto/instrumentation.rb +5 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +1 -1
- data/lib/datadog/tracing/contrib/que/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/racecar/event.rb +5 -0
- data/lib/datadog/tracing/contrib/rack/header_tagging.rb +14 -4
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +4 -4
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +3 -38
- data/lib/datadog/tracing/contrib/redis/tags.rb +7 -2
- data/lib/datadog/tracing/contrib/redis/trace_middleware.rb +46 -33
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +5 -0
- data/lib/datadog/tracing/contrib/sequel/utils.rb +5 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +6 -0
- data/lib/datadog/tracing/distributed/propagation.rb +13 -33
- data/lib/datadog/tracing/metadata/tagging.rb +3 -3
- data/lib/datadog/tracing/sync_writer.rb +3 -3
- data/lib/datadog/tracing/tracer.rb +2 -0
- data/lib/datadog/{core → tracing}/transport/http/api/instance.rb +1 -1
- data/lib/datadog/{core → tracing}/transport/http/api/spec.rb +1 -1
- data/lib/datadog/tracing/transport/http/api.rb +43 -0
- data/lib/datadog/{core → tracing}/transport/http/builder.rb +13 -68
- data/lib/datadog/tracing/transport/http/client.rb +57 -0
- data/lib/datadog/tracing/transport/http/statistics.rb +47 -0
- data/lib/datadog/tracing/transport/http/traces.rb +152 -0
- data/lib/datadog/tracing/transport/http.rb +124 -0
- data/lib/datadog/tracing/transport/io/client.rb +89 -0
- data/lib/datadog/tracing/transport/io/response.rb +27 -0
- data/lib/datadog/tracing/transport/io/traces.rb +101 -0
- data/lib/datadog/tracing/transport/io.rb +30 -0
- data/lib/datadog/tracing/transport/serializable_trace.rb +126 -0
- data/lib/datadog/tracing/transport/statistics.rb +77 -0
- data/lib/datadog/tracing/transport/trace_formatter.rb +209 -0
- data/lib/datadog/tracing/transport/traces.rb +224 -0
- data/lib/datadog/tracing/workers/trace_writer.rb +5 -3
- data/lib/datadog/tracing/workers.rb +3 -2
- data/lib/datadog/tracing/writer.rb +5 -2
- data/lib/ddtrace/transport/ext.rb +17 -15
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace.rb +1 -1
- metadata +73 -96
- data/lib/datadog/ci/configuration/components.rb +0 -32
- data/lib/datadog/ci/configuration/settings.rb +0 -51
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/cucumber/ext.rb +0 -22
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +0 -94
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +0 -28
- data/lib/datadog/ci/contrib/cucumber/integration.rb +0 -47
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +0 -27
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/minitest/ext.rb +0 -21
- data/lib/datadog/ci/contrib/minitest/integration.rb +0 -49
- data/lib/datadog/ci/contrib/minitest/patcher.rb +0 -27
- data/lib/datadog/ci/contrib/minitest/test_helper.rb +0 -68
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +0 -35
- data/lib/datadog/ci/contrib/rspec/example.rb +0 -68
- data/lib/datadog/ci/contrib/rspec/ext.rb +0 -21
- data/lib/datadog/ci/contrib/rspec/integration.rb +0 -48
- data/lib/datadog/ci/contrib/rspec/patcher.rb +0 -27
- data/lib/datadog/ci/ext/app_types.rb +0 -9
- data/lib/datadog/ci/ext/environment.rb +0 -575
- data/lib/datadog/ci/ext/settings.rb +0 -10
- data/lib/datadog/ci/ext/test.rb +0 -35
- data/lib/datadog/ci/extensions.rb +0 -19
- data/lib/datadog/ci/flush.rb +0 -38
- data/lib/datadog/ci/test.rb +0 -81
- data/lib/datadog/ci.rb +0 -21
- data/lib/datadog/core/configuration/dependency_resolver.rb +0 -28
- data/lib/datadog/core/configuration/option_definition_set.rb +0 -22
- data/lib/datadog/core/configuration/option_set.rb +0 -10
- data/lib/datadog/core/transport/config.rb +0 -58
- data/lib/datadog/core/transport/http/api.rb +0 -57
- data/lib/datadog/core/transport/http/client.rb +0 -45
- data/lib/datadog/core/transport/http/config.rb +0 -278
- data/lib/datadog/core/transport/http/negotiation.rb +0 -144
- data/lib/datadog/core/transport/http.rb +0 -169
- data/lib/datadog/core/utils/object_set.rb +0 -43
- data/lib/datadog/core/utils/string_table.rb +0 -47
- data/lib/datadog/profiling/backtrace_location.rb +0 -34
- data/lib/datadog/profiling/buffer.rb +0 -43
- data/lib/datadog/profiling/collectors/old_stack.rb +0 -301
- data/lib/datadog/profiling/encoding/profile.rb +0 -41
- data/lib/datadog/profiling/event.rb +0 -15
- data/lib/datadog/profiling/events/stack.rb +0 -82
- data/lib/datadog/profiling/old_recorder.rb +0 -107
- data/lib/datadog/profiling/pprof/builder.rb +0 -125
- data/lib/datadog/profiling/pprof/converter.rb +0 -102
- data/lib/datadog/profiling/pprof/message_set.rb +0 -16
- data/lib/datadog/profiling/pprof/payload.rb +0 -20
- data/lib/datadog/profiling/pprof/pprof.proto +0 -212
- data/lib/datadog/profiling/pprof/pprof_pb.rb +0 -81
- data/lib/datadog/profiling/pprof/stack_sample.rb +0 -139
- data/lib/datadog/profiling/pprof/string_table.rb +0 -12
- data/lib/datadog/profiling/pprof/template.rb +0 -118
- data/lib/datadog/profiling/trace_identifiers/ddtrace.rb +0 -43
- data/lib/datadog/profiling/trace_identifiers/helper.rb +0 -45
- data/lib/ddtrace/transport/http/adapters/net.rb +0 -168
- data/lib/ddtrace/transport/http/adapters/registry.rb +0 -27
- data/lib/ddtrace/transport/http/adapters/test.rb +0 -85
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +0 -77
- data/lib/ddtrace/transport/http/api/endpoint.rb +0 -29
- data/lib/ddtrace/transport/http/api/fallbacks.rb +0 -24
- data/lib/ddtrace/transport/http/api/instance.rb +0 -35
- data/lib/ddtrace/transport/http/api/map.rb +0 -16
- data/lib/ddtrace/transport/http/api/spec.rb +0 -17
- data/lib/ddtrace/transport/http/api.rb +0 -39
- data/lib/ddtrace/transport/http/builder.rb +0 -176
- data/lib/ddtrace/transport/http/client.rb +0 -52
- data/lib/ddtrace/transport/http/env.rb +0 -58
- data/lib/ddtrace/transport/http/response.rb +0 -58
- data/lib/ddtrace/transport/http/statistics.rb +0 -43
- data/lib/ddtrace/transport/http/traces.rb +0 -144
- data/lib/ddtrace/transport/http.rb +0 -117
- data/lib/ddtrace/transport/io/client.rb +0 -85
- data/lib/ddtrace/transport/io/response.rb +0 -25
- data/lib/ddtrace/transport/io/traces.rb +0 -99
- data/lib/ddtrace/transport/io.rb +0 -28
- data/lib/ddtrace/transport/parcel.rb +0 -20
- data/lib/ddtrace/transport/request.rb +0 -15
- data/lib/ddtrace/transport/response.rb +0 -60
- data/lib/ddtrace/transport/serializable_trace.rb +0 -122
- data/lib/ddtrace/transport/statistics.rb +0 -75
- data/lib/ddtrace/transport/trace_formatter.rb +0 -207
- data/lib/ddtrace/transport/traces.rb +0 -216
|
@@ -121,6 +121,11 @@ module Datadog
|
|
|
121
121
|
)
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
+
# Tag original global service name if not used
|
|
125
|
+
if span.service != Datadog.configuration.service
|
|
126
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
127
|
+
end
|
|
128
|
+
|
|
124
129
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
125
130
|
|
|
126
131
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
@@ -45,6 +45,9 @@ module Datadog
|
|
|
45
45
|
|
|
46
46
|
# Value of tag from which peer.service value was remapped from
|
|
47
47
|
TAG_PEER_SERVICE_REMAP = '_dd.peer.service.remapped_from'
|
|
48
|
+
|
|
49
|
+
# Set equal to the global service when contrib span.service is overriden
|
|
50
|
+
TAG_BASE_SERVICE = '_dd.base_service'
|
|
48
51
|
end
|
|
49
52
|
end
|
|
50
53
|
end
|
|
@@ -36,7 +36,7 @@ module Datadog
|
|
|
36
36
|
option :distributed_tracing, default: true, type: :bool
|
|
37
37
|
option :error_handler do |o|
|
|
38
38
|
o.type :proc
|
|
39
|
-
o.
|
|
39
|
+
o.default_proc(&DEFAULT_ERROR_HANDLER)
|
|
40
40
|
end
|
|
41
41
|
option :split_by_domain, default: false, type: :bool
|
|
42
42
|
|
|
@@ -47,6 +47,11 @@ module Datadog
|
|
|
47
47
|
)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
# Tag original global service name if not used
|
|
51
|
+
if span.service != Datadog.configuration.service
|
|
52
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
53
|
+
end
|
|
54
|
+
|
|
50
55
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
51
56
|
|
|
52
57
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
@@ -48,7 +48,27 @@ module Datadog
|
|
|
48
48
|
|
|
49
49
|
option :error_handler do |o|
|
|
50
50
|
o.type :proc
|
|
51
|
-
o.
|
|
51
|
+
o.default_proc(&Tracing::SpanOperation::Events::DEFAULT_ON_ERROR)
|
|
52
|
+
o.after_set do |value|
|
|
53
|
+
if value != Tracing::SpanOperation::Events::DEFAULT_ON_ERROR
|
|
54
|
+
Datadog.logger.warn(
|
|
55
|
+
'The gRPC `error_handler` setting has been deprecated for removal. Please replace ' \
|
|
56
|
+
'it with `server_error_handler` which is explicit about only handling errors from ' \
|
|
57
|
+
'server interceptors. Alternatively, to handle errors from client interceptors use ' \
|
|
58
|
+
'the `client_error_handler` setting instead.'
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
option :server_error_handler do |o|
|
|
65
|
+
o.type :proc
|
|
66
|
+
o.default_proc(&Tracing::SpanOperation::Events::DEFAULT_ON_ERROR)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
option :client_error_handler do |o|
|
|
70
|
+
o.type :proc
|
|
71
|
+
o.default_proc(&Tracing::SpanOperation::Events::DEFAULT_ON_ERROR)
|
|
52
72
|
end
|
|
53
73
|
end
|
|
54
74
|
end
|
|
@@ -22,7 +22,8 @@ module Datadog
|
|
|
22
22
|
options = {
|
|
23
23
|
span_type: Tracing::Metadata::Ext::HTTP::TYPE_OUTBOUND,
|
|
24
24
|
service: service_name, # Maintain client-side service name configuration
|
|
25
|
-
resource: formatter.resource_name
|
|
25
|
+
resource: formatter.resource_name,
|
|
26
|
+
on_error: error_handler
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
Tracing.trace(Ext::SPAN_CLIENT, **options) do |span, trace|
|
|
@@ -56,6 +57,11 @@ module Datadog
|
|
|
56
57
|
)
|
|
57
58
|
end
|
|
58
59
|
|
|
60
|
+
# Tag original global service name if not used
|
|
61
|
+
if span.service != Datadog.configuration.service
|
|
62
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
63
|
+
end
|
|
64
|
+
|
|
59
65
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
60
66
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
61
67
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_CLIENT)
|
|
@@ -101,6 +107,10 @@ module Datadog
|
|
|
101
107
|
Datadog.logger.debug { "Could not parse host:port from #{call}: #{e}" }
|
|
102
108
|
nil
|
|
103
109
|
end
|
|
110
|
+
|
|
111
|
+
def error_handler
|
|
112
|
+
Datadog.configuration_for(self, :error_handler) || datadog_configuration[:client_error_handler]
|
|
113
|
+
end
|
|
104
114
|
end
|
|
105
115
|
end
|
|
106
116
|
end
|
|
@@ -64,6 +64,11 @@ module Datadog
|
|
|
64
64
|
span.set_tag(header, value)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
# Tag original global service name if not used
|
|
68
|
+
if span.service != Datadog.configuration.service
|
|
69
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
70
|
+
end
|
|
71
|
+
|
|
67
72
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_SERVER)
|
|
68
73
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
69
74
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_SERVICE)
|
|
@@ -81,6 +86,19 @@ module Datadog
|
|
|
81
86
|
rescue StandardError => e
|
|
82
87
|
Datadog.logger.debug("GRPC server trace failed: #{e}")
|
|
83
88
|
end
|
|
89
|
+
|
|
90
|
+
def error_handler
|
|
91
|
+
self_handler = Datadog.configuration_for(self, :error_handler)
|
|
92
|
+
return self_handler if self_handler
|
|
93
|
+
|
|
94
|
+
unless datadog_configuration.using_default?(:server_error_handler)
|
|
95
|
+
return datadog_configuration[:server_error_handler]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# As a last resort, fallback to the deprecated error_handler
|
|
99
|
+
# configuration option.
|
|
100
|
+
datadog_configuration[:error_handler]
|
|
101
|
+
end
|
|
84
102
|
end
|
|
85
103
|
end
|
|
86
104
|
end
|
|
@@ -58,10 +58,6 @@ module Datadog
|
|
|
58
58
|
datadog_configuration[:analytics_sample_rate]
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
def error_handler
|
|
62
|
-
datadog_configuration[:error_handler]
|
|
63
|
-
end
|
|
64
|
-
|
|
65
61
|
# Allows interceptors to define settings using methods instead of `[]`
|
|
66
62
|
class PinAdapter
|
|
67
63
|
OPTIONS = Configuration::Settings.instance_methods(false).freeze
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative '
|
|
3
|
+
require_relative '../../../core/transport/ext'
|
|
4
4
|
|
|
5
5
|
module Datadog
|
|
6
6
|
module Tracing
|
|
@@ -24,8 +24,8 @@ module Datadog
|
|
|
24
24
|
# TODO: We don't want this kind of soft-check on HTTP requests.
|
|
25
25
|
# Remove this when transport implements its own "skip tracing" mechanism.
|
|
26
26
|
def internal_request?(request)
|
|
27
|
-
!!(request[Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION] ||
|
|
28
|
-
request[Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST])
|
|
27
|
+
!!(request[Datadog::Core::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION] ||
|
|
28
|
+
request[Datadog::Core::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST])
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def should_skip_distributed_tracing?(client_config)
|
|
@@ -76,6 +76,11 @@ module Datadog
|
|
|
76
76
|
)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# Tag original global service name if not used
|
|
80
|
+
if span.service != Datadog.configuration.service
|
|
81
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
82
|
+
end
|
|
83
|
+
|
|
79
84
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
80
85
|
|
|
81
86
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
@@ -58,6 +58,11 @@ module Datadog
|
|
|
58
58
|
)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
# Tag original global service name if not used
|
|
62
|
+
if span.service != Datadog.configuration.service
|
|
63
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
64
|
+
end
|
|
65
|
+
|
|
61
66
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
62
67
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
|
|
63
68
|
|
|
@@ -58,6 +58,11 @@ module Datadog
|
|
|
58
58
|
)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
# Tag original global service name if not used
|
|
62
|
+
if span.service != Datadog.configuration.service
|
|
63
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
64
|
+
end
|
|
65
|
+
|
|
61
66
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
62
67
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
|
|
63
68
|
|
|
@@ -11,6 +11,7 @@ module Datadog
|
|
|
11
11
|
# `MongoCommandSubscriber` listens to all events from the `Monitoring`
|
|
12
12
|
# system available in the Mongo driver.
|
|
13
13
|
class MongoCommandSubscriber
|
|
14
|
+
# rubocop:disable Metrics/AbcSize
|
|
14
15
|
def started(event)
|
|
15
16
|
return unless Tracing.enabled?
|
|
16
17
|
|
|
@@ -36,6 +37,11 @@ module Datadog
|
|
|
36
37
|
)
|
|
37
38
|
end
|
|
38
39
|
|
|
40
|
+
# Tag original global service name if not used
|
|
41
|
+
if span.service != Datadog.configuration.service
|
|
42
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
43
|
+
end
|
|
44
|
+
|
|
39
45
|
span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM)
|
|
40
46
|
|
|
41
47
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
@@ -63,6 +69,7 @@ module Datadog
|
|
|
63
69
|
# set the resource with the quantized query
|
|
64
70
|
span.resource = serialized_query
|
|
65
71
|
end
|
|
72
|
+
# rubocop:enable Metrics/AbcSize
|
|
66
73
|
|
|
67
74
|
def failed(event)
|
|
68
75
|
span = get_span(event)
|
|
@@ -33,6 +33,11 @@ module Datadog
|
|
|
33
33
|
)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# Tag original global service name if not used
|
|
37
|
+
if span.service != Datadog.configuration.service
|
|
38
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
39
|
+
end
|
|
40
|
+
|
|
36
41
|
span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM)
|
|
37
42
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
38
43
|
|
|
@@ -48,12 +53,17 @@ module Datadog
|
|
|
48
53
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, query_options[:host])
|
|
49
54
|
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, query_options[:port])
|
|
50
55
|
|
|
56
|
+
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
57
|
+
|
|
51
58
|
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(comment_propagation)
|
|
52
59
|
|
|
53
60
|
Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
|
|
54
|
-
sql = Contrib::Propagation::SqlComment.prepend_comment(
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
sql = Contrib::Propagation::SqlComment.prepend_comment(
|
|
62
|
+
sql,
|
|
63
|
+
span,
|
|
64
|
+
trace_op,
|
|
65
|
+
propagation_mode
|
|
66
|
+
)
|
|
57
67
|
|
|
58
68
|
super(sql, options)
|
|
59
69
|
end
|
|
@@ -18,8 +18,8 @@ module Datadog
|
|
|
18
18
|
register_as :opensearch, auto_patch: true
|
|
19
19
|
|
|
20
20
|
def self.version
|
|
21
|
-
Gem.loaded_specs['opensearch-
|
|
22
|
-
&& Gem.loaded_specs['opensearch-
|
|
21
|
+
Gem.loaded_specs['opensearch-ruby'] \
|
|
22
|
+
&& Gem.loaded_specs['opensearch-ruby'].version
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def self.loaded?
|
|
@@ -28,6 +28,7 @@ module Datadog
|
|
|
28
28
|
# Patches OpenSearch::Transport::Client module
|
|
29
29
|
module Client
|
|
30
30
|
# rubocop:disable Metrics/MethodLength
|
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
|
31
32
|
def perform_request(method, path, params = {}, body = nil, headers = nil)
|
|
32
33
|
response = nil
|
|
33
34
|
# rubocop:disable Metrics/BlockLength
|
|
@@ -61,6 +62,11 @@ module Datadog
|
|
|
61
62
|
)
|
|
62
63
|
end
|
|
63
64
|
|
|
65
|
+
# Tag original global service name if not used
|
|
66
|
+
if span.service != Datadog.configuration.service
|
|
67
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
68
|
+
end
|
|
69
|
+
|
|
64
70
|
# Set url tags
|
|
65
71
|
span.set_tag(OpenSearch::Ext::TAG_URL, url)
|
|
66
72
|
span.set_tag(OpenSearch::Ext::TAG_HOST, host)
|
|
@@ -94,6 +100,7 @@ module Datadog
|
|
|
94
100
|
end
|
|
95
101
|
end
|
|
96
102
|
# rubocop:enable Metrics/BlockLength
|
|
103
|
+
# rubocop:enable Metrics/AbcSize
|
|
97
104
|
response
|
|
98
105
|
end
|
|
99
106
|
|
|
@@ -129,6 +129,11 @@ module Datadog
|
|
|
129
129
|
)
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
+
# Tag original global service name if not used
|
|
133
|
+
if span.service != Datadog.configuration.service
|
|
134
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
135
|
+
end
|
|
136
|
+
|
|
132
137
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
133
138
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_QUERY)
|
|
134
139
|
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
|
@@ -90,6 +90,11 @@ module Datadog
|
|
|
90
90
|
)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
# Tag original global service name if not used
|
|
94
|
+
if span.service != Datadog.configuration.service
|
|
95
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
96
|
+
end
|
|
97
|
+
|
|
93
98
|
if (host_port = @options[:server])
|
|
94
99
|
host, port = Core::Utils.extract_host_port(host_port)
|
|
95
100
|
if host && port
|
|
@@ -21,7 +21,7 @@ module Datadog
|
|
|
21
21
|
return sql unless mode.enabled?
|
|
22
22
|
|
|
23
23
|
tags = {
|
|
24
|
-
Ext::KEY_DATABASE_SERVICE => span_op.service,
|
|
24
|
+
Ext::KEY_DATABASE_SERVICE => span_op.get_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE) || span_op.service,
|
|
25
25
|
Ext::KEY_ENVIRONMENT => datadog_configuration.env,
|
|
26
26
|
Ext::KEY_PARENT_SERVICE => datadog_configuration.service,
|
|
27
27
|
Ext::KEY_VERSION => datadog_configuration.version
|
|
@@ -48,6 +48,11 @@ module Datadog
|
|
|
48
48
|
# Measure service stats
|
|
49
49
|
Contrib::Analytics.set_measured(span)
|
|
50
50
|
|
|
51
|
+
# Tag original global service name if not used
|
|
52
|
+
if span.service != Datadog.configuration.service
|
|
53
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
54
|
+
end
|
|
55
|
+
|
|
51
56
|
span.set_tag(Ext::TAG_TOPIC, payload[:topic])
|
|
52
57
|
span.set_tag(Ext::TAG_CONSUMER, payload[:consumer_class])
|
|
53
58
|
span.set_tag(Ext::TAG_PARTITION, payload[:partition])
|
|
@@ -37,10 +37,20 @@ module Datadog
|
|
|
37
37
|
whitelist = configuration[:headers][:response] || []
|
|
38
38
|
whitelist.each_with_object({}) do |header, result|
|
|
39
39
|
header_value = headers[header]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
|
|
41
|
+
next if header_value.nil?
|
|
42
|
+
|
|
43
|
+
header_tag = Tracing::Metadata::Ext::HTTP::ResponseHeaders.to_tag(header)
|
|
44
|
+
|
|
45
|
+
# Maintain the value format between Rack 2 and 3
|
|
46
|
+
#
|
|
47
|
+
# Rack 2.x => { 'foo' => 'bar,baz' }
|
|
48
|
+
# Rack 3.x => { 'foo' => ['bar', 'baz'] }
|
|
49
|
+
result[header_tag] = if header_value.is_a? Array
|
|
50
|
+
header_value.join(',')
|
|
51
|
+
else
|
|
52
|
+
header_value
|
|
53
|
+
end
|
|
44
54
|
end
|
|
45
55
|
end
|
|
46
56
|
|
|
@@ -32,7 +32,7 @@ module Datadog
|
|
|
32
32
|
option :analytics_enabled do |o|
|
|
33
33
|
o.type :bool, nilable: true
|
|
34
34
|
o.env Ext::ENV_ANALYTICS_ENABLED
|
|
35
|
-
o.
|
|
35
|
+
o.after_set do |value|
|
|
36
36
|
# Update ActionPack analytics too
|
|
37
37
|
Datadog.configuration.tracing[:action_pack][:analytics_enabled] = value
|
|
38
38
|
end
|
|
@@ -42,7 +42,7 @@ module Datadog
|
|
|
42
42
|
o.type :float
|
|
43
43
|
o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
|
|
44
44
|
o.default 1.0
|
|
45
|
-
o.
|
|
45
|
+
o.after_set do |value|
|
|
46
46
|
# Update ActionPack analytics too
|
|
47
47
|
Datadog.configuration.tracing[:action_pack][:analytics_sample_rate] = value
|
|
48
48
|
end
|
|
@@ -55,7 +55,7 @@ module Datadog
|
|
|
55
55
|
end
|
|
56
56
|
# DEV-2.0: Breaking changes for removal.
|
|
57
57
|
option :exception_controller do |o|
|
|
58
|
-
o.
|
|
58
|
+
o.after_set do |value|
|
|
59
59
|
if value
|
|
60
60
|
Datadog::Core.log_deprecation do
|
|
61
61
|
'The error controller is now automatically detected. '\
|
|
@@ -70,7 +70,7 @@ module Datadog
|
|
|
70
70
|
option :template_base_path do |o|
|
|
71
71
|
o.type :string
|
|
72
72
|
o.default 'views/'
|
|
73
|
-
o.
|
|
73
|
+
o.after_set do |value|
|
|
74
74
|
# Update ActionView template base path too
|
|
75
75
|
Datadog.configuration.tracing[:action_view][:template_base_path] = value
|
|
76
76
|
end
|
|
@@ -41,7 +41,7 @@ module Datadog
|
|
|
41
41
|
option :tasks do |o|
|
|
42
42
|
o.type :array
|
|
43
43
|
o.default []
|
|
44
|
-
o.
|
|
44
|
+
o.after_set do |value|
|
|
45
45
|
# DEV: It should be possible to modify the value after it's set. E.g. for normalization.
|
|
46
46
|
options[:tasks].instance_variable_set(:@value, value.map(&:to_s).to_set)
|
|
47
47
|
end
|
|
@@ -3,6 +3,7 @@ require_relative 'configuration/resolver'
|
|
|
3
3
|
require_relative 'ext'
|
|
4
4
|
require_relative 'quantize'
|
|
5
5
|
require_relative 'tags'
|
|
6
|
+
require_relative 'trace_middleware'
|
|
6
7
|
|
|
7
8
|
module Datadog
|
|
8
9
|
module Tracing
|
|
@@ -17,31 +18,11 @@ module Datadog
|
|
|
17
18
|
# InstanceMethods - implementing instrumentation
|
|
18
19
|
module InstanceMethods
|
|
19
20
|
def call(*args, &block)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Tracing.trace(Contrib::Redis::Ext::SPAN_COMMAND) do |span|
|
|
23
|
-
span.service = service_name
|
|
24
|
-
span.span_type = Contrib::Redis::Ext::TYPE
|
|
25
|
-
span.resource = get_command(args, show_command_args)
|
|
26
|
-
Contrib::Redis::Tags.set_common_tags(self, span, show_command_args)
|
|
27
|
-
|
|
28
|
-
super
|
|
29
|
-
end
|
|
21
|
+
TraceMiddleware.call(self, args[0], service_name, command_args?) { super }
|
|
30
22
|
end
|
|
31
23
|
|
|
32
24
|
def call_pipeline(*args, &block)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Tracing.trace(Contrib::Redis::Ext::SPAN_COMMAND) do |span|
|
|
36
|
-
span.service = service_name
|
|
37
|
-
span.span_type = Contrib::Redis::Ext::TYPE
|
|
38
|
-
commands = get_pipeline_commands(args, show_command_args)
|
|
39
|
-
span.resource = commands.any? ? commands.join("\n") : '(none)'
|
|
40
|
-
span.set_metric Contrib::Redis::Ext::METRIC_PIPELINE_LEN, commands.length
|
|
41
|
-
Contrib::Redis::Tags.set_common_tags(self, span, show_command_args)
|
|
42
|
-
|
|
43
|
-
super
|
|
44
|
-
end
|
|
25
|
+
TraceMiddleware.call_pipelined(self, args[0].commands, service_name, command_args?) { super }
|
|
45
26
|
end
|
|
46
27
|
|
|
47
28
|
private
|
|
@@ -59,22 +40,6 @@ module Datadog
|
|
|
59
40
|
datadog_configuration[:service_name]
|
|
60
41
|
end
|
|
61
42
|
|
|
62
|
-
def get_command(args, show_command_args)
|
|
63
|
-
if show_command_args
|
|
64
|
-
Contrib::Redis::Quantize.format_command_args(*args)
|
|
65
|
-
else
|
|
66
|
-
Contrib::Redis::Quantize.get_verb(*args)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def get_pipeline_commands(args, show_command_args)
|
|
71
|
-
if show_command_args
|
|
72
|
-
args[0].commands.map { |c| Contrib::Redis::Quantize.format_command_args(c) }
|
|
73
|
-
else
|
|
74
|
-
args[0].commands.map { |c| Contrib::Redis::Quantize.get_verb(c) }
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
43
|
def datadog_configuration
|
|
79
44
|
Datadog.configuration.tracing[:redis, options]
|
|
80
45
|
end
|
|
@@ -12,7 +12,7 @@ module Datadog
|
|
|
12
12
|
# Tags handles generic common tags assignment.
|
|
13
13
|
module Tags
|
|
14
14
|
class << self
|
|
15
|
-
def set_common_tags(client, span,
|
|
15
|
+
def set_common_tags(client, span, raw_command)
|
|
16
16
|
if datadog_configuration[:peer_service]
|
|
17
17
|
span.set_tag(
|
|
18
18
|
Tracing::Metadata::Ext::TAG_PEER_SERVICE,
|
|
@@ -20,6 +20,11 @@ module Datadog
|
|
|
20
20
|
)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Tag original global service name if not used
|
|
24
|
+
if span.service != Datadog.configuration.service
|
|
25
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
|
24
29
|
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_COMMAND)
|
|
25
30
|
|
|
@@ -37,7 +42,7 @@ module Datadog
|
|
|
37
42
|
|
|
38
43
|
span.set_tag Ext::TAG_DATABASE_INDEX, client.db.to_s
|
|
39
44
|
span.set_tag Ext::TAG_DB, client.db
|
|
40
|
-
span.set_tag Ext::TAG_RAW_COMMAND,
|
|
45
|
+
span.set_tag Ext::TAG_RAW_COMMAND, raw_command
|
|
41
46
|
|
|
42
47
|
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
|
43
48
|
end
|
|
@@ -9,55 +9,68 @@ module Datadog
|
|
|
9
9
|
module Redis
|
|
10
10
|
# Instrumentation for Redis 5+
|
|
11
11
|
module TraceMiddleware
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
# Instruments {RedisClient::ConnectionMixin#call}.
|
|
13
|
+
def call(command, redis_config)
|
|
14
|
+
config = resolve(redis_config)
|
|
15
|
+
TraceMiddleware.call(redis_config, command, config[:service_name], config[:command_args]) { super }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Instruments {RedisClient::ConnectionMixin#call_pipelined}.
|
|
19
|
+
def call_pipelined(commands, redis_config)
|
|
20
|
+
config = resolve(redis_config)
|
|
21
|
+
TraceMiddleware.call_pipelined(redis_config, commands, config[:service_name], config[:command_args]) { super }
|
|
22
|
+
end
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
class << self
|
|
25
|
+
def call(client, command, service_name, command_args)
|
|
26
|
+
Tracing.trace(Redis::Ext::SPAN_COMMAND, type: Redis::Ext::TYPE, service: service_name) do |span|
|
|
27
|
+
raw_command = get_command(command, true)
|
|
28
|
+
span.resource = command_args ? raw_command : get_command(command, false)
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
Contrib::Redis::Tags.set_common_tags(client, span, raw_command)
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
yield
|
|
33
|
+
end
|
|
24
34
|
end
|
|
25
|
-
end
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
def call_pipelined(client, commands, service_name, command_args)
|
|
37
|
+
Tracing.trace(Redis::Ext::SPAN_COMMAND, type: Redis::Ext::TYPE, service: service_name) do |span|
|
|
38
|
+
raw_command = get_pipeline_commands(commands, true)
|
|
39
|
+
span.resource = command_args ? raw_command : get_pipeline_commands(commands, false)
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
span.span_type = Contrib::Redis::Ext::TYPE
|
|
34
|
-
span.resource = pipelined_commands.join("\n")
|
|
35
|
-
span.set_metric Contrib::Redis::Ext::METRIC_PIPELINE_LEN, pipelined_commands.length
|
|
41
|
+
span.set_metric Contrib::Redis::Ext::METRIC_PIPELINE_LEN, commands.length
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
Contrib::Redis::Tags.set_common_tags(client, span, raw_command)
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
yield
|
|
46
|
+
end
|
|
40
47
|
end
|
|
41
|
-
end
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
private
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
# Quantizes a single Redis command
|
|
52
|
+
def get_command(command, command_args)
|
|
53
|
+
if command_args
|
|
54
|
+
Contrib::Redis::Quantize.format_command_args(command)
|
|
55
|
+
else
|
|
56
|
+
Contrib::Redis::Quantize.get_verb(command)
|
|
57
|
+
end
|
|
50
58
|
end
|
|
51
|
-
end
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
# Quantizes a multi-command Redis pipeline execution
|
|
61
|
+
def get_pipeline_commands(commands, command_args)
|
|
62
|
+
list = if command_args
|
|
63
|
+
commands.map { |c| Contrib::Redis::Quantize.format_command_args(c) }
|
|
64
|
+
else
|
|
65
|
+
commands.map { |c| Contrib::Redis::Quantize.get_verb(c) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
list.empty? ? '(none)' : list.join("\n")
|
|
58
69
|
end
|
|
59
70
|
end
|
|
60
71
|
|
|
72
|
+
private
|
|
73
|
+
|
|
61
74
|
def resolve(redis_config)
|
|
62
75
|
custom = redis_config.custom[:datadog] || {}
|
|
63
76
|
|