Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ekump/decouple core transport #3150

Merged
merged 22 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
406c01b
WIP: Moving transport traces to tracing
ekump Aug 30, 2023
c6d2028
move ddtrace/transport to tracing and update file references
ekump Aug 31, 2023
84ce9f3
namespace Datadog::Transport from ddtrace to DDatadog::Tracing::Trans…
ekump Sep 1, 2023
90c280d
move Core::Transport to Core::Remote::Transport
ekump Sep 7, 2023
918cfc2
move Transport::HTTP::API::Map and Fallback to core
ekump Sep 8, 2023
2cb1a15
move tracing::transport::http::env to core
ekump Sep 14, 2023
5754c16
move tracing::transport::request to core
ekump Sep 14, 2023
35fea19
move tracing::transport::http::response to core
ekump Sep 15, 2023
bdb8945
move tracing::transport::http::adapters to core
ekump Sep 15, 2023
c2cf885
move datadog::tracing::transport::http::api::endpoint and tracing::tr…
ekump Sep 15, 2023
a00f91f
move Tracing::Transport::Response to core
ekump Sep 19, 2023
667cfb3
fixing contrib tests for transport refactor
ekump Sep 19, 2023
68c0e8a
fix bad merge for faux_writer
ekump Sep 19, 2023
96a411f
fix rubocop errors
ekump Sep 20, 2023
e9d47d2
cleanup TODOs for transport refactor
ekump Sep 21, 2023
32d7c6c
creating Datadog::Core::Transport::Ext
ekump Sep 21, 2023
02b6c42
cleaning up contrib test failures
ekump Sep 21, 2023
a4c0001
export Datadog::Core::Transport::Ext to Datadog::Transport::Ext in dd…
ekump Sep 22, 2023
ffc5cb8
cleaning up rubocop errors
ekump Sep 22, 2023
4ca9b95
move rbs files to correct folders for transport refactor
ekump Sep 22, 2023
01e2fac
update namespace for decoupling transport
ekump Sep 22, 2023
caecc2c
forgot to properly namespace Datadog::Core::Transport::HTTP::Env
ekump Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ Lint/MissingSuper:
- 'lib/datadog/profiling/pprof/converter.rb'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

- 'lib/datadog/profiling/pprof/template.rb'
- 'lib/datadog/profiling/scheduler.rb'
- 'lib/ddtrace/transport/http/adapters/net.rb'
- 'lib/ddtrace/transport/http/adapters/unix_socket.rb'
- 'lib/ddtrace/transport/http/builder.rb'
- 'lib/ddtrace/transport/http/env.rb'
- 'lib/ddtrace/transport/http/traces.rb'
- 'lib/ddtrace/transport/traces.rb'
- 'spec/support/faux_transport.rb'
- 'spec/support/spy_transport.rb'

Expand Down Expand Up @@ -71,12 +65,6 @@ RSpec/LeakyConstantDeclaration:
- 'spec/datadog/tracing/benchmark/support/benchmark_helper.rb'
- 'spec/datadog/tracing/contrib/rails/rack_spec.rb'

# Offense count: 32
RSpec/MissingExampleGroupArgument:
Exclude:
- 'spec/ddtrace/transport/http/adapters/net_spec.rb'
- 'spec/ddtrace/transport/http/adapters/test_spec.rb'

# Offense count: 71
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Expand All @@ -96,7 +84,6 @@ RSpec/NamedSubject:
- 'spec/datadog/tracing/contrib/patcher_spec.rb'
- 'spec/datadog/tracing/contrib/rails/cache_spec.rb'
- 'spec/datadog/tracing/contrib/rails/database_spec.rb'
- 'spec/ddtrace/transport/traces_spec.rb'

# Offense count: 8
RSpec/RepeatedDescription:
Expand Down Expand Up @@ -391,18 +378,6 @@ Style/FrozenStringLiteralComment:
- 'lib/datadog/tracing/workers/trace_writer.rb'
- 'lib/datadog/tracing/writer.rb'
- 'lib/ddtrace/profiling/preload.rb'
- 'lib/ddtrace/transport/http/adapters/net.rb'
- 'lib/ddtrace/transport/http/adapters/test.rb'
- 'lib/ddtrace/transport/http/adapters/unix_socket.rb'
- 'lib/ddtrace/transport/http/api.rb'
- 'lib/ddtrace/transport/http/builder.rb'
- 'lib/ddtrace/transport/http/client.rb'
- 'lib/ddtrace/transport/http/statistics.rb'
- 'lib/ddtrace/transport/http/traces.rb'
- 'lib/ddtrace/transport/io/client.rb'
- 'lib/ddtrace/transport/response.rb'
- 'lib/ddtrace/transport/serializable_trace.rb'
- 'lib/ddtrace/transport/traces.rb'

Metrics/BlockNesting:
Exclude:
Expand Down
55 changes: 23 additions & 32 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ target :ddtrace do

check 'lib/'

ignore 'lib/datadog/appsec/contrib/'
ignore 'lib/datadog/ci/contrib/'
ignore 'lib/datadog/tracing/contrib/'

