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
data/lib/datadog/ci/test.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../tracing/contrib/analytics'
|
4
|
-
|
5
|
-
require_relative 'ext/app_types'
|
6
|
-
require_relative 'ext/test'
|
7
|
-
|
8
|
-
require 'rbconfig'
|
9
|
-
|
10
|
-
module Datadog
|
11
|
-
module CI
|
12
|
-
# Common behavior for CI tests
|
13
|
-
module Test
|
14
|
-
# Creates a new span for a CI test
|
15
|
-
def self.trace(span_name, options = {})
|
16
|
-
span_options = {
|
17
|
-
span_type: Ext::AppTypes::TYPE_TEST
|
18
|
-
}.merge(options[:span_options] || {})
|
19
|
-
|
20
|
-
if block_given?
|
21
|
-
Tracing.trace(span_name, **span_options) do |span, trace|
|
22
|
-
set_tags!(trace, span, options)
|
23
|
-
yield(span, trace)
|
24
|
-
end
|
25
|
-
else
|
26
|
-
span = Tracing.trace(span_name, **span_options)
|
27
|
-
trace = Tracing.active_trace
|
28
|
-
set_tags!(trace, span, options)
|
29
|
-
span
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Adds tags to a CI test span.
|
34
|
-
def self.set_tags!(trace, span, tags = {})
|
35
|
-
tags ||= {}
|
36
|
-
|
37
|
-
# Set default tags
|
38
|
-
trace.origin = Ext::Test::CONTEXT_ORIGIN if trace
|
39
|
-
Datadog::Tracing::Contrib::Analytics.set_measured(span)
|
40
|
-
span.set_tag(Ext::Test::TAG_SPAN_KIND, Ext::AppTypes::TYPE_TEST)
|
41
|
-
|
42
|
-
# Set environment tags
|
43
|
-
@environment_tags ||= Ext::Environment.tags(ENV)
|
44
|
-
@environment_tags.each { |k, v| span.set_tag(k, v) }
|
45
|
-
|
46
|
-
# Set contextual tags
|
47
|
-
span.set_tag(Ext::Test::TAG_FRAMEWORK, tags[:framework]) if tags[:framework]
|
48
|
-
span.set_tag(Ext::Test::TAG_FRAMEWORK_VERSION, tags[:framework_version]) if tags[:framework_version]
|
49
|
-
span.set_tag(Ext::Test::TAG_NAME, tags[:test_name]) if tags[:test_name]
|
50
|
-
span.set_tag(Ext::Test::TAG_SUITE, tags[:test_suite]) if tags[:test_suite]
|
51
|
-
span.set_tag(Ext::Test::TAG_TYPE, tags[:test_type]) if tags[:test_type]
|
52
|
-
|
53
|
-
set_environment_runtime_tags!(span)
|
54
|
-
|
55
|
-
span
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.passed!(span)
|
59
|
-
span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::PASS)
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.failed!(span, exception = nil)
|
63
|
-
span.status = 1
|
64
|
-
span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::FAIL)
|
65
|
-
span.set_error(exception) unless exception.nil?
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.skipped!(span, exception = nil)
|
69
|
-
span.set_tag(Ext::Test::TAG_STATUS, Ext::Test::Status::SKIP)
|
70
|
-
span.set_error(exception) unless exception.nil?
|
71
|
-
end
|
72
|
-
|
73
|
-
private_class_method def self.set_environment_runtime_tags!(span)
|
74
|
-
span.set_tag(Ext::Test::TAG_OS_ARCHITECTURE, ::RbConfig::CONFIG['host_cpu'])
|
75
|
-
span.set_tag(Ext::Test::TAG_OS_PLATFORM, ::RbConfig::CONFIG['host_os'])
|
76
|
-
span.set_tag(Ext::Test::TAG_RUNTIME_NAME, Core::Environment::Ext::LANG_ENGINE)
|
77
|
-
span.set_tag(Ext::Test::TAG_RUNTIME_VERSION, Core::Environment::Ext::ENGINE_VERSION)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/lib/datadog/ci.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'core'
|
4
|
-
require_relative 'tracing'
|
5
|
-
require_relative 'tracing/contrib'
|
6
|
-
|
7
|
-
module Datadog
|
8
|
-
# Namespace for Datadog CI instrumentation:
|
9
|
-
# e.g. rspec, cucumber, etc...
|
10
|
-
module CI
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Integrations
|
15
|
-
require_relative 'ci/contrib/cucumber/integration'
|
16
|
-
require_relative 'ci/contrib/rspec/integration'
|
17
|
-
require_relative 'ci/contrib/minitest/integration'
|
18
|
-
|
19
|
-
# Extensions
|
20
|
-
require_relative 'ci/extensions'
|
21
|
-
Datadog::CI::Extensions.activate!
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'tsort'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Core
|
7
|
-
module Configuration
|
8
|
-
# Resolver performs a topological sort over the dependency graph
|
9
|
-
class DependencyResolver
|
10
|
-
include TSort
|
11
|
-
|
12
|
-
def initialize(dependency_graph = {})
|
13
|
-
@dependency_graph = dependency_graph
|
14
|
-
end
|
15
|
-
|
16
|
-
def tsort_each_node(&blk)
|
17
|
-
@dependency_graph.each_key(&blk)
|
18
|
-
end
|
19
|
-
|
20
|
-
def tsort_each_child(node, &blk)
|
21
|
-
@dependency_graph.fetch(node).each(&blk)
|
22
|
-
end
|
23
|
-
|
24
|
-
alias call tsort
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'dependency_resolver'
|
4
|
-
|
5
|
-
module Datadog
|
6
|
-
module Core
|
7
|
-
module Configuration
|
8
|
-
# Represents a set of configuration option definitions for an integration
|
9
|
-
class OptionDefinitionSet < Hash
|
10
|
-
def dependency_order
|
11
|
-
DependencyResolver.new(dependency_graph).call
|
12
|
-
end
|
13
|
-
|
14
|
-
def dependency_graph
|
15
|
-
each_with_object({}) do |(name, option), graph|
|
16
|
-
graph[name] = option.depends_on
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../ddtrace/transport/request'
|
4
|
-
require_relative '../../../ddtrace/transport/parcel'
|
5
|
-
|
6
|
-
module Datadog
|
7
|
-
module Core
|
8
|
-
module Transport
|
9
|
-
module Config
|
10
|
-
# Data transfer object for encoded traces
|
11
|
-
class EncodedParcel
|
12
|
-
include Datadog::Transport::Parcel
|
13
|
-
|
14
|
-
def count
|
15
|
-
data.length
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Config request
|
20
|
-
class Request < Datadog::Transport::Request
|
21
|
-
end
|
22
|
-
|
23
|
-
# Config response
|
24
|
-
module Response
|
25
|
-
attr_reader :roots, :targets, :target_files, :client_configs
|
26
|
-
|
27
|
-
def empty?
|
28
|
-
@empty
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Config transport
|
33
|
-
class Transport
|
34
|
-
attr_reader :client, :apis, :default_api, :current_api_id
|
35
|
-
|
36
|
-
def initialize(apis, default_api)
|
37
|
-
@apis = apis
|
38
|
-
|
39
|
-
@client = HTTP::Client.new(current_api)
|
40
|
-
end
|
41
|
-
|
42
|
-
##### there is only one transport! it's negotiation!
|
43
|
-
def send_config(payload)
|
44
|
-
json = JSON.dump(payload)
|
45
|
-
parcel = EncodedParcel.new(json)
|
46
|
-
request = Request.new(parcel)
|
47
|
-
|
48
|
-
@client.send_config_payload(request)
|
49
|
-
end
|
50
|
-
|
51
|
-
def current_api
|
52
|
-
@apis[HTTP::API::V7]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../encoding'
|
4
|
-
|
5
|
-
require_relative '../../../../ddtrace/transport/http/api/map'
|
6
|
-
|
7
|
-
# TODO: Decouple standard transport/http/api/instance
|
8
|
-
#
|
9
|
-
# Separate classes are needed because transport/http/traces includes
|
10
|
-
# Trace::API::Instance which closes over and uses a single spec, which is
|
11
|
-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
|
12
|
-
# need an independent toplevel path at the endpoint level.
|
13
|
-
#
|
14
|
-
# Separate classes are needed because of `include Trace::API::Instance`.
|
15
|
-
#
|
16
|
-
# Below should be:
|
17
|
-
# require_relative '../../../../ddtrace/transport/http/api/spec'
|
18
|
-
require_relative 'api/spec'
|
19
|
-
|
20
|
-
# TODO: only needed for Negotiation::API::Endpoint
|
21
|
-
require_relative 'negotiation'
|
22
|
-
|
23
|
-
# TODO: only needed for Config::API::Endpoint
|
24
|
-
require_relative 'config'
|
25
|
-
|
26
|
-
module Datadog
|
27
|
-
module Core
|
28
|
-
module Transport
|
29
|
-
module HTTP
|
30
|
-
# Namespace for API components
|
31
|
-
module API
|
32
|
-
# Default API versions
|
33
|
-
ROOT = 'root'
|
34
|
-
V7 = 'v0.7'
|
35
|
-
|
36
|
-
module_function
|
37
|
-
|
38
|
-
def defaults
|
39
|
-
Datadog::Transport::HTTP::API::Map[
|
40
|
-
ROOT => Spec.new do |s|
|
41
|
-
s.info = Negotiation::API::Endpoint.new(
|
42
|
-
'/info',
|
43
|
-
)
|
44
|
-
end,
|
45
|
-
V7 => Spec.new do |s|
|
46
|
-
s.config = Config::API::Endpoint.new(
|
47
|
-
'/v0.7/config',
|
48
|
-
Core::Encoding::JSONEncoder,
|
49
|
-
)
|
50
|
-
end,
|
51
|
-
]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../../ddtrace/transport/http/env'
|
4
|
-
|
5
|
-
# TODO: Decouple transport/http/client
|
6
|
-
#
|
7
|
-
# The standard one does `include Transport::HTTP::Statistics` and performs
|
8
|
-
# stats updates, which may or may not be desirable in general.
|
9
|
-
|
10
|
-
module Datadog
|
11
|
-
module Core
|
12
|
-
module Transport
|
13
|
-
module HTTP
|
14
|
-
# Routes, encodes, and sends tracer data to the trace agent via HTTP.
|
15
|
-
class Client
|
16
|
-
attr_reader :api
|
17
|
-
|
18
|
-
def initialize(api)
|
19
|
-
@api = api
|
20
|
-
end
|
21
|
-
|
22
|
-
def send_request(request, &block)
|
23
|
-
# Build request into env
|
24
|
-
env = build_env(request)
|
25
|
-
|
26
|
-
# Get responses from API
|
27
|
-
yield(api, env)
|
28
|
-
rescue StandardError => e
|
29
|
-
message =
|
30
|
-
"Internal error during #{self.class.name} request. Cause: #{e.class.name} #{e.message} " \
|
31
|
-
"Location: #{Array(e.backtrace).first}"
|
32
|
-
|
33
|
-
Datadog.logger.debug(message)
|
34
|
-
|
35
|
-
Datadog::Transport::InternalErrorResponse.new(e)
|
36
|
-
end
|
37
|
-
|
38
|
-
def build_env(request)
|
39
|
-
Datadog::Transport::HTTP::Env.new(request)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,278 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'base64'
|
5
|
-
|
6
|
-
require_relative '../config'
|
7
|
-
require_relative 'client'
|
8
|
-
require_relative '../../../../ddtrace/transport/http/response'
|
9
|
-
require_relative '../../../../ddtrace/transport/http/api/endpoint'
|
10
|
-
|
11
|
-
# TODO: Decouple standard transport/http/api/instance
|
12
|
-
#
|
13
|
-
# Separate classes are needed because transport/http/trace includes
|
14
|
-
# Trace::API::Instance which closes over and uses a single spec, which is
|
15
|
-
# negotiated as either /v3 or /v4 for the whole API at the spec level, but we
|
16
|
-
# need an independent toplevel path at the endpoint level.
|
17
|
-
#
|
18
|
-
# Separate classes are needed because of `include Trace::API::Instance`.
|
19
|
-
#
|
20
|
-
# Below should be:
|
21
|
-
# require_relative '../../../../ddtrace/transport/http/api/instance'
|
22
|
-
require_relative 'api/instance'
|
23
|
-
# Below should be:
|
24
|
-
# require_relative '../../../../ddtrace/transport/http/api/spec'
|
25
|
-
require_relative 'api/spec'
|
26
|
-
|
27
|
-
module Datadog
|
28
|
-
module Core
|
29
|
-
module Transport
|
30
|
-
module HTTP
|
31
|
-
# HTTP transport behavior for remote configuration
|
32
|
-
module Config
|
33
|
-
# Response from HTTP transport for remote configuration
|
34
|
-
class Response
|
35
|
-
include Datadog::Transport::HTTP::Response
|
36
|
-
include Core::Transport::Config::Response
|
37
|
-
|
38
|
-
def initialize(http_response, options = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
39
|
-
super(http_response)
|
40
|
-
|
41
|
-
begin
|
42
|
-
payload = JSON.parse(http_response.payload, symbolize_names: true)
|
43
|
-
rescue JSON::ParserError => e
|
44
|
-
raise ParseError.new(:roots, e)
|
45
|
-
end
|
46
|
-
|
47
|
-
raise TypeError.new(Hash, payload) unless payload.is_a?(Hash)
|
48
|
-
|
49
|
-
@empty = true if payload.empty?
|
50
|
-
|
51
|
-
# TODO: these fallbacks should be improved
|
52
|
-
roots = payload[:roots] || []
|
53
|
-
targets = payload[:targets] || Base64.encode64('{}').chomp
|
54
|
-
target_files = payload[:target_files] || []
|
55
|
-
client_configs = payload[:client_configs] || []
|
56
|
-
|
57
|
-
raise TypeError.new(Array, roots) unless roots.is_a?(Array)
|
58
|
-
|
59
|
-
@roots = roots.map do |root|
|
60
|
-
raise TypeError.new(String, root) unless root.is_a?(String)
|
61
|
-
|
62
|
-
decoded = begin
|
63
|
-
Base64.strict_decode64(root) # TODO: unprocessed, don't symbolize_names
|
64
|
-
rescue ArgumentError
|
65
|
-
raise DecodeError.new(:roots, root)
|
66
|
-
end
|
67
|
-
|
68
|
-
parsed = begin
|
69
|
-
JSON.parse(decoded)
|
70
|
-
rescue JSON::ParserError
|
71
|
-
raise ParseError.new(:roots, decoded)
|
72
|
-
end
|
73
|
-
|
74
|
-
# TODO: perform more processing to validate content. til then, no freeze
|
75
|
-
|
76
|
-
parsed
|
77
|
-
end
|
78
|
-
|
79
|
-
raise TypeError.new(String, targets) unless targets.is_a?(String)
|
80
|
-
|
81
|
-
@targets = begin
|
82
|
-
decoded = begin
|
83
|
-
Base64.strict_decode64(targets)
|
84
|
-
rescue ArgumentError
|
85
|
-
raise DecodeError.new(:targets, targets)
|
86
|
-
end
|
87
|
-
|
88
|
-
parsed = begin
|
89
|
-
JSON.parse(decoded) # TODO: unprocessed, don't symbolize_names
|
90
|
-
rescue JSON::ParserError
|
91
|
-
raise ParseError.new(:targets, decoded)
|
92
|
-
end
|
93
|
-
|
94
|
-
# TODO: perform more processing to validate content. til then, no freeze
|
95
|
-
|
96
|
-
parsed
|
97
|
-
end
|
98
|
-
|
99
|
-
raise TypeError.new(Array, target_files) unless target_files.is_a?(Array)
|
100
|
-
|
101
|
-
@target_files = target_files.map do |h|
|
102
|
-
raise TypeError.new(Hash, h) unless h.is_a?(Hash)
|
103
|
-
raise KeyError.new(:raw) unless h.key?(:raw) # rubocop:disable Style/RaiseArgs
|
104
|
-
raise KeyError.new(:path) unless h.key?(:path) # rubocop:disable Style/RaiseArgs
|
105
|
-
|
106
|
-
raw = h[:raw]
|
107
|
-
|
108
|
-
raise TypeError.new(String, raw) unless raw.is_a?(String)
|
109
|
-
|
110
|
-
content = begin
|
111
|
-
Base64.strict_decode64(raw)
|
112
|
-
rescue ArgumentError
|
113
|
-
raise DecodeError.new(:target_files, raw)
|
114
|
-
end
|
115
|
-
|
116
|
-
{
|
117
|
-
path: h[:path].freeze,
|
118
|
-
content: StringIO.new(content.freeze),
|
119
|
-
}
|
120
|
-
end.freeze
|
121
|
-
|
122
|
-
@client_configs = client_configs.map do |s|
|
123
|
-
raise TypeError.new(String, s) unless s.is_a?(String)
|
124
|
-
|
125
|
-
s.freeze
|
126
|
-
end.freeze
|
127
|
-
end
|
128
|
-
|
129
|
-
def inspect
|
130
|
-
"#{super}, #{
|
131
|
-
{
|
132
|
-
roots: @roots,
|
133
|
-
targets: @targets,
|
134
|
-
target_files: @target_files,
|
135
|
-
client_configs: @client_configs,
|
136
|
-
}}"
|
137
|
-
end
|
138
|
-
|
139
|
-
# When an expected key is missing
|
140
|
-
class KeyError < StandardError
|
141
|
-
def initialize(key)
|
142
|
-
message = "key not found: #{key.inspect}"
|
143
|
-
|
144
|
-
super(message)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# When an expected value type is incorrect
|
149
|
-
class TypeError < StandardError
|
150
|
-
def initialize(type, value)
|
151
|
-
message = "not a #{type}: #{value.inspect}"
|
152
|
-
|
153
|
-
super(message)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# When value decoding fails
|
158
|
-
class DecodeError < StandardError
|
159
|
-
def initialize(key, value)
|
160
|
-
message = "could not decode key #{key.inspect}: #{value.inspect}"
|
161
|
-
|
162
|
-
super(message)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
# When value parsing fails
|
167
|
-
class ParseError < StandardError
|
168
|
-
def initialize(key, value)
|
169
|
-
message = "could not parse key #{key.inspect}: #{value.inspect}"
|
170
|
-
|
171
|
-
super(message)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
# Extensions for HTTP client
|
177
|
-
module Client
|
178
|
-
def send_config_payload(request)
|
179
|
-
send_request(request) do |api, env|
|
180
|
-
api.send_config(env)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
module API
|
186
|
-
# Extensions for HTTP API Spec
|
187
|
-
module Spec
|
188
|
-
attr_reader :config
|
189
|
-
|
190
|
-
def config=(endpoint)
|
191
|
-
@config = endpoint
|
192
|
-
end
|
193
|
-
|
194
|
-
def send_config(env, &block)
|
195
|
-
raise NoConfigEndpointDefinedError, self if config.nil?
|
196
|
-
|
197
|
-
config.call(env, &block)
|
198
|
-
end
|
199
|
-
|
200
|
-
# Raised when traces sent but no traces endpoint is defined
|
201
|
-
class NoConfigEndpointDefinedError < StandardError
|
202
|
-
attr_reader :spec
|
203
|
-
|
204
|
-
def initialize(spec)
|
205
|
-
super()
|
206
|
-
|
207
|
-
@spec = spec
|
208
|
-
end
|
209
|
-
|
210
|
-
def message
|
211
|
-
'No config endpoint is defined for API specification!'
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Extensions for HTTP API Instance
|
217
|
-
module Instance
|
218
|
-
def send_config(env)
|
219
|
-
raise ConfigNotSupportedError, spec unless spec.is_a?(Config::API::Spec)
|
220
|
-
|
221
|
-
spec.send_config(env) do |request_env|
|
222
|
-
call(request_env)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
# Raised when traces sent to API that does not support traces
|
227
|
-
class ConfigNotSupportedError < StandardError
|
228
|
-
attr_reader :spec
|
229
|
-
|
230
|
-
def initialize(spec)
|
231
|
-
super()
|
232
|
-
|
233
|
-
@spec = spec
|
234
|
-
end
|
235
|
-
|
236
|
-
def message
|
237
|
-
'Config not supported for this API!'
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
# Endpoint for remote configuration
|
243
|
-
class Endpoint < Datadog::Transport::HTTP::API::Endpoint
|
244
|
-
HEADER_CONTENT_TYPE = 'Content-Type'
|
245
|
-
|
246
|
-
attr_reader :encoder
|
247
|
-
|
248
|
-
def initialize(path, encoder)
|
249
|
-
super(:post, path)
|
250
|
-
@encoder = encoder
|
251
|
-
end
|
252
|
-
|
253
|
-
def call(env, &block)
|
254
|
-
# Encode body & type
|
255
|
-
env.headers[HEADER_CONTENT_TYPE] = encoder.content_type
|
256
|
-
env.body = env.request.parcel.data
|
257
|
-
|
258
|
-
# Query for response
|
259
|
-
http_response = super(env, &block)
|
260
|
-
|
261
|
-
response_options = {}
|
262
|
-
|
263
|
-
# Build and return a response
|
264
|
-
Config::Response.new(http_response, response_options)
|
265
|
-
end
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
# Add remote configuration behavior to transport components
|
270
|
-
###### overrides send_payload! which calls send_<endpoint>! kills any other possible endpoint!
|
271
|
-
HTTP::Client.include(Config::Client)
|
272
|
-
HTTP::API::Spec.include(Config::API::Spec)
|
273
|
-
HTTP::API::Instance.include(Config::API::Instance)
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|