Skip to content

Conversation

@p-datadog
Copy link
Member

@p-datadog p-datadog commented Nov 27, 2025

What does this PR do?

Removes duplicated code from Transport classes and deletes most of the HTTP::Client classes.

This PR continues on the path started in #5095.

Most of the HTTP::Client classes were functionally identical, except for the Tracing::Traces one which had additional logic for API version downgrades. The difference between the Client classes was in send_XXX_payload methods which were largely identical. They have been replaced by a single send_request method with the XXX as the argument. Then, all of the HTTP::Client classes have been removed except for the Tracing::Traces one which derives from the core HTTP::Client.

This PR moves also moves the downgrading methods to the core class because they will be used by DI in the next PR. Accordingly, some unit tests have been moved to core. Not all because I think there needs to be additional work to have mock APIs, since existing unit tests under Tracing::Traces utilize the APIs in Traces.

Finally, a base Transport class in core has been created with the API management code that was identical across all of the Transport classes in the various components. The per-component Transport classes remain since they still have unique methods but these now all derive from the core base class.

Motivation:
Making transport layer more legible to implement API downgrades for DI

Change log entry
None

Additional Notes:

How to test the change?

Existing tests

@github-actions github-actions bot added core Involves Datadog core libraries tracing labels Nov 27, 2025
@github-actions
Copy link

github-actions bot commented Nov 27, 2025

Thank you for updating Change log entry section 👏

Visited at: 2025-12-02 22:11:17 UTC

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

Typing analysis

Note: Ignored files are excluded from the next sections.

steep:ignore comments

This PR clears 2 steep:ignore comments.

steep:ignore comments (+0-2)Cleared:
lib/datadog/core/telemetry/transport/http/telemetry.rb:19
lib/datadog/data_streams/transport/http/client.rb:14

Untyped methods

This PR introduces 7 untyped methods and 2 partially typed methods, and clears 7 untyped methods and 2 partially typed methods.

Untyped methods (+7-7)Introduced:
sig/datadog/core/transport/transport.rbs:9
└── def initialize: (untyped version) -> void
sig/datadog/core/transport/transport.rbs:18
└── def initialize: (untyped version) -> void
sig/datadog/core/transport/transport.rbs:44
└── def initialize: (untyped apis, untyped default_api, logger: untyped) -> void
sig/datadog/core/transport/transport.rbs:46
└── def current_api: () -> untyped
sig/datadog/core/transport/transport.rbs:50
└── def set_api!: (untyped api_id) -> untyped
sig/datadog/core/transport/transport.rbs:54
└── def downgrade!: () -> untyped
sig/datadog/tracing/transport/traces.rbs:53
└── def stats: () -> untyped
Cleared:
sig/datadog/tracing/transport/traces.rbs:71
└── def initialize: (untyped apis, untyped default_api, ?logger: untyped) -> void
sig/datadog/tracing/transport/traces.rbs:75
└── def stats: () -> untyped
sig/datadog/tracing/transport/traces.rbs:77
└── def current_api: () -> untyped
sig/datadog/tracing/transport/traces.rbs:83
└── def downgrade!: () -> untyped
sig/datadog/tracing/transport/traces.rbs:85
└── def change_api!: (untyped api_id) -> untyped
sig/datadog/tracing/transport/traces.rbs:92
└── def initialize: (untyped version) -> void
sig/datadog/tracing/transport/traces.rbs:101
└── def initialize: (untyped version) -> void
Partially typed methods (+2-2)Introduced:
sig/datadog/core/transport/transport.rbs:52
└── def downgrade?: (untyped response) -> (false | untyped)
sig/datadog/tracing/transport/traces.rbs:51
└── def send_traces: (Array[Tracing::TraceOperation] traces) -> untyped
Cleared:
sig/datadog/tracing/transport/traces.rbs:73
└── def send_traces: (Array[Tracing::TraceOperation] traces) -> untyped
sig/datadog/tracing/transport/traces.rbs:81
└── def downgrade?: (untyped response) -> (false | untyped)

Untyped other declarations

This PR introduces 15 untyped other declarations, and clears 14 untyped other declarations. It decreases the percentage of typed other declarations from 69.16% to 69.11% (-0.05%).

