ddtrace 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -2
- data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +9 -2
- data/ext/ddtrace_profiling_loader/extconf.rb +17 -0
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +38 -2
- data/ext/ddtrace_profiling_native_extension/clock_id.h +1 -0
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +1 -0
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +517 -42
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +3 -0
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +208 -30
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +156 -46
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +11 -2
- data/ext/ddtrace_profiling_native_extension/extconf.rb +11 -1
- data/ext/ddtrace_profiling_native_extension/http_transport.c +83 -64
- data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +4 -4
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +3 -2
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +59 -0
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +3 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +10 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +0 -1
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +4 -2
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +45 -29
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +7 -7
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +4 -0
- data/lib/datadog/appsec/event.rb +6 -0
- data/lib/datadog/core/configuration/components.rb +20 -14
- data/lib/datadog/core/configuration/settings.rb +42 -4
- data/lib/datadog/core/diagnostics/environment_logger.rb +5 -1
- data/lib/datadog/core/utils/compression.rb +5 -1
- data/lib/datadog/core.rb +0 -54
- data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +12 -2
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +5 -3
- data/lib/datadog/profiling/exporter.rb +2 -4
- data/lib/datadog/profiling/http_transport.rb +1 -1
- data/lib/datadog/tracing/configuration/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -0
- data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +3 -0
- data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/excon/middleware.rb +2 -0
- data/lib/datadog/tracing/contrib/ext.rb +6 -0
- data/lib/datadog/tracing/contrib/faraday/middleware.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +5 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +7 -1
- data/lib/datadog/tracing/contrib/grpc/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +47 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +22 -0
- data/lib/datadog/tracing/contrib/hanami/ext.rb +24 -0
- data/lib/datadog/tracing/contrib/hanami/integration.rb +44 -0
- data/lib/datadog/tracing/contrib/hanami/patcher.rb +33 -0
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +23 -0
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +41 -0
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +44 -0
- data/lib/datadog/tracing/contrib/http/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/ext.rb +7 -0
- data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +4 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +12 -0
- data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +16 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +12 -0
- data/lib/datadog/tracing/contrib/pg/ext.rb +2 -1
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +34 -18
- data/lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb +43 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +32 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +28 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +49 -0
- data/lib/datadog/tracing/contrib/rack/middlewares.rb +11 -5
- data/lib/datadog/tracing/contrib/redis/ext.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/instrumentation.rb +4 -2
- data/lib/datadog/tracing/contrib/redis/integration.rb +2 -1
- data/lib/datadog/tracing/contrib/redis/patcher.rb +40 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +5 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/sinatra/env.rb +12 -23
- data/lib/datadog/tracing/contrib/sinatra/ext.rb +7 -3
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -2
- data/lib/datadog/tracing/contrib/sinatra/tracer.rb +8 -80
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +14 -9
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +84 -0
- data/lib/datadog/tracing/distributed/headers/datadog.rb +122 -30
- data/lib/datadog/tracing/distributed/headers/ext.rb +2 -0
- data/lib/datadog/tracing/flush.rb +1 -1
- data/lib/datadog/tracing/metadata/ext.rb +8 -0
- data/lib/datadog/tracing/propagation/http.rb +9 -1
- data/lib/datadog/tracing/sampling/ext.rb +31 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +46 -4
- data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +8 -9
- data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +29 -5
- data/lib/datadog/tracing/sampling/rate_sampler.rb +10 -3
- data/lib/datadog/tracing/sampling/rule_sampler.rb +4 -3
- data/lib/datadog/tracing/sampling/span/ext.rb +0 -4
- data/lib/datadog/tracing/sampling/span/rule.rb +1 -1
- data/lib/datadog/tracing/sampling/span/sampler.rb +14 -3
- data/lib/datadog/tracing/trace_digest.rb +3 -0
- data/lib/datadog/tracing/trace_operation.rb +10 -0
- data/lib/datadog/tracing/trace_segment.rb +6 -0
- data/lib/datadog/tracing/tracer.rb +3 -1
- data/lib/datadog/tracing/writer.rb +7 -0
- data/lib/ddtrace/transport/trace_formatter.rb +7 -0
- data/lib/ddtrace/transport/traces.rb +1 -1
- data/lib/ddtrace/version.rb +2 -2
- metadata +18 -14
- data/lib/datadog/profiling/old_ext.rb +0 -42
- data/lib/datadog/profiling/transport/http/api/endpoint.rb +0 -85
- data/lib/datadog/profiling/transport/http/api/instance.rb +0 -38
- data/lib/datadog/profiling/transport/http/api/spec.rb +0 -42
- data/lib/datadog/profiling/transport/http/api.rb +0 -45
- data/lib/datadog/profiling/transport/http/builder.rb +0 -30
- data/lib/datadog/profiling/transport/http/client.rb +0 -37
- data/lib/datadog/profiling/transport/http/response.rb +0 -21
- data/lib/datadog/profiling/transport/http.rb +0 -118
@@ -1,42 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../../../../ddtrace/transport/http/api/spec'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Profiling
|
7
|
-
module Transport
|
8
|
-
module HTTP
|
9
|
-
module API
|
10
|
-
# API specification for profiling
|
11
|
-
class Spec < Datadog::Transport::HTTP::API::Spec
|
12
|
-
attr_accessor \
|
13
|
-
:profiles
|
14
|
-
|
15
|
-
def send_profiling_flush(env, &block)
|
16
|
-
raise NoProfilesEndpointDefinedError, self if profiles.nil?
|
17
|
-
|
18
|
-
profiles.call(env, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def encoder
|
22
|
-
profiles.encoder
|
23
|
-
end
|
24
|
-
|
25
|
-
# Raised when profiles sent but no profiles endpoint is defined
|
26
|
-
class NoProfilesEndpointDefinedError < StandardError
|
27
|
-
attr_reader :spec
|
28
|
-
|
29
|
-
def initialize(spec)
|
30
|
-
@spec = spec
|
31
|
-
end
|
32
|
-
|
33
|
-
def message
|
34
|
-
'No profiles endpoint is defined for API specification!'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../../../ddtrace/transport/http/api/map'
|
4
|
-
require_relative '../../encoding/profile'
|
5
|
-
require_relative 'api/spec'
|
6
|
-
require_relative 'api/instance'
|
7
|
-
require_relative 'api/endpoint'
|
8
|
-
|
9
|
-
module Datadog
|
10
|
-
module Profiling
|
11
|
-
module Transport
|
12
|
-
module HTTP
|
13
|
-
# Extensions for HTTP API Spec
|
14
|
-
module API
|
15
|
-
# Default API versions
|
16
|
-
V1 = 'v1'.freeze
|
17
|
-
|
18
|
-
module_function
|
19
|
-
|
20
|
-
def agent_defaults
|
21
|
-
@agent_defaults ||= Datadog::Transport::HTTP::API::Map[
|
22
|
-
V1 => Spec.new do |s|
|
23
|
-
s.profiles = Endpoint.new(
|
24
|
-
'/profiling/v1/input'.freeze,
|
25
|
-
Profiling::Encoding::Profile::Protobuf
|
26
|
-
)
|
27
|
-
end
|
28
|
-
]
|
29
|
-
end
|
30
|
-
|
31
|
-
def api_defaults
|
32
|
-
@api_defaults ||= Datadog::Transport::HTTP::API::Map[
|
33
|
-
V1 => Spec.new do |s|
|
34
|
-
s.profiles = Endpoint.new(
|
35
|
-
'/v1/input'.freeze,
|
36
|
-
Profiling::Encoding::Profile::Protobuf
|
37
|
-
)
|
38
|
-
end
|
39
|
-
]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../../../ddtrace/transport/http/builder'
|
4
|
-
|
5
|
-
require_relative 'api'
|
6
|
-
require_relative 'client'
|
7
|
-
|
8
|
-
module Datadog
|
9
|
-
module Profiling
|
10
|
-
module Transport
|
11
|
-
module HTTP
|
12
|
-
# Builds new instances of Transport::HTTP::Client
|
13
|
-
class Builder < Datadog::Transport::HTTP::Builder
|
14
|
-
def api_instance_class
|
15
|
-
API::Instance
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_transport
|
19
|
-
raise Datadog::Transport::HTTP::Builder::NoDefaultApiError if @default_api.nil?
|
20
|
-
|
21
|
-
# TODO: Profiling doesn't have multiple APIs yet.
|
22
|
-
# When it does, we should build it out with these APIs.
|
23
|
-
# Just use :default_api for now.
|
24
|
-
Client.new(to_api_instances[@default_api])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../../../ddtrace/transport/http/client'
|
4
|
-
require_relative '../../../../ddtrace/transport/request'
|
5
|
-
|
6
|
-
module Datadog
|
7
|
-
module Profiling
|
8
|
-
module Transport
|
9
|
-
module HTTP
|
10
|
-
# Routes, encodes, and sends tracer data to the trace agent via HTTP.
|
11
|
-
class Client < Datadog::Transport::HTTP::Client
|
12
|
-
def export(flush)
|
13
|
-
send_profiling_flush(flush)
|
14
|
-
end
|
15
|
-
|
16
|
-
def send_profiling_flush(flush)
|
17
|
-
# Build a request
|
18
|
-
request = flush
|
19
|
-
send_payload(request).tap do |response|
|
20
|
-
if response.ok?
|
21
|
-
Datadog.logger.debug('Successfully reported profiling data')
|
22
|
-
else
|
23
|
-
Datadog.logger.debug { "Failed to report profiling data -- #{response.inspect}" }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def send_payload(request)
|
29
|
-
send_request(request) do |api, env|
|
30
|
-
api.send_profiling_flush(env)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../../../ddtrace/transport/http/response'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Profiling
|
7
|
-
module Transport
|
8
|
-
# HTTP transport behavior for profiling
|
9
|
-
module HTTP
|
10
|
-
# Response from HTTP transport for profiling
|
11
|
-
class Response
|
12
|
-
include Datadog::Transport::HTTP::Response
|
13
|
-
|
14
|
-
def initialize(http_response, options = {})
|
15
|
-
super(http_response)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
require_relative '../../core/environment/ext'
|
4
|
-
require_relative '../../../ddtrace/transport/ext'
|
5
|
-
|
6
|
-
require_relative '../../core/environment/container'
|
7
|
-
require_relative '../../core/environment/variable_helpers'
|
8
|
-
|
9
|
-
require_relative 'http/builder'
|
10
|
-
require_relative 'http/api'
|
11
|
-
|
12
|
-
require_relative '../../../ddtrace/transport/http/adapters/net'
|
13
|
-
require_relative '../../../ddtrace/transport/http/adapters/test'
|
14
|
-
require_relative '../../../ddtrace/transport/http/adapters/unix_socket'
|
15
|
-
|
16
|
-
module Datadog
|
17
|
-
module Profiling
|
18
|
-
module Transport
|
19
|
-
# Namespace for HTTP transport components
|
20
|
-
module HTTP
|
21
|
-
# Builds a new Transport::HTTP::Client
|
22
|
-
def self.new(&block)
|
23
|
-
Builder.new(&block).to_transport
|
24
|
-
end
|
25
|
-
|
26
|
-
# Builds a new Transport::HTTP::Client with default settings
|
27
|
-
def self.default(
|
28
|
-
profiling_upload_timeout_seconds:,
|
29
|
-
agent_settings:,
|
30
|
-
site: nil,
|
31
|
-
api_key: nil,
|
32
|
-
agentless_allowed: agentless_allowed?
|
33
|
-
)
|
34
|
-
new do |transport|
|
35
|
-
transport.headers default_headers
|
36
|
-
|
37
|
-
# Configure adapter & API
|
38
|
-
if site && api_key && agentless_allowed
|
39
|
-
configure_for_agentless(
|
40
|
-
transport,
|
41
|
-
profiling_upload_timeout_seconds: profiling_upload_timeout_seconds,
|
42
|
-
site: site,
|
43
|
-
api_key: api_key
|
44
|
-
)
|
45
|
-
else
|
46
|
-
configure_for_agent(
|
47
|
-
transport,
|
48
|
-
profiling_upload_timeout_seconds: profiling_upload_timeout_seconds,
|
49
|
-
agent_settings: agent_settings
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.default_headers
|
56
|
-
{
|
57
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG => Core::Environment::Ext::LANG,
|
58
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_VERSION => Core::Environment::Ext::LANG_VERSION,
|
59
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_LANG_INTERPRETER => Core::Environment::Ext::LANG_INTERPRETER,
|
60
|
-
Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION => Core::Environment::Ext::TRACER_VERSION
|
61
|
-
}.tap do |headers|
|
62
|
-
# Add container ID, if present.
|
63
|
-
container_id = Core::Environment::Container.container_id
|
64
|
-
headers[Datadog::Transport::Ext::HTTP::HEADER_CONTAINER_ID] = container_id unless container_id.nil?
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
private_class_method def self.configure_for_agent(transport, profiling_upload_timeout_seconds:, agent_settings:)
|
69
|
-
apis = API.agent_defaults
|
70
|
-
|
71
|
-
transport.adapter(agent_settings.merge(timeout_seconds: profiling_upload_timeout_seconds))
|
72
|
-
transport.api(API::V1, apis[API::V1], default: true)
|
73
|
-
|
74
|
-
# NOTE: This proc, when it exists, usually overrides the transport specified above
|
75
|
-
if agent_settings.deprecated_for_removal_transport_configuration_proc
|
76
|
-
agent_settings.deprecated_for_removal_transport_configuration_proc.call(transport)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
private_class_method def self.configure_for_agentless(transport, profiling_upload_timeout_seconds:, site:, api_key:)
|
81
|
-
apis = API.api_defaults
|
82
|
-
|
83
|
-
site_uri = URI(format(Profiling::OldExt::Transport::HTTP::URI_TEMPLATE_DD_API, site))
|
84
|
-
hostname = site_uri.host
|
85
|
-
port = site_uri.port
|
86
|
-
|
87
|
-
transport.adapter(
|
88
|
-
Datadog::Transport::Ext::HTTP::ADAPTER,
|
89
|
-
hostname,
|
90
|
-
port,
|
91
|
-
timeout: profiling_upload_timeout_seconds,
|
92
|
-
ssl: site_uri.scheme == 'https'
|
93
|
-
)
|
94
|
-
transport.api(API::V1, apis[API::V1], default: true)
|
95
|
-
transport.headers(Datadog::Transport::Ext::HTTP::HEADER_DD_API_KEY => api_key)
|
96
|
-
end
|
97
|
-
|
98
|
-
private_class_method def self.agentless_allowed?
|
99
|
-
Core::Environment::VariableHelpers.env_to_bool(Profiling::Ext::ENV_AGENTLESS, false)
|
100
|
-
end
|
101
|
-
|
102
|
-
# Add adapters to registry
|
103
|
-
Datadog::Transport::HTTP::Builder::REGISTRY.set(
|
104
|
-
Datadog::Transport::HTTP::Adapters::Net,
|
105
|
-
Datadog::Transport::Ext::HTTP::ADAPTER
|
106
|
-
)
|
107
|
-
Datadog::Transport::HTTP::Builder::REGISTRY.set(
|
108
|
-
Datadog::Transport::HTTP::Adapters::Test,
|
109
|
-
Datadog::Transport::Ext::Test::ADAPTER
|
110
|
-
)
|
111
|
-
Datadog::Transport::HTTP::Builder::REGISTRY.set(
|
112
|
-
Datadog::Transport::HTTP::Adapters::UnixSocket,
|
113
|
-
Datadog::Transport::Ext::UnixSocket::ADAPTER
|
114
|
-
)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|