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,118 +0,0 @@
|
|
1
|
-
require_relative 'payload'
|
2
|
-
require_relative 'message_set'
|
3
|
-
require_relative 'builder'
|
4
|
-
|
5
|
-
require_relative '../events/stack'
|
6
|
-
require_relative 'stack_sample'
|
7
|
-
|
8
|
-
module Datadog
|
9
|
-
module Profiling
|
10
|
-
module Pprof
|
11
|
-
# Converts a collection of profiling events into a Perftools::Profiles::Profile
|
12
|
-
class Template
|
13
|
-
DEFAULT_MAPPINGS = {
|
14
|
-
Events::StackSample => Pprof::StackSample
|
15
|
-
}.freeze
|
16
|
-
|
17
|
-
attr_reader \
|
18
|
-
:builder,
|
19
|
-
:converters,
|
20
|
-
:sample_type_mappings
|
21
|
-
|
22
|
-
def self.for_event_classes(event_classes)
|
23
|
-
# Build a map of event class --> converter class
|
24
|
-
mappings = event_classes.each_with_object({}) do |event_class, m|
|
25
|
-
converter_class = DEFAULT_MAPPINGS[event_class]
|
26
|
-
raise NoProfilingEventConversionError, event_class unless converter_class
|
27
|
-
|
28
|
-
m[event_class] = converter_class
|
29
|
-
end
|
30
|
-
|
31
|
-
new(mappings)
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize(mappings)
|
35
|
-
@builder = Builder.new
|
36
|
-
@converters = Hash.new { |_h, event_class| raise NoProfilingEventConversionError, event_class }
|
37
|
-
@sample_type_mappings = Hash.new { |_h, type| raise UnknownSampleTypeMappingError, type }
|
38
|
-
|
39
|
-
# Add default mapping
|
40
|
-
builder.mappings.fetch($PROGRAM_NAME, &builder.method(:build_mapping))
|
41
|
-
|
42
|
-
# Combine all sample types from each converter class
|
43
|
-
types = mappings.values.each_with_object({}) do |converter_class, t|
|
44
|
-
t.merge!(converter_class.sample_value_types)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Build the sample types into sample type objects
|
48
|
-
types.each do |type_name, type_args|
|
49
|
-
index = nil
|
50
|
-
|
51
|
-
sample_type = builder.sample_types.fetch(*type_args) do |id, type, unit|
|
52
|
-
index = id
|
53
|
-
builder.build_value_type(type, unit)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Create mapping between the type and index to which its assigned.
|
57
|
-
# Do this for faster lookup while building profile sample values.
|
58
|
-
sample_type_mappings[type_name] = index || builder.sample_types.messages.index(sample_type)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Freeze them so they can't be modified.
|
62
|
-
# We don't want the number of sample types to vary between samples within the same profile.
|
63
|
-
builder.sample_types.freeze
|
64
|
-
sample_type_mappings.freeze
|
65
|
-
|
66
|
-
# Add converters
|
67
|
-
mappings.each do |event_class, converter_class|
|
68
|
-
converters[event_class] = converter_class.new(builder, sample_type_mappings)
|
69
|
-
end
|
70
|
-
|
71
|
-
converters.freeze
|
72
|
-
end
|
73
|
-
|
74
|
-
def add_events!(event_class, events)
|
75
|
-
converters[event_class].add_events!(events)
|
76
|
-
end
|
77
|
-
|
78
|
-
def debug_statistics
|
79
|
-
converters.values.map(&:debug_statistics).join(', ')
|
80
|
-
end
|
81
|
-
|
82
|
-
def to_pprof(start:, finish:)
|
83
|
-
profile = builder.build_profile(start: start, finish: finish)
|
84
|
-
data = builder.encode_profile(profile)
|
85
|
-
types = sample_type_mappings.keys
|
86
|
-
|
87
|
-
Payload.new(data, types)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Error when an unknown event type is given to be converted
|
91
|
-
class NoProfilingEventConversionError < ArgumentError
|
92
|
-
attr_reader :type
|
93
|
-
|
94
|
-
def initialize(type)
|
95
|
-
@type = type
|
96
|
-
end
|
97
|
-
|
98
|
-
def message
|
99
|
-
"Profiling event type '#{type}' cannot be converted to pprof."
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Error when the mapping of a sample type to value index is unknown
|
104
|
-
class UnknownSampleTypeMappingError < ArgumentError
|
105
|
-
attr_reader :type
|
106
|
-
|
107
|
-
def initialize(type)
|
108
|
-
@type = type
|
109
|
-
end
|
110
|
-
|
111
|
-
def message
|
112
|
-
"Mapping for sample value type '#{type}' is unknown."
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../tracing'
|
4
|
-
require_relative '../../tracing/metadata/ext'
|
5
|
-
|
6
|
-
module Datadog
|
7
|
-
module Profiling
|
8
|
-
module TraceIdentifiers
|
9
|
-
# Used by Datadog::Profiling::TraceIdentifiers::Helper to get the trace identifiers (root span id and span id)
|
10
|
-
# for a given thread, if there is an active trace for that thread in the supplied tracer object.
|
11
|
-
class Ddtrace
|
12
|
-
def initialize(tracer:)
|
13
|
-
@tracer = (tracer if tracer.respond_to?(:active_trace))
|
14
|
-
end
|
15
|
-
|
16
|
-
def trace_identifiers_for(thread)
|
17
|
-
return unless @tracer
|
18
|
-
|
19
|
-
trace = @tracer.active_trace(thread)
|
20
|
-
return unless trace
|
21
|
-
|
22
|
-
root_span = trace.send(:root_span)
|
23
|
-
span = trace.active_span
|
24
|
-
return unless span && root_span
|
25
|
-
|
26
|
-
root_span_id = root_span.id || 0
|
27
|
-
span_id = span.id || 0
|
28
|
-
|
29
|
-
[root_span_id, span_id, maybe_extract_resource(trace, root_span)] if root_span_id != 0 && span_id != 0
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# NOTE: Currently we're only interested in HTTP service endpoints. Over time, this list may be expanded.
|
35
|
-
# Resources MUST NOT include personal identifiable information (PII); this should not be the case with
|
36
|
-
# ddtrace integrations, but worth mentioning just in case :)
|
37
|
-
def maybe_extract_resource(trace, root_span)
|
38
|
-
trace.resource if root_span.span_type == Tracing::Metadata::Ext::HTTP::TYPE_INBOUND
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'ddtrace'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Profiling
|
7
|
-
module TraceIdentifiers
|
8
|
-
# Helper used to retrieve the trace identifiers (root span id and span id) for a given thread,
|
9
|
-
# if there is an active trace for that thread for the supported tracing APIs.
|
10
|
-
#
|
11
|
-
# This data is used to connect profiles to the traces -- samples in a profile will be tagged with this data and
|
12
|
-
# the profile can be filtered down to look at only the samples for a given trace.
|
13
|
-
class Helper
|
14
|
-
DEFAULT_SUPPORTED_APIS = [
|
15
|
-
Profiling::TraceIdentifiers::Ddtrace
|
16
|
-
].freeze
|
17
|
-
private_constant :DEFAULT_SUPPORTED_APIS
|
18
|
-
|
19
|
-
def initialize(
|
20
|
-
tracer:,
|
21
|
-
# If this is disabled, the helper will strip the optional trace_resource_container even if provided by the api
|
22
|
-
endpoint_collection_enabled:,
|
23
|
-
supported_apis: DEFAULT_SUPPORTED_APIS.map { |api| api.new(tracer: tracer) }
|
24
|
-
)
|
25
|
-
@endpoint_collection_enabled = endpoint_collection_enabled
|
26
|
-
@supported_apis = supported_apis
|
27
|
-
end
|
28
|
-
|
29
|
-
# Expected output of the #trace_identifiers_for
|
30
|
-
# duck type is [root_span_id, span_id, (optional trace_resource_container)]
|
31
|
-
def trace_identifiers_for(thread)
|
32
|
-
@supported_apis.each do |api|
|
33
|
-
trace_identifiers = api.trace_identifiers_for(thread)
|
34
|
-
|
35
|
-
if trace_identifiers
|
36
|
-
return @endpoint_collection_enabled ? trace_identifiers : trace_identifiers[0..1]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,168 +0,0 @@
|
|
1
|
-
require_relative '../../response'
|
2
|
-
require_relative '../../../../datadog/core/vendor/multipart-post/net/http/post/multipart'
|
3
|
-
|
4
|
-
module Datadog
|
5
|
-
module Transport
|
6
|
-
module HTTP
|
7
|
-
module Adapters
|
8
|
-
# Adapter for Net::HTTP
|
9
|
-
class Net
|
10
|
-
attr_reader \
|
11
|
-
:hostname,
|
12
|
-
:port,
|
13
|
-
:timeout,
|
14
|
-
:ssl
|
15
|
-
|
16
|
-
# in seconds
|
17
|
-
DEFAULT_TIMEOUT = 30
|
18
|
-
|
19
|
-
# @deprecated Positional parameters are deprecated. Use named parameters instead.
|
20
|
-
def initialize(hostname = nil, port = nil, **options)
|
21
|
-
@hostname = hostname || options.fetch(:hostname)
|
22
|
-
@port = port || options.fetch(:port)
|
23
|
-
@timeout = options[:timeout] || DEFAULT_TIMEOUT
|
24
|
-
@ssl = options.key?(:ssl) ? options[:ssl] == true : false
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.build(agent_settings)
|
28
|
-
new(
|
29
|
-
hostname: agent_settings.hostname,
|
30
|
-
port: agent_settings.port,
|
31
|
-
timeout: agent_settings.timeout_seconds,
|
32
|
-
ssl: agent_settings.ssl
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
def open(&block)
|
37
|
-
# DEV Initializing +Net::HTTP+ directly help us avoid expensive
|
38
|
-
# options processing done in +Net::HTTP.start+:
|
39
|
-
# https://github.com/ruby/ruby/blob/b2d96abb42abbe2e01f010ffc9ac51f0f9a50002/lib/net/http.rb#L614-L618
|
40
|
-
req = ::Net::HTTP.new(hostname, port, nil)
|
41
|
-
|
42
|
-
req.use_ssl = ssl
|
43
|
-
req.open_timeout = req.read_timeout = timeout
|
44
|
-
|
45
|
-
req.start(&block)
|
46
|
-
end
|
47
|
-
|
48
|
-
def call(env)
|
49
|
-
if respond_to?(env.verb)
|
50
|
-
send(env.verb, env)
|
51
|
-
else
|
52
|
-
raise UnknownHTTPMethod, env
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def get(env)
|
57
|
-
get = ::Net::HTTP::Get.new(env.path, env.headers)
|
58
|
-
|
59
|
-
# Connect and send the request
|
60
|
-
http_response = open do |http|
|
61
|
-
http.request(get)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Build and return response
|
65
|
-
Response.new(http_response)
|
66
|
-
end
|
67
|
-
|
68
|
-
def post(env)
|
69
|
-
post = nil
|
70
|
-
|
71
|
-
if env.form.nil? || env.form.empty?
|
72
|
-
post = ::Net::HTTP::Post.new(env.path, env.headers)
|
73
|
-
post.body = env.body
|
74
|
-
else
|
75
|
-
post = ::Datadog::Core::Vendor::Net::HTTP::Post::Multipart.new(
|
76
|
-
env.path,
|
77
|
-
env.form,
|
78
|
-
env.headers
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Connect and send the request
|
83
|
-
http_response = open do |http|
|
84
|
-
http.request(post)
|
85
|
-
end
|
86
|
-
|
87
|
-
# Build and return response
|
88
|
-
Response.new(http_response)
|
89
|
-
end
|
90
|
-
|
91
|
-
def url
|
92
|
-
"http://#{hostname}:#{port}?timeout=#{timeout}"
|
93
|
-
end
|
94
|
-
|
95
|
-
# Raised when called with an unknown HTTP method
|
96
|
-
class UnknownHTTPMethod < StandardError
|
97
|
-
attr_reader :verb
|
98
|
-
|
99
|
-
def initialize(verb)
|
100
|
-
@verb = verb
|
101
|
-
end
|
102
|
-
|
103
|
-
def message
|
104
|
-
"No matching Net::HTTP function for '#{verb}'!"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# A wrapped Net::HTTP response that implements the Transport::Response interface
|
109
|
-
class Response
|
110
|
-
include Datadog::Transport::Response
|
111
|
-
|
112
|
-
attr_reader :http_response
|
113
|
-
|
114
|
-
def initialize(http_response)
|
115
|
-
@http_response = http_response
|
116
|
-
end
|
117
|
-
|
118
|
-
def payload
|
119
|
-
return super if http_response.nil?
|
120
|
-
|
121
|
-
http_response.body
|
122
|
-
end
|
123
|
-
|
124
|
-
def code
|
125
|
-
return super if http_response.nil?
|
126
|
-
|
127
|
-
http_response.code.to_i
|
128
|
-
end
|
129
|
-
|
130
|
-
def ok?
|
131
|
-
return super if http_response.nil?
|
132
|
-
|
133
|
-
code.between?(200, 299)
|
134
|
-
end
|
135
|
-
|
136
|
-
def unsupported?
|
137
|
-
return super if http_response.nil?
|
138
|
-
|
139
|
-
code == 415
|
140
|
-
end
|
141
|
-
|
142
|
-
def not_found?
|
143
|
-
return super if http_response.nil?
|
144
|
-
|
145
|
-
code == 404
|
146
|
-
end
|
147
|
-
|
148
|
-
def client_error?
|
149
|
-
return super if http_response.nil?
|
150
|
-
|
151
|
-
code.between?(400, 499)
|
152
|
-
end
|
153
|
-
|
154
|
-
def server_error?
|
155
|
-
return super if http_response.nil?
|
156
|
-
|
157
|
-
code.between?(500, 599)
|
158
|
-
end
|
159
|
-
|
160
|
-
def inspect
|
161
|
-
"#{super}, http_response:#{http_response}"
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Transport
|
5
|
-
module HTTP
|
6
|
-
module Adapters
|
7
|
-
# List of available adapters
|
8
|
-
class Registry
|
9
|
-
def initialize
|
10
|
-
@adapters = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(name)
|
14
|
-
@adapters[name]
|
15
|
-
end
|
16
|
-
|
17
|
-
def set(klass, name = nil)
|
18
|
-
name ||= klass.to_s
|
19
|
-
return if name.nil?
|
20
|
-
|
21
|
-
@adapters[name] = klass
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require_relative '../../response'
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Transport
|
5
|
-
module HTTP
|
6
|
-
module Adapters
|
7
|
-
# Adapter for testing
|
8
|
-
class Test
|
9
|
-
attr_reader \
|
10
|
-
:buffer,
|
11
|
-
:status
|
12
|
-
|
13
|
-
# @param buffer [Array] an optional array that will capture all spans sent to this adapter, defaults to +nil+
|
14
|
-
# @deprecated Positional parameters are deprecated. Use named parameters instead.
|
15
|
-
def initialize(buffer = nil, **options)
|
16
|
-
@buffer = buffer || options[:buffer]
|
17
|
-
@mutex = Mutex.new
|
18
|
-
@status = 200
|
19
|
-
end
|
20
|
-
|
21
|
-
def call(env)
|
22
|
-
add_request(env)
|
23
|
-
Response.new(status)
|
24
|
-
end
|
25
|
-
|
26
|
-
def buffer?
|
27
|
-
!@buffer.nil?
|
28
|
-
end
|
29
|
-
|
30
|
-
def add_request(env)
|
31
|
-
@mutex.synchronize { buffer << env } if buffer?
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_status!(status)
|
35
|
-
@status = status
|
36
|
-
end
|
37
|
-
|
38
|
-
def url; end
|
39
|
-
|
40
|
-
# Response for test adapter
|
41
|
-
class Response
|
42
|
-
include Datadog::Transport::Response
|
43
|
-
|
44
|
-
attr_reader \
|
45
|
-
:body,
|
46
|
-
:code
|
47
|
-
|
48
|
-
def initialize(code, body = nil)
|
49
|
-
@code = code
|
50
|
-
@body = body
|
51
|
-
end
|
52
|
-
|
53
|
-
def payload
|
54
|
-
@body
|
55
|
-
end
|
56
|
-
|
57
|
-
def ok?
|
58
|
-
code.between?(200, 299)
|
59
|
-
end
|
60
|
-
|
61
|
-
def unsupported?
|
62
|
-
code == 415
|
63
|
-
end
|
64
|
-
|
65
|
-
def not_found?
|
66
|
-
code == 404
|
67
|
-
end
|
68
|
-
|
69
|
-
def client_error?
|
70
|
-
code.between?(400, 499)
|
71
|
-
end
|
72
|
-
|
73
|
-
def server_error?
|
74
|
-
code.between?(500, 599)
|
75
|
-
end
|
76
|
-
|
77
|
-
def inspect
|
78
|
-
"#{super}, code:#{code}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
require_relative '../../ext'
|
3
|
-
require_relative 'net'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Transport
|
7
|
-
module HTTP
|
8
|
-
module Adapters
|
9
|
-
# Adapter for Unix sockets
|
10
|
-
class UnixSocket < Adapters::Net
|
11
|
-
attr_reader \
|
12
|
-
:filepath, # DEV(1.0): Rename to `uds_path`
|
13
|
-
:timeout
|
14
|
-
|
15
|
-
alias_method :uds_path, :filepath
|
16
|
-
|
17
|
-
# @deprecated Positional parameters are deprecated. Use named parameters instead.
|
18
|
-
def initialize(uds_path = nil, **options)
|
19
|
-
@filepath = uds_path || options.fetch(:uds_path)
|
20
|
-
@timeout = options[:timeout] || Transport::Ext::UnixSocket::DEFAULT_TIMEOUT_SECONDS
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.build(agent_settings)
|
24
|
-
new(
|
25
|
-
uds_path: agent_settings.uds_path,
|
26
|
-
timeout: agent_settings.timeout_seconds,
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
def open(&block)
|
31
|
-
# Open connection
|
32
|
-
connection = HTTP.new(
|
33
|
-
uds_path,
|
34
|
-
read_timeout: timeout,
|
35
|
-
continue_timeout: timeout
|
36
|
-
)
|
37
|
-
|
38
|
-
connection.start(&block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def url
|
42
|
-
"http+unix://#{uds_path}?timeout=#{timeout}"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Re-implements Net:HTTP with underlying Unix socket
|
46
|
-
class HTTP < ::Net::HTTP
|
47
|
-
DEFAULT_TIMEOUT = 1
|
48
|
-
|
49
|
-
attr_reader \
|
50
|
-
:filepath, # DEV(1.0): Rename to `uds_path`
|
51
|
-
:unix_socket
|
52
|
-
|
53
|
-
alias_method :uds_path, :filepath
|
54
|
-
|
55
|
-
def initialize(uds_path, options = {})
|
56
|
-
super('localhost', 80)
|
57
|
-
@filepath = uds_path
|
58
|
-
@read_timeout = options.fetch(:read_timeout, DEFAULT_TIMEOUT)
|
59
|
-
@continue_timeout = options.fetch(:continue_timeout, DEFAULT_TIMEOUT)
|
60
|
-
@debug_output = options[:debug_output] if options.key?(:debug_output)
|
61
|
-
end
|
62
|
-
|
63
|
-
def connect
|
64
|
-
@unix_socket = UNIXSocket.open(uds_path)
|
65
|
-
@socket = ::Net::BufferedIO.new(@unix_socket).tap do |socket|
|
66
|
-
socket.read_timeout = @read_timeout
|
67
|
-
socket.continue_timeout = @continue_timeout
|
68
|
-
socket.debug_output = @debug_output
|
69
|
-
end
|
70
|
-
on_connect
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Transport
|
7
|
-
module HTTP
|
8
|
-
module API
|
9
|
-
# Endpoint
|
10
|
-
class Endpoint
|
11
|
-
attr_reader \
|
12
|
-
:verb,
|
13
|
-
:path
|
14
|
-
|
15
|
-
def initialize(verb, path)
|
16
|
-
@verb = verb
|
17
|
-
@path = path
|
18
|
-
end
|
19
|
-
|
20
|
-
def call(env)
|
21
|
-
env.verb = verb
|
22
|
-
env.path = path
|
23
|
-
yield(env)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Transport
|
5
|
-
module HTTP
|
6
|
-
module API
|
7
|
-
# Extension for Map with adds fallback versions.
|
8
|
-
module Fallbacks
|
9
|
-
def fallbacks
|
10
|
-
@fallbacks ||= {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def with_fallbacks(fallbacks)
|
14
|
-
tap { add_fallbacks!(fallbacks) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_fallbacks!(fallbacks)
|
18
|
-
self.fallbacks.merge!(fallbacks)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Transport
|
5
|
-
module HTTP
|
6
|
-
module API
|
7
|
-
# An API configured with adapter and routes
|
8
|
-
class Instance
|
9
|
-
attr_reader \
|
10
|
-
:adapter,
|
11
|
-
:headers,
|
12
|
-
:spec
|
13
|
-
|
14
|
-
def initialize(spec, adapter, options = {})
|
15
|
-
@spec = spec
|
16
|
-
@adapter = adapter
|
17
|
-
@headers = options.fetch(:headers, {})
|
18
|
-
end
|
19
|
-
|
20
|
-
def encoder
|
21
|
-
spec.encoder
|
22
|
-
end
|
23
|
-
|
24
|
-
def call(env)
|
25
|
-
# Add headers to request env, unless empty.
|
26
|
-
env.headers.merge!(headers) unless headers.empty?
|
27
|
-
|
28
|
-
# Send request env to the adapter.
|
29
|
-
adapter.call(env)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'fallbacks'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Transport
|
7
|
-
module HTTP
|
8
|
-
module API
|
9
|
-
# A mapping of API version => API Routes/Instance
|
10
|
-
class Map < Hash
|
11
|
-
include Fallbacks
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Datadog
|
4
|
-
module Transport
|
5
|
-
module HTTP
|
6
|
-
module API
|
7
|
-
# Specification for an HTTP API
|
8
|
-
# Defines behaviors without specific configuration details.
|
9
|
-
class Spec
|
10
|
-
def initialize
|
11
|
-
yield(self) if block_given?
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|