ddtrace 1.1.0 → 1.2.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 +59 -1
- data/CONTRIBUTING.md +1 -1
- data/README.md +7 -2
- data/ddtrace.gemspec +5 -2
- data/docs/GettingStarted.md +27 -3
- data/docs/ProfilingDevelopment.md +27 -28
- data/docs/UpgradeGuide.md +1 -1
- data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +1 -1
- data/ext/ddtrace_profiling_loader/extconf.rb +1 -0
- data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +6 -5
- data/ext/ddtrace_profiling_native_extension/clock_id.h +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +1 -1
- data/ext/ddtrace_profiling_native_extension/clock_id_noop.c +1 -1
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +269 -0
- data/ext/ddtrace_profiling_native_extension/collectors_stack.c +12 -12
- data/ext/ddtrace_profiling_native_extension/collectors_stack.h +9 -0
- data/ext/ddtrace_profiling_native_extension/extconf.rb +44 -3
- data/ext/ddtrace_profiling_native_extension/http_transport.c +341 -0
- data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +92 -4
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +76 -1
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +3 -0
- data/ext/ddtrace_profiling_native_extension/profiling.c +4 -0
- data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +33 -0
- data/ext/ddtrace_profiling_native_extension/stack_recorder.c +18 -10
- data/ext/ddtrace_profiling_native_extension/stack_recorder.h +10 -1
- data/lib/datadog/core/configuration/components.rb +39 -24
- data/lib/datadog/core/configuration/settings.rb +8 -1
- data/lib/datadog/core/environment/platform.rb +40 -0
- data/lib/datadog/core/utils.rb +1 -1
- data/lib/datadog/opentracer/thread_local_scope_manager.rb +26 -3
- data/lib/datadog/profiling/collectors/code_provenance.rb +1 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +42 -0
- data/lib/datadog/profiling/collectors/stack.rb +2 -0
- data/lib/datadog/profiling/encoding/profile.rb +7 -11
- data/lib/datadog/profiling/exporter.rb +58 -9
- data/lib/datadog/profiling/ext/forking.rb +8 -8
- data/lib/datadog/profiling/ext.rb +2 -15
- data/lib/datadog/profiling/flush.rb +25 -53
- data/lib/datadog/profiling/http_transport.rb +131 -0
- data/lib/datadog/profiling/old_ext.rb +42 -0
- data/lib/datadog/profiling/{recorder.rb → old_recorder.rb} +20 -31
- data/lib/datadog/profiling/scheduler.rb +24 -43
- data/lib/datadog/profiling/transport/http/api/endpoint.rb +9 -31
- data/lib/datadog/profiling/transport/http/client.rb +5 -3
- data/lib/datadog/profiling/transport/http/response.rb +0 -2
- data/lib/datadog/profiling/transport/http.rb +1 -1
- data/lib/datadog/profiling.rb +3 -3
- data/lib/datadog/tracing/context_provider.rb +17 -1
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +4 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +1 -1
- data/lib/datadog/tracing/contrib/grpc/datadog_interceptor.rb +4 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +35 -0
- data/lib/datadog/tracing/contrib/pg/ext.rb +31 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +129 -0
- data/lib/datadog/tracing/contrib/pg/integration.rb +43 -0
- data/lib/datadog/tracing/contrib/pg/patcher.rb +31 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +3 -0
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -1
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +1 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +1 -1
- data/lib/datadog/tracing/contrib.rb +1 -0
- data/lib/datadog/tracing/distributed/headers/b3.rb +1 -1
- data/lib/datadog/tracing/distributed/headers/b3_single.rb +4 -4
- data/lib/datadog/tracing/distributed/headers/datadog.rb +1 -1
- data/lib/datadog/tracing/distributed/headers/parser.rb +37 -0
- data/lib/datadog/tracing/distributed/helpers.rb +34 -0
- data/lib/datadog/tracing/distributed/metadata/b3.rb +55 -0
- data/lib/datadog/tracing/distributed/metadata/b3_single.rb +66 -0
- data/lib/datadog/tracing/distributed/metadata/datadog.rb +73 -0
- data/lib/datadog/tracing/distributed/metadata/parser.rb +34 -0
- data/lib/datadog/tracing/metadata/ext.rb +25 -0
- data/lib/datadog/tracing/metadata/tagging.rb +6 -0
- data/lib/datadog/tracing/propagation/grpc.rb +65 -55
- data/lib/datadog/tracing/sampling/rate_sampler.rb +2 -2
- data/lib/datadog/tracing/sampling/span/matcher.rb +80 -0
- data/lib/datadog/tracing/span.rb +21 -1
- data/lib/datadog/tracing/span_operation.rb +2 -1
- data/lib/ddtrace/version.rb +1 -1
- metadata +24 -13
- data/lib/datadog/profiling/transport/client.rb +0 -16
- data/lib/datadog/profiling/transport/io/client.rb +0 -29
- data/lib/datadog/profiling/transport/io/response.rb +0 -18
- data/lib/datadog/profiling/transport/io.rb +0 -32
- data/lib/datadog/profiling/transport/parcel.rb +0 -19
- data/lib/datadog/profiling/transport/request.rb +0 -17
- data/lib/datadog/profiling/transport/response.rb +0 -10
- data/lib/datadog/tracing/distributed/parser.rb +0 -70
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
|
|
3
|
-
require 'ddtrace/transport/io/response'
|
|
4
|
-
require 'datadog/profiling/transport/response'
|
|
5
|
-
|
|
6
|
-
module Datadog
|
|
7
|
-
module Profiling
|
|
8
|
-
module Transport
|
|
9
|
-
# IO transport behavior for profiling
|
|
10
|
-
module IO
|
|
11
|
-
# Response from IO transport for profiling
|
|
12
|
-
class Response < Datadog::Transport::IO::Response
|
|
13
|
-
include Profiling::Transport::Response
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
|
|
3
|
-
require 'datadog/profiling/transport/io/client'
|
|
4
|
-
require 'datadog/profiling/encoding/profile'
|
|
5
|
-
|
|
6
|
-
module Datadog
|
|
7
|
-
module Profiling
|
|
8
|
-
module Transport
|
|
9
|
-
# Namespace for profiling IO transport components
|
|
10
|
-
module IO
|
|
11
|
-
module_function
|
|
12
|
-
|
|
13
|
-
# Builds a new Profiling::Transport::IO::Client
|
|
14
|
-
def new(out, encoder, options = {})
|
|
15
|
-
Client.new(out, encoder, options)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Builds a new Profiling::Transport::IO::Client with default settings
|
|
19
|
-
# Pass options to override any settings.
|
|
20
|
-
def default(options = {})
|
|
21
|
-
options = options.dup
|
|
22
|
-
|
|
23
|
-
new(
|
|
24
|
-
options.delete(:out) || $stdout,
|
|
25
|
-
options.delete(:encoder) || Profiling::Encoding::Profile::Protobuf,
|
|
26
|
-
options
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
|
|
3
|
-
require 'ddtrace/transport/parcel'
|
|
4
|
-
|
|
5
|
-
module Datadog
|
|
6
|
-
module Profiling
|
|
7
|
-
module Transport
|
|
8
|
-
# Data transfer object for profiling data
|
|
9
|
-
class Parcel
|
|
10
|
-
include Datadog::Transport::Parcel
|
|
11
|
-
|
|
12
|
-
def encode_with(encoder)
|
|
13
|
-
# TODO: Determine encoding behavior
|
|
14
|
-
encoder.encode(data)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
|
|
3
|
-
require 'ddtrace/transport/request'
|
|
4
|
-
require 'datadog/profiling/transport/parcel'
|
|
5
|
-
|
|
6
|
-
module Datadog
|
|
7
|
-
module Profiling
|
|
8
|
-
module Transport
|
|
9
|
-
# Profiling request
|
|
10
|
-
class Request < Datadog::Transport::Request
|
|
11
|
-
def initialize(flush)
|
|
12
|
-
super(Parcel.new(flush))
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# typed: false
|
|
2
|
-
|
|
3
|
-
require 'datadog/tracing/span'
|
|
4
|
-
require 'datadog/tracing/distributed/helpers'
|
|
5
|
-
|
|
6
|
-
module Datadog
|
|
7
|
-
module Tracing
|
|
8
|
-
module Distributed
|
|
9
|
-
# Parser provides easy access and validation methods for Rack headers
|
|
10
|
-
class Parser
|
|
11
|
-
def initialize(env)
|
|
12
|
-
@env = env
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# TODO: Don't assume Rack format.
|
|
16
|
-
# Make distributed tracing headers apathetic.
|
|
17
|
-
def header(name)
|
|
18
|
-
rack_header = "http-#{name}".upcase!.tr('-', '_')
|
|
19
|
-
|
|
20
|
-
hdr = @env[rack_header]
|
|
21
|
-
|
|
22
|
-
# Only return the value if it is not an empty string
|
|
23
|
-
hdr if hdr != ''
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def id(hdr, base = 10)
|
|
27
|
-
value_to_id(header(hdr), base)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def value_to_id(value, base = 10)
|
|
31
|
-
id = value_to_number(value, base)
|
|
32
|
-
|
|
33
|
-
# Return early if we could not parse a number
|
|
34
|
-
return if id.nil?
|
|
35
|
-
|
|
36
|
-
# Zero or greater than max allowed value of 2**64
|
|
37
|
-
return if id.zero? || id > Span::EXTERNAL_MAX_ID
|
|
38
|
-
|
|
39
|
-
id < 0 ? id + (2**64) : id
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def number(hdr, base = 10)
|
|
43
|
-
value_to_number(header(hdr), base)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def value_to_number(value, base = 10)
|
|
47
|
-
# It's important to make a difference between no header,
|
|
48
|
-
# and a header defined to zero.
|
|
49
|
-
return if value.nil?
|
|
50
|
-
|
|
51
|
-
# Be sure we have a string
|
|
52
|
-
value = value.to_s
|
|
53
|
-
|
|
54
|
-
# If we are parsing base16 number then truncate to 64-bit
|
|
55
|
-
value = Helpers.truncate_base16_number(value) if base == 16
|
|
56
|
-
|
|
57
|
-
# Convert header to an integer
|
|
58
|
-
# DEV: Ruby `.to_i` will return `0` if a number could not be parsed
|
|
59
|
-
num = value.to_i(base)
|
|
60
|
-
|
|
61
|
-
# Ensure the parsed number is the same as the original string value
|
|
62
|
-
# e.g. We want to make sure to throw away `'nan'.to_i == 0`
|
|
63
|
-
return unless num.to_s(base) == value
|
|
64
|
-
|
|
65
|
-
num
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|