ddtrace 1.13.1 → 1.15.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 +207 -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 -1
- 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 +68 -3
- 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 +2 -5
- data/lib/datadog/appsec/contrib/rack/request_body_middleware.rb +3 -2
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +23 -9
- 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 +9 -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/diagnostics/environment_logger.rb +130 -234
- data/lib/datadog/core/environment/execution.rb +50 -2
- 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/telemetry/collector.rb +13 -4
- 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 +12 -18
- 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 +34 -99
- data/lib/datadog/profiling/diagnostics/environment_logger.rb +39 -0
- data/lib/datadog/profiling/exporter.rb +4 -4
- data/lib/datadog/profiling/ext.rb +0 -12
- data/lib/datadog/profiling/flush.rb +2 -7
- data/lib/datadog/profiling/http_transport.rb +6 -3
- data/lib/datadog/profiling/native_extension.rb +0 -21
- data/lib/datadog/profiling/profiler.rb +11 -12
- data/lib/datadog/profiling.rb +9 -81
- data/lib/datadog/tracing/component.rb +12 -5
- 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/configuration/resolver.rb +18 -11
- data/lib/datadog/tracing/contrib/active_record/events/sql.rb +4 -0
- data/lib/datadog/tracing/contrib/active_record/utils.rb +1 -1
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +104 -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/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 +104 -102
- 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/lograge/instrumentation.rb +1 -17
- 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/tags.rb +5 -0
- 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/semantic_logger/instrumentation.rb +3 -20
- 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 +11 -11
- data/lib/datadog/tracing/correlation.rb +20 -0
- data/lib/datadog/tracing/diagnostics/environment_logger.rb +159 -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 +6 -4
- 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 +2 -2
- data/lib/ddtrace.rb +1 -1
- metadata +74 -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
@@ -24,123 +24,125 @@ module Datadog
|
|
24
24
|
require 'json'
|
25
25
|
require_relative 'quantize'
|
26
26
|
|
27
|
-
|
27
|
+
transport_module::Client.prepend(Client)
|
28
28
|
end
|
29
29
|
|
30
30
|
SELF_DEPRECATION_ONLY_ONCE = Core::Utils::OnlyOnce.new
|
31
31
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
32
|
+
# Patches Elasticsearch::Transport::Client module
|
33
|
+
module Client
|
34
|
+
# rubocop:disable Metrics/MethodLength
|
35
|
+
# rubocop:disable Metrics/AbcSize
|
36
|
+
def perform_request(*args)
|
37
|
+
# DEV-2.0: Remove this access, as `Client#self` in this context is not exposed to the user
|
38
|
+
# since `elasticsearch` v8.0.0. In contrast, `Client#transport` is always available across
|
39
|
+
# all `elasticsearch` gem versions and should be used instead.
|
40
|
+
service = Datadog.configuration_for(self, :service_name)
|
41
|
+
|
42
|
+
if service
|
43
|
+
SELF_DEPRECATION_ONLY_ONCE.run do
|
44
|
+
Datadog.logger.warn(
|
45
|
+
'Providing configuration though the Elasticsearch client object is deprecated.' \
|
46
|
+
'Configure the `client#transport` object instead: ' \
|
47
|
+
'Datadog.configure_onto(client.transport, service_name: service_name, ...)'
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# `Client#transport` is most convenient object both this integration and the library
|
53
|
+
# user have shared access to across all `elasticsearch` versions.
|
54
|
+
#
|
55
|
+
# `Client#self` in this context is an internal object that the library user
|
56
|
+
# does not have access to since `elasticsearch` v8.0.0.
|
57
|
+
service ||= Datadog.configuration_for(transport, :service_name) || datadog_configuration[:service_name]
|
58
|
+
|
59
|
+
method = args[0]
|
60
|
+
path = args[1]
|
61
|
+
params = args[2]
|
62
|
+
body = args[3]
|
63
|
+
full_url = URI.parse(path)
|
64
|
+
url = full_url.path
|
65
|
+
response = nil
|
66
|
+
|
67
|
+
Tracing.trace(Datadog::Tracing::Contrib::Elasticsearch::Ext::SPAN_QUERY, service: service) do |span|
|
68
|
+
begin
|
69
|
+
connection = transport.connections.first
|
70
|
+
host = connection.host[:host] if connection
|
71
|
+
port = connection.host[:port] if connection
|
72
|
+
|
73
|
+
if datadog_configuration[:peer_service]
|
74
|
+
span.set_tag(
|
75
|
+
Tracing::Metadata::Ext::TAG_PEER_SERVICE,
|
76
|
+
datadog_configuration[:peer_service]
|
54
77
|
)
|
55
78
|
end
|
56
|
-
end
|
57
79
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
connection = transport.connections.first
|
77
|
-
host = connection.host[:host] if connection
|
78
|
-
port = connection.host[:port] if connection
|
79
|
-
|
80
|
-
if datadog_configuration[:peer_service]
|
81
|
-
span.set_tag(
|
82
|
-
Tracing::Metadata::Ext::TAG_PEER_SERVICE,
|
83
|
-
datadog_configuration[:peer_service]
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
span.span_type = Datadog::Tracing::Contrib::Elasticsearch::Ext::SPAN_TYPE_QUERY
|
88
|
-
|
89
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
90
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_QUERY)
|
91
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
92
|
-
|
93
|
-
span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM)
|
94
|
-
|
95
|
-
# load JSON for the following fields unless they're already strings
|
96
|
-
params = JSON.generate(params) if params && !params.is_a?(String)
|
97
|
-
body = JSON.generate(body) if body && !body.is_a?(String)
|
98
|
-
|
99
|
-
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host) if host
|
100
|
-
|
101
|
-
# Set analytics sample rate
|
102
|
-
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
|
103
|
-
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
|
104
|
-
end
|
105
|
-
|
106
|
-
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_METHOD, method)
|
107
|
-
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_URL, url)
|
108
|
-
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_PARAMS, params) if params
|
109
|
-
if body
|
110
|
-
quantize_options = datadog_configuration[:quantize]
|
111
|
-
quantized_body = Datadog::Tracing::Contrib::Elasticsearch::Quantize.format_body(
|
112
|
-
body,
|
113
|
-
quantize_options
|
114
|
-
)
|
115
|
-
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_BODY, quantized_body)
|
116
|
-
end
|
117
|
-
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, host) if host
|
118
|
-
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, port) if port
|
119
|
-
|
120
|
-
quantized_url = Datadog::Tracing::Contrib::Elasticsearch::Quantize.format_url(url)
|
121
|
-
span.resource = "#{method} #{quantized_url}"
|
122
|
-
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
123
|
-
rescue StandardError => e
|
124
|
-
Datadog.logger.error(e.message)
|
125
|
-
ensure
|
126
|
-
# the call is still executed
|
127
|
-
response = perform_request_without_datadog(*args)
|
128
|
-
span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, response.status)
|
80
|
+
# Tag original global service name if not used
|
81
|
+
if span.service != Datadog.configuration.service
|
82
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
83
|
+
end
|
84
|
+
|
85
|
+
span.span_type = Datadog::Tracing::Contrib::Elasticsearch::Ext::SPAN_TYPE_QUERY
|
86
|
+
|
87
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
|
88
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_QUERY)
|
89
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
90
|
+
|
91
|
+
span.set_tag(Contrib::Ext::DB::TAG_SYSTEM, Ext::TAG_SYSTEM)
|
92
|
+
|
93
|
+
span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host) if host
|
94
|
+
|
95
|
+
# Set analytics sample rate
|
96
|
+
if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
|
97
|
+
Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
|
129
98
|
end
|
99
|
+
|
100
|
+
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_METHOD, method)
|
101
|
+
tag_params(params, span)
|
102
|
+
tag_body(body, span)
|
103
|
+
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_URL, url)
|
104
|
+
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, host) if host
|
105
|
+
span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, port) if port
|
106
|
+
|
107
|
+
quantized_url = Datadog::Tracing::Contrib::Elasticsearch::Quantize.format_url(url)
|
108
|
+
span.resource = "#{method} #{quantized_url}"
|
109
|
+
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
|
110
|
+
rescue StandardError => e
|
111
|
+
Datadog.logger.error(e.message)
|
112
|
+
ensure
|
113
|
+
# the call is still executed
|
114
|
+
response = super
|
115
|
+
span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, response.status)
|
130
116
|
end
|
131
|
-
response
|
132
117
|
end
|
118
|
+
response
|
119
|
+
end
|
133
120
|
|
134
|
-
|
135
|
-
|
136
|
-
|
121
|
+
def tag_params(params, span)
|
122
|
+
return unless params
|
123
|
+
|
124
|
+
params = JSON.generate(params) unless params.is_a?(String)
|
125
|
+
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_PARAMS, params)
|
126
|
+
end
|
127
|
+
|
128
|
+
def tag_body(body, span)
|
129
|
+
return unless body
|
130
|
+
|
131
|
+
body = JSON.generate(body) unless body.is_a?(String)
|
132
|
+
quantize_options = datadog_configuration[:quantize]
|
133
|
+
quantized_body = Datadog::Tracing::Contrib::Elasticsearch::Quantize.format_body(
|
134
|
+
body,
|
135
|
+
quantize_options
|
136
|
+
)
|
137
|
+
span.set_tag(Datadog::Tracing::Contrib::Elasticsearch::Ext::TAG_BODY, quantized_body)
|
138
|
+
end
|
139
|
+
|
140
|
+
def datadog_configuration
|
141
|
+
Datadog.configuration.tracing[:elasticsearch]
|
137
142
|
end
|
138
|
-
# rubocop:enable Metrics/BlockLength
|
139
143
|
end
|
140
144
|
# rubocop:enable Metrics/MethodLength
|
141
145
|
# rubocop:enable Metrics/AbcSize
|
142
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
143
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
144
146
|
|
145
147
|
# `Elasticsearch` namespace renamed to `Elastic` in version 8.0.0 of the transport gem:
|
146
148
|
# @see https://github.com/elastic/elastic-transport-ruby/commit/ef804cbbd284f2a82d825221f87124f8b5ff823c
|
@@ -136,6 +136,11 @@ module Datadog
|
|
136
136
|
)
|
137
137
|
end
|
138
138
|
|
139
|
+
# Tag original global service name if not used
|
140
|
+
if span.service != Datadog.configuration.service
|
141
|
+
span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE, Datadog.configuration.service)
|
142
|
+
end
|
143
|
+
|
139
144
|
# Set analytics sample rate
|
140
145
|
Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?
|
141
146
|
|
@@ -69,6 +69,14 @@ module Datadog
|
|
69
69
|
|
70
70
|
@datadog_multi_span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
|
71
71
|
|
72
|
+
# Tag original global service name if not used
|
73
|
+
if @datadog_multi_span.service != Datadog.configuration.service
|
74
|
+
@datadog_multi_span.set_tag(
|
75
|
+
Tracing::Contrib::Ext::Metadata::TAG_BASE_SERVICE,
|
76
|
+
Datadog.configuration.service
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
72
80
|
# Set analytics sample rate
|
73
81
|
Contrib::Analytics.set_sample_rate(@datadog_multi_span, analytics_sample_rate) if analytics_enabled?
|
74
82
|
|
@@ -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
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../../core/logging/ext'
|
4
|
-
|
5
3
|
module Datadog
|
6
4
|
module Tracing
|
7
5
|
module Contrib
|
@@ -23,21 +21,7 @@ module Datadog
|
|
23
21
|
# Retrieves trace information for current thread
|
24
22
|
correlation = Tracing.correlation
|
25
23
|
# merge original lambda with datadog context
|
26
|
-
|
27
|
-
datadog_trace_log_hash = {
|
28
|
-
# Adds IDs as tags to log output
|
29
|
-
dd: {
|
30
|
-
# To preserve precision during JSON serialization, use strings for large numbers
|
31
|
-
trace_id: correlation.trace_id.to_s,
|
32
|
-
span_id: correlation.span_id.to_s,
|
33
|
-
env: correlation.env.to_s,
|
34
|
-
service: correlation.service.to_s,
|
35
|
-
version: correlation.version.to_s
|
36
|
-
},
|
37
|
-
ddsource: Core::Logging::Ext::DD_SOURCE
|
38
|
-
}
|
39
|
-
|
40
|
-
datadog_trace_log_hash.merge(original_custom_options)
|
24
|
+
correlation.to_h.merge(original_custom_options)
|
41
25
|
end
|
42
26
|
end
|
43
27
|
end
|
@@ -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
|