ddtrace 1.14.0 → 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 +178 -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 +61 -2
- 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 +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/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 +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 +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 +11 -12
- 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 +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 +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/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/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/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 +72 -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
@@ -1,144 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
require_relative '../negotiation'
|
6
|
-
require_relative 'client'
|
7
|
-
require_relative '../../../../ddtrace/transport/http/response'
|
8
|
-
require_relative '../../../../ddtrace/transport/http/api/endpoint'
|
9
|
-
|
10
|
-
# TODO: Decouple standard transport/http/api/instance
|
11
|
-
#
|
12
|
-
# Separate classes are needed because transport/http/trace includes
|
13
|
-
# Trace::API::Instance which closes over and uses a single spec, which is
|
14
|
-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
|
15
|
-
# need an independent toplevel path at the endpoint level.
|
16
|
-
#
|
17
|
-
# Separate classes are needed because of `include Trace::API::Instance`.
|
18
|
-
#
|
19
|
-
# Below should be:
|
20
|
-
# require_relative '../../../../ddtrace/transport/http/api/instance'
|
21
|
-
require_relative 'api/instance'
|
22
|
-
# Below should be:
|
23
|
-
# require_relative '../../../../ddtrace/transport/http/api/spec'
|
24
|
-
require_relative 'api/spec'
|
25
|
-
|
26
|
-
module Datadog
|
27
|
-
module Core
|
28
|
-
module Transport
|
29
|
-
module HTTP
|
30
|
-
# HTTP transport behavior for agent feature negotiation
|
31
|
-
module Negotiation
|
32
|
-
# Response from HTTP transport for agent feature negotiation
|
33
|
-
class Response
|
34
|
-
include Datadog::Transport::HTTP::Response
|
35
|
-
include Core::Transport::Negotiation::Response
|
36
|
-
|
37
|
-
def initialize(http_response, options = {})
|
38
|
-
super(http_response)
|
39
|
-
|
40
|
-
# TODO: transform endpoint hash in a better object for negotiation
|
41
|
-
# TODO: transform config in a better object, notably config has max_request_bytes
|
42
|
-
@version = options[:version]
|
43
|
-
@endpoints = options[:endpoints]
|
44
|
-
@config = options[:config]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Extensions for HTTP client
|
49
|
-
module Client
|
50
|
-
def send_info_payload(request)
|
51
|
-
send_request(request) do |api, env|
|
52
|
-
api.send_info(env)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
module API
|
58
|
-
# Extensions for HTTP API Spec
|
59
|
-
module Spec
|
60
|
-
attr_reader :info
|
61
|
-
|
62
|
-
def info=(endpoint)
|
63
|
-
@info = endpoint
|
64
|
-
end
|
65
|
-
|
66
|
-
def send_info(env, &block)
|
67
|
-
raise NoNegotiationEndpointDefinedError, self if info.nil?
|
68
|
-
|
69
|
-
info.call(env, &block)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Raised when traces sent but no traces endpoint is defined
|
73
|
-
class NoNegotiationEndpointDefinedError < StandardError
|
74
|
-
attr_reader :spec
|
75
|
-
|
76
|
-
def initialize(spec)
|
77
|
-
super()
|
78
|
-
|
79
|
-
@spec = spec
|
80
|
-
end
|
81
|
-
|
82
|
-
def message
|
83
|
-
'No info endpoint is defined for API specification!'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# Extensions for HTTP API Instance
|
89
|
-
module Instance
|
90
|
-
def send_info(env)
|
91
|
-
raise NegotiationNotSupportedError, spec unless spec.is_a?(Negotiation::API::Spec)
|
92
|
-
|
93
|
-
spec.send_info(env) do |request_env|
|
94
|
-
call(request_env)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Raised when traces sent to API that does not support traces
|
99
|
-
class NegotiationNotSupportedError < StandardError
|
100
|
-
attr_reader :spec
|
101
|
-
|
102
|
-
def initialize(spec)
|
103
|
-
super()
|
104
|
-
|
105
|
-
@spec = spec
|
106
|
-
end
|
107
|
-
|
108
|
-
def message
|
109
|
-
'Info not supported for this API!'
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# Endpoint for negotiation
|
115
|
-
class Endpoint < Datadog::Transport::HTTP::API::Endpoint
|
116
|
-
def initialize(path)
|
117
|
-
super(:get, path)
|
118
|
-
end
|
119
|
-
|
120
|
-
def call(env, &block)
|
121
|
-
# Query for response
|
122
|
-
http_response = super(env, &block)
|
123
|
-
|
124
|
-
# Process the response
|
125
|
-
body = JSON.parse(http_response.payload, symbolize_names: true) if http_response.ok?
|
126
|
-
|
127
|
-
# TODO: there should be more processing here to ensure a proper response_options
|
128
|
-
response_options = body.is_a?(Hash) ? body : {}
|
129
|
-
|
130
|
-
# Build and return a trace response
|
131
|
-
Negotiation::Response.new(http_response, response_options)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
# Add negotiation behavior to transport components
|
137
|
-
HTTP::Client.include(Negotiation::Client)
|
138
|
-
HTTP::API::Spec.include(Negotiation::API::Spec)
|
139
|
-
HTTP::API::Instance.include(Negotiation::API::Instance)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
require_relative '../environment/container'
|
6
|
-
require_relative '../environment/ext'
|
7
|
-
require_relative '../../../ddtrace/transport/ext'
|
8
|
-
require_relative '../../../ddtrace/transport/http/adapters/net'
|
9
|
-
require_relative '../../../ddtrace/transport/http/adapters/test'
|
10
|
-
require_relative '../../../ddtrace/transport/http/adapters/unix_socket'
|
11
|
-
|
12
|
-
# TODO: Improve negotiation to allow per endpoint selection
|
13
|
-
#
|
14
|
-
# Since endpoint negotiation happens at the `API::Spec` level there can not be
|
15
|
-
# a mix of enpoints at various versions or versionless without describing all
|
16
|
-
# the possible combinations as specs. See http/api.
|
17
|
-
#
|
18
|
-
# Below should be:
|
19
|
-
# require_relative '../../../ddtrace/transport/http/api'
|
20
|
-
require_relative 'http/api'
|
21
|
-
|
22
|
-
# TODO: Decouple transport/http/builder
|
23
|
-
#
|
24
|
-
# See http/builder
|
25
|
-
#
|
26
|
-
# Below should be:
|
27
|
-
# require_relative '../../../ddtrace/transport/http/builder'
|
28
|
-
require_relative 'http/builder'
|
29
|
-
|
30
|
-
# TODO: Decouple transport/http
|
31
|
-
#
|
32
|
-
# Because a new transport is required for every (API, Client, Transport)
|
33
|
-
# triplet and endpoints cannot be negotiated independently, there can not be a
|
34
|
-
# single `default` transport, but only endpoint-specific ones.
|
35
|
-
|
36
|
-
module Datadog
|
37
|
-
module Core
|
38
|
-
module Transport
|
39
|
-
# Namespace for HTTP transport components
|
40
|
-
module HTTP
|
41
|
-
# NOTE: Due to... legacy reasons... This class likes having a default `AgentSettings` instance to fall back to.
|
42
|
-
# Because we generate this instance with an empty instance of `Settings`, the resulting `AgentSettings` below
|
43
|
-
# represents only settings specified via environment variables + the usual defaults.
|
44
|
-
#
|
45
|
-
# DO NOT USE THIS IN NEW CODE, as it ignores any settings specified by users via `Datadog.configure`.
|
46
|
-
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS = Datadog::Core::Configuration::AgentSettingsResolver.call(
|
47
|
-
Datadog::Core::Configuration::Settings.new,
|
48
|
-
logger: nil,
|
49
|
-
)
|
50
|
-
|
51
|
-
module_function
|
52
|
-
|
53
|
-
# Builds a new Transport::HTTP::Client
|
54
|
-
def new(klass, &block)
|
55
|
-
Builder.new(&block).to_transport(klass)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Builds a new Transport::HTTP::Client with default settings
|
59
|
-
# Pass a block to override any settings.
|
60
|
-
def root(
|
61
|
-
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
62
|
-
**options
|
63
|
-
)
|
64
|
-
new(Transport::Negotiation::Transport) do |transport|
|
65
|
-
transport.adapter(agent_settings)
|
66
|
-
transport.headers(default_headers)
|
67
|
-
|
68
|
-
apis = API.defaults
|
69
|
-
|
70
|
-
transport.api API::ROOT, apis[API::ROOT]
|
71
|
-
|
72
|
-
# Apply any settings given by options
|
73
|
-
unless options.empty?
|
74
|
-
transport.default_api = options[:api_version] if options.key?(:api_version)
|
75
|
-
transport.headers options[:headers] if options.key?(:headers)
|
76
|
-
end
|
77
|
-
|
78
|
-
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
79
|
-
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Call block to apply any customization, if provided
|
83
|
-
yield(transport) if block_given?
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Builds a new Transport::HTTP::Client with default settings
|
88
|
-
# Pass a block to override any settings.
|
89
|
-
def v7(
|
90
|
-
agent_settings: DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS,
|
91
|
-
**options
|
92
|
-
)
|
93
|
-
new(Transport::Config::Transport) do |transport|
|
94
|
-
transport.adapter(agent_settings)
|
95
|
-
transport.headers default_headers
|
96
|
-
|
97
|
-
apis = API.defaults
|
98
|
-
|
99
|
-
transport.api API::V7, apis[API::V7]
|
100
|
-
|
101
|
-
# Apply any settings given by options
|
102
|
-
unless options.empty?
|
103
|
-
transport.default_api = options[:api_version] if options.key?(:api_version)
|
104
|
-
transport.headers options[:headers] if options.key?(:headers)
|
105
|
-
end
|
106
|
-
|
107
|
-
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
108
|
-
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Call block to apply any customization, if provided
|
112
|
-
yield(transport) if block_given?
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def default_headers
|
117
|
-
{
|
118
|
-
Datadog::Transport::Ext::HTTP::HEADER_CLIENT_COMPUTED_TOP_LEVEL => '1',
|
119
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG => Datadog::Core::Environment::Ext::LANG,
|
120
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_VERSION => Datadog::Core::Environment::Ext::LANG_VERSION,
|
121
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_INTERPRETER =>
|
122
|
-
Datadog::Core::Environment::Ext::LANG_INTERPRETER,
|
123
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION => Datadog::Core::Environment::Ext::TRACER_VERSION
|
124
|
-
}.tap do |headers|
|
125
|
-
# Add container ID, if present.
|
126
|
-
container_id = Datadog::Core::Environment::Container.container_id
|
127
|
-
headers[Datadog::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id unless container_id.nil?
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def default_adapter
|
132
|
-
Datadog::Transport::Ext::HTTP::ADAPTER
|
133
|
-
end
|
134
|
-
|
135
|
-
def default_hostname(logger: Datadog.logger)
|
136
|
-
logger.warn(
|
137
|
-
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
138
|
-
'be removed on a future ddtrace release.'
|
139
|
-
)
|
140
|
-
|
141
|
-
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.hostname
|
142
|
-
end
|
143
|
-
|
144
|
-
def default_port(logger: Datadog.logger)
|
145
|
-
logger.warn(
|
146
|
-
'Deprecated for removal: Using #default_hostname for configuration is deprecated and will ' \
|
147
|
-
'be removed on a future ddtrace release.'
|
148
|
-
)
|
149
|
-
|
150
|
-
DO_NOT_USE_ENVIRONMENT_AGENT_SETTINGS.port
|
151
|
-
end
|
152
|
-
|
153
|
-
def default_url(logger: Datadog.logger)
|
154
|
-
logger.warn(
|
155
|
-
'Deprecated for removal: Using #default_url for configuration is deprecated and will ' \
|
156
|
-
'be removed on a future ddtrace release.'
|
157
|
-
)
|
158
|
-
|
159
|
-
nil
|
160
|
-
end
|
161
|
-
|
162
|
-
# Add adapters to registry
|
163
|
-
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::Net, Datadog::Transport::Ext::HTTP::ADAPTER)
|
164
|
-
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::Test, Datadog::Transport::Ext::Test::ADAPTER)
|
165
|
-
Builder::REGISTRY.set(Datadog::Transport::HTTP::Adapters::UnixSocket, Datadog::Transport::Ext::UnixSocket::ADAPTER)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'sequence'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Core
|
7
|
-
module Utils
|
8
|
-
# Acts as a unique dictionary of objects
|
9
|
-
class ObjectSet
|
10
|
-
# You can provide a block that defines how the key
|
11
|
-
# for this message type is resolved.
|
12
|
-
def initialize(seed = 0, &block)
|
13
|
-
@sequence = Sequence.new(seed)
|
14
|
-
@items = {}
|
15
|
-
@key_block = block
|
16
|
-
end
|
17
|
-
|
18
|
-
# Submit an array of arguments that define the message.
|
19
|
-
# If they match an existing message, it will return the
|
20
|
-
# matching object. If it doesn't match, it will yield to
|
21
|
-
# the block with the next ID & args given.
|
22
|
-
def fetch(*args)
|
23
|
-
# TODO: Array hashing is **really** expensive, we probably want to get rid of it in the future
|
24
|
-
key = @key_block ? @key_block.call(*args) : args.hash
|
25
|
-
@items[key] ||= yield(@sequence.next, *args)
|
26
|
-
end
|
27
|
-
|
28
|
-
def length
|
29
|
-
@items.length
|
30
|
-
end
|
31
|
-
|
32
|
-
def objects
|
33
|
-
@items.values
|
34
|
-
end
|
35
|
-
|
36
|
-
def freeze
|
37
|
-
super
|
38
|
-
@items.freeze
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative 'sequence'
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Core
|
5
|
-
module Utils
|
6
|
-
# Tracks strings and returns IDs
|
7
|
-
class StringTable
|
8
|
-
def initialize
|
9
|
-
@sequence = Sequence.new
|
10
|
-
@ids = { ''.freeze => @sequence.next }
|
11
|
-
end
|
12
|
-
|
13
|
-
# Returns an ID for the string
|
14
|
-
def fetch(string)
|
15
|
-
@ids[string.to_s] ||= @sequence.next
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns the canonical copy of this string
|
19
|
-
# Typically used for psuedo interning; reduce
|
20
|
-
# identical copies of a string to one object.
|
21
|
-
def fetch_string(string)
|
22
|
-
return nil if string.nil?
|
23
|
-
|
24
|
-
# Co-erce to string
|
25
|
-
string = string.to_s
|
26
|
-
|
27
|
-
# Add to string table if no match
|
28
|
-
@ids[string] = @sequence.next unless @ids.key?(string)
|
29
|
-
|
30
|
-
# Get and return matching string in table
|
31
|
-
# NOTE: Have to resolve the key and retrieve from table again
|
32
|
-
# because "string" argument is not same object as string key.
|
33
|
-
id = @ids[string]
|
34
|
-
@ids.key(id)
|
35
|
-
end
|
36
|
-
|
37
|
-
def [](id)
|
38
|
-
@ids.key(id)
|
39
|
-
end
|
40
|
-
|
41
|
-
def strings
|
42
|
-
@ids.keys
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Profiling
|
5
|
-
# Entity class used to represent an entry in a stack trace.
|
6
|
-
# Its fields are a simplified struct version of `Thread::Backtrace::Location`.
|
7
|
-
class BacktraceLocation
|
8
|
-
attr_reader \
|
9
|
-
:base_label,
|
10
|
-
:lineno,
|
11
|
-
:path,
|
12
|
-
:hash
|
13
|
-
|
14
|
-
def initialize(
|
15
|
-
base_label,
|
16
|
-
lineno,
|
17
|
-
path
|
18
|
-
)
|
19
|
-
@base_label = base_label
|
20
|
-
@lineno = lineno
|
21
|
-
@path = path
|
22
|
-
@hash = [base_label, lineno, path].hash
|
23
|
-
end
|
24
|
-
|
25
|
-
def ==(other)
|
26
|
-
hash == other.hash
|
27
|
-
end
|
28
|
-
|
29
|
-
def eql?(other)
|
30
|
-
hash == other.hash
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../core/buffer/thread_safe'
|
4
|
-
require_relative '../core/utils/object_set'
|
5
|
-
require_relative '../core/utils/string_table'
|
6
|
-
|
7
|
-
module Datadog
|
8
|
-
module Profiling
|
9
|
-
# Profiling buffer that stores profiling events. The buffer has a maximum size and when
|
10
|
-
# the buffer is full, a random event is discarded. This class is thread-safe.
|
11
|
-
class Buffer < Core::Buffer::ThreadSafe
|
12
|
-
def initialize(*args)
|
13
|
-
super
|
14
|
-
@caches = {}
|
15
|
-
@string_table = Core::Utils::StringTable.new
|
16
|
-
end
|
17
|
-
|
18
|
-
def cache(cache_name)
|
19
|
-
synchronize do
|
20
|
-
@caches[cache_name] ||= Core::Utils::ObjectSet.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def string_table
|
25
|
-
synchronize do
|
26
|
-
@string_table
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
protected
|
31
|
-
|
32
|
-
def drain!
|
33
|
-
items = super
|
34
|
-
|
35
|
-
# Clear caches
|
36
|
-
@caches = {}
|
37
|
-
@string_table = Core::Utils::StringTable.new
|
38
|
-
|
39
|
-
items
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|