ignore 'lib/datadog/appsec.rb'
ignore 'lib/datadog/appsec/component.rb'
ignore 'lib/datadog/appsec/contrib/'
ignore 'lib/datadog/appsec/contrib/auto_instrument.rb'
ignore 'lib/datadog/appsec/contrib/integration.rb'
ignore 'lib/datadog/appsec/contrib/rack/gateway/request.rb'
Expand Down Expand Up @@ -38,6 +35,7 @@ target :ddtrace do
ignore 'lib/datadog/ci.rb'
ignore 'lib/datadog/ci/configuration/components.rb'
ignore 'lib/datadog/ci/configuration/settings.rb'
ignore 'lib/datadog/ci/contrib/'
ignore 'lib/datadog/ci/contrib/cucumber/configuration/settings.rb'
ignore 'lib/datadog/ci/contrib/cucumber/ext.rb'
ignore 'lib/datadog/ci/contrib/cucumber/formatter.rb'
Expand Down Expand Up @@ -115,6 +113,14 @@ target :ddtrace do
ignore 'lib/datadog/core/telemetry/v1/integration.rb'
ignore 'lib/datadog/core/telemetry/v1/product.rb'
ignore 'lib/datadog/core/telemetry/v1/telemetry_request.rb'
ignore 'lib/datadog/core/transport/ext.rb'
ignore 'lib/datadog/core/transport/http/adapters/net.rb'
ignore 'lib/datadog/core/transport/http/adapters/registry.rb'
ignore 'lib/datadog/core/transport/http/adapters/test.rb'
ignore 'lib/datadog/core/transport/http/adapters/unix_socket.rb'
ignore 'lib/datadog/core/transport/http/api/fallbacks.rb'
ignore 'lib/datadog/core/transport/http/env.rb'
ignore 'lib/datadog/core/transport/http/response.rb'
ignore 'lib/datadog/core/utils.rb'
ignore 'lib/datadog/core/utils/compression.rb'
ignore 'lib/datadog/core/utils/forking.rb'
Expand Down Expand Up @@ -201,6 +207,7 @@ target :ddtrace do
ignore 'lib/datadog/tracing/context.rb'
ignore 'lib/datadog/tracing/context_provider.rb'
ignore 'lib/datadog/tracing/contrib.rb'
ignore 'lib/datadog/tracing/contrib/'
ignore 'lib/datadog/tracing/contrib/action_cable/configuration/settings.rb'
ignore 'lib/datadog/tracing/contrib/action_cable/event.rb'
ignore 'lib/datadog/tracing/contrib/action_cable/events.rb'
Expand Down Expand Up @@ -601,41 +608,25 @@ target :ddtrace do
ignore 'lib/datadog/tracing/trace_operation.rb'
ignore 'lib/datadog/tracing/trace_segment.rb'
ignore 'lib/datadog/tracing/tracer.rb'
ignore 'lib/datadog/tracing/transport/http.rb'
ignore 'lib/datadog/tracing/transport/http/api.rb'
ignore 'lib/datadog/tracing/transport/http/builder.rb'
ignore 'lib/datadog/tracing/transport/http/client.rb'
ignore 'lib/datadog/tracing/transport/http/statistics.rb'
ignore 'lib/datadog/tracing/transport/http/traces.rb'
ignore 'lib/datadog/tracing/transport/io/client.rb'
ignore 'lib/datadog/tracing/transport/io/traces.rb'
ignore 'lib/datadog/tracing/transport/serializable_trace.rb'
ignore 'lib/datadog/tracing/transport/statistics.rb'
ignore 'lib/datadog/tracing/transport/trace_formatter.rb'
ignore 'lib/datadog/tracing/transport/traces.rb'
ignore 'lib/datadog/tracing/utils.rb'
ignore 'lib/datadog/tracing/workers.rb'
ignore 'lib/datadog/tracing/workers/trace_writer.rb'
ignore 'lib/datadog/tracing/writer.rb'
ignore 'lib/ddtrace/auto_instrument.rb'
ignore 'lib/ddtrace/auto_instrument_base.rb'
ignore 'lib/ddtrace/transport/ext.rb'
ignore 'lib/ddtrace/transport/http.rb'
ignore 'lib/ddtrace/transport/http/adapters/net.rb'
ignore 'lib/ddtrace/transport/http/adapters/registry.rb'
ignore 'lib/ddtrace/transport/http/adapters/test.rb'
ignore 'lib/ddtrace/transport/http/adapters/unix_socket.rb'
ignore 'lib/ddtrace/transport/http/api.rb'
ignore 'lib/ddtrace/transport/http/api/endpoint.rb'
ignore 'lib/ddtrace/transport/http/api/fallbacks.rb'
ignore 'lib/ddtrace/transport/http/api/instance.rb'
ignore 'lib/ddtrace/transport/http/api/map.rb'
ignore 'lib/ddtrace/transport/http/api/spec.rb'
ignore 'lib/ddtrace/transport/http/builder.rb'
ignore 'lib/ddtrace/transport/http/client.rb'
ignore 'lib/ddtrace/transport/http/env.rb'
ignore 'lib/ddtrace/transport/http/response.rb'
ignore 'lib/ddtrace/transport/http/statistics.rb'
ignore 'lib/ddtrace/transport/http/traces.rb'
ignore 'lib/ddtrace/transport/io.rb'
ignore 'lib/ddtrace/transport/io/client.rb'
ignore 'lib/ddtrace/transport/io/response.rb'
ignore 'lib/ddtrace/transport/io/traces.rb'
ignore 'lib/ddtrace/transport/parcel.rb'
ignore 'lib/ddtrace/transport/request.rb'
ignore 'lib/ddtrace/transport/response.rb'
ignore 'lib/ddtrace/transport/serializable_trace.rb'
ignore 'lib/ddtrace/transport/statistics.rb'
ignore 'lib/ddtrace/transport/trace_formatter.rb'
ignore 'lib/ddtrace/transport/traces.rb'
ignore 'lib/ddtrace/version.rb'

# References `RubyVM::YJIT`, which does not have type information.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/profiler_http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize

@transport = Datadog::Profiling::HttpTransport.new(
agent_settings: Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings.new(
adapter: Datadog::Transport::Ext::HTTP::ADAPTER,
adapter: Datadog::Core::Transport::Ext::HTTP::ADAPTER,
uds_path: nil,
ssl: false,
hostname: '127.0.0.1',
Expand Down
9 changes: 5 additions & 4 deletions lib/datadog/core/configuration/agent_settings_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require_relative 'settings'
require_relative 'ext'
require_relative '../transport/ext'

module Datadog
module Core
Expand Down Expand Up @@ -66,9 +67,9 @@ def initialize(settings, logger: Datadog.logger)

def call
# A transport_options proc configured for unix domain socket overrides most of the logic on this file
if transport_options.adapter == Datadog::Transport::Ext::UnixSocket::ADAPTER
if transport_options.adapter == Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
return AgentSettings.new(
adapter: Datadog::Transport::Ext::UnixSocket::ADAPTER,
adapter: Datadog::Core::Transport::Ext::UnixSocket::ADAPTER,
ssl: false,
hostname: nil,
port: nil,
Expand Down Expand Up @@ -96,9 +97,9 @@ def call

def adapter
if should_use_uds?
Datadog::Transport::Ext::UnixSocket::ADAPTER
Datadog::Core::Transport::Ext::UnixSocket::ADAPTER
else
Datadog::Transport::Ext::HTTP::ADAPTER
Datadog::Core::Transport::Ext::HTTP::ADAPTER
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/core/remote/client/capabilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Datadog
module Core
module Remote
class Client
# Capbailities
# Capabilities
class Capabilities
attr_reader :products, :capabilities, :receivers, :base64_capabilities

Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/core/remote/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative 'worker'
require_relative 'client/capabilities'
require_relative 'client'
require_relative '../transport/http'
require_relative 'transport/http'
require_relative '../remote'
require_relative 'negotiation'

Expand All @@ -22,7 +22,7 @@ def initialize(settings, capabilities, agent_settings)
transport_options[:agent_settings] = agent_settings if agent_settings

negotiation = Negotiation.new(settings, agent_settings)
transport_v7 = Datadog::Core::Transport::HTTP.v7(**transport_options.dup)
transport_v7 = Datadog::Core::Remote::Transport::HTTP.v7(**transport_options.dup)

@barrier = Barrier.new(BARRIER_TIMEOUT)

Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/core/remote/negotiation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative '../transport/http'
require_relative 'transport/http'

module Datadog
module Core
Expand All @@ -11,7 +11,7 @@ def initialize(_settings, agent_settings)
transport_options = {}
transport_options[:agent_settings] = agent_settings if agent_settings

@transport_root = Datadog::Core::Transport::HTTP.root(**transport_options.dup)
@transport_root = Datadog::Core::Remote::Transport::HTTP.root(**transport_options.dup)
@logged = {}
end

Expand Down
60 changes: 60 additions & 0 deletions lib/datadog/core/remote/transport/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# frozen_string_literal: true

require_relative '../../../core/transport/request'
require_relative '../../../core/transport/parcel'

module Datadog
module Core
module Remote
module Transport
module Config
# Data transfer object for encoded traces
class EncodedParcel
include Datadog::Core::Transport::Parcel

def count
data.length
end
end

# Config request
class Request < Datadog::Core::Transport::Request
end

# Config response
module Response
attr_reader :roots, :targets, :target_files, :client_configs

def empty?
@empty
end
end

# Config transport
class Transport
attr_reader :client, :apis, :default_api, :current_api_id

def initialize(apis, default_api)
@apis = apis

@client = HTTP::Client.new(current_api)
end

##### there is only one transport! it's negotiation!
def send_config(payload)
json = JSON.dump(payload)
parcel = EncodedParcel.new(json)
request = Request.new(parcel)

@client.send_config_payload(request)
end

def current_api
@apis[HTTP::API::V7]
end
end
end
end
end
end
end
Loading
Loading