Untyped other declarations (+15-14)Introduced:
sig/datadog/core/transport/transport.rbs:5
└── @version: untyped
sig/datadog/core/transport/transport.rbs:7
└── attr_reader version: untyped
sig/datadog/core/transport/transport.rbs:14
└── @version: untyped
sig/datadog/core/transport/transport.rbs:16
└── attr_reader version: untyped
sig/datadog/core/transport/transport.rbs:23
└── @apis: untyped
sig/datadog/core/transport/transport.rbs:25
└── @default_api: untyped
sig/datadog/core/transport/transport.rbs:27
└── @logger: untyped
sig/datadog/core/transport/transport.rbs:29
└── @current_api_id: untyped
sig/datadog/core/transport/transport.rbs:31
└── @client: untyped
sig/datadog/core/transport/transport.rbs:33
└── attr_reader client: untyped
sig/datadog/core/transport/transport.rbs:35
└── attr_reader apis: untyped
sig/datadog/core/transport/transport.rbs:37
└── attr_reader default_api: untyped
sig/datadog/core/transport/transport.rbs:39
└── attr_reader current_api_id: untyped
sig/datadog/core/transport/transport.rbs:41
└── attr_reader logger: untyped
sig/datadog/core/transport/transport.rbs:42
└── attr_accessor self.http_client_class: untyped
Cleared:
sig/datadog/tracing/transport/traces.rbs:49
└── @apis: untyped
sig/datadog/tracing/transport/traces.rbs:51
└── @default_api: untyped
sig/datadog/tracing/transport/traces.rbs:53
└── @logger: untyped
sig/datadog/tracing/transport/traces.rbs:55
└── @current_api_id: untyped
sig/datadog/tracing/transport/traces.rbs:57
└── @client: untyped
sig/datadog/tracing/transport/traces.rbs:61
└── attr_reader client: untyped
sig/datadog/tracing/transport/traces.rbs:63
└── attr_reader apis: untyped
sig/datadog/tracing/transport/traces.rbs:65
└── attr_reader default_api: untyped
sig/datadog/tracing/transport/traces.rbs:67
└── attr_reader current_api_id: untyped
sig/datadog/tracing/transport/traces.rbs:69
└── attr_reader logger: untyped
sig/datadog/tracing/transport/traces.rbs:88
└── @version: untyped
sig/datadog/tracing/transport/traces.rbs:90
└── attr_reader version: untyped
sig/datadog/tracing/transport/traces.rbs:97
└── @version: untyped
sig/datadog/tracing/transport/traces.rbs:99
└── attr_reader version: untyped

If you believe a method or an attribute is rightfully untyped or partially typed, you can add # untyped:accept to the end of the line to remove it from the stats.

@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Nov 27, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 98.25%
Total Coverage: 95.22% (+0.06%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 20fab87 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Nov 27, 2025

Benchmarks

Benchmark execution time: 2025-12-03 20:38:20

Comparing candidate commit c87e32b in PR branch dry-transport with baseline commit 48fa3f2 in branch master.

Found 2 performance improvements and 1 performance regressions! Performance is the same for 41 metrics, 2 unstable metrics.

scenario:profiling - Allocations (profiling disabled)

  • 🟩 throughput [+275753.174op/s; +282543.999op/s] or [+5.702%; +5.843%]

scenario:profiling - Allocations (profiling enabled)

  • 🟩 throughput [+269961.246op/s; +278054.255op/s] or [+5.625%; +5.794%]

scenario:profiling - intern mixed existing and new

  • 🟥 throughput [-2.850op/s; -1.722op/s] or [-9.131%; -5.517%]

@p-datadog p-datadog force-pushed the dry-transport branch 4 times, most recently from ac5f229 to 3108b35 Compare December 2, 2025 15:32
@p-datadog p-datadog changed the title Telemetry: DRY transport Transports: DRY HTTP Client classes Dec 2, 2025
@p-datadog p-datadog changed the title Transports: DRY HTTP Client classes Transports: DRY HTTP Transport & Client classes Dec 2, 2025
@p-datadog p-datadog marked this pull request as ready for review December 2, 2025 22:15
@p-datadog p-datadog requested review from a team as code owners December 2, 2025 22:15
@p-datadog p-datadog requested a review from vpellan December 2, 2025 22:16
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up! Left a few notes.

TBH I suspect in the long run it may be easier to start from scratch and rebuilding the support for the required feature-set VS slowly untangling the current mess back into a good design step by step.

But having said that, I'll take any improvement I can get.

Copy link
Contributor

@vpellan vpellan left a comment

Choose a reason for hiding this comment

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

LGTM (except send_request_impl in tests stuff)

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

While ideally there's a few more cleanups I'd like to get in, me and @p-datadog spoke about it and I think this PR as-is is already an improvement, so leaving my 👍

@p-datadog p-datadog requested a review from a team as a code owner December 9, 2025 13:41
@p-datadog
Copy link
Member Author

I will be addressing the comments in the future PRs, thank you for the feedback.

@p-datadog p-datadog merged commit a619389 into master Dec 11, 2025
553 checks passed
@p-datadog p-datadog deleted the dry-transport branch December 11, 2025 20:12
@github-actions github-actions bot added this to the 2.24.0 milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants