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

refactor: ddcommon-net+profiling with hyper 1 #748

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

morrisonlevi
Copy link
Contributor

What does this PR do?

  1. There is a new crate ddcommon-net, naming suggestions welcome. It has bits of ddcommon networking code which have been upgraded to hyper 1. Note it's not a direct 1:1 because hyper 1 changed a lot.
  2. The datadog-profiling crate has been updated to use it. Currently its tests pass for me locally. The datadog-profiling-ffi is currently broken.
  3. Other crates are not touched

Motivation

The main motivation is to upgrade hyper from v0.14 to v1. There are a lot of changes when moving to v1. Some things do not have direct replacements, so upgrading all crates at once is difficult. I decided (with input from a few others) that it seemed sensible to try making a ddcommon-net crate that uses hyper 1, and then crates can migrate one-by-one from ddcommon to ddcommon-net.

Additional Notes

Please tell me if you have concerns about the approach, technical or otherwise. Here are some of mine:

  1. Since datadog-profiling is the only crate using this for now, is ddcommon-net really going to be common? Maybe we should make a net module inside of datadog-profiling instead and only extract a crate when there is at least one other crate migrated to hyper 1?
  2. There is some of copy/paste in ddcommon-net::compat and ddcommon, mostly around Uri and Endpoint related things. Probably okay, not sure.

How to test the change?

Don't. This is a WIP, I'll update this when it's ready for testing.

@github-actions github-actions bot added profiling Relates to the profiling* modules. common labels Nov 19, 2024
Cargo.toml Outdated
@@ -37,7 +37,7 @@ members = [
"data-pipeline-ffi",
"ddsketch",
"tinybytes",
"dogstatsd-client",
"dogstatsd-client", "ddcommon-net",
Copy link
Contributor

Choose a reason for hiding this comment

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

formatting

ddcommon = { path = "../ddcommon" }
hex = { version = "0.4" }
http = { version = "1" }
hyper = { version = "1", default-features = false }
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

use std::borrow::Cow;
use std::ops::Deref;

// todo: why do we need to serialize and deserialize endpoints?
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe crashtracker uses this: we spawn a collector, and then tell it where to send data by sending a Config struct as json over a pipe.

ddcommon-net/src/compat.rs Outdated Show resolved Hide resolved
Self {
url: uri,
api_key: None,
timeout_ms: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be DEFAULT_TIMEOUT?

api_key: Some(api_key.into()),
..Default::default()
})
pub trait ProfilingEndpoint {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a trait?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the "extension" trait pattern to add new methods to existing types. In this case, Endpoint::profiling_agent. We don't have to do it this way. Is there something else you would prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this to EndpointExt to hopefully be more clear about that.

ddcommon-net/src/lib.rs Show resolved Hide resolved
ddcommon-net/src/http.rs Outdated Show resolved Hide resolved
ddcommon-net/src/http.rs Outdated Show resolved Hide resolved
Some(scheme) => match scheme.as_str() {
"http" => send_http(request).await,
"https" => send_https(request).await,
#[cfg(unix)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we eventually want to support this on Windows? https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2024

Codecov Report

Attention: Patch coverage is 19.26606% with 264 lines in your changes missing coverage. Please review.

Project coverage is 70.12%. Comparing base (6fe032f) to head (a8a319c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #748      +/-   ##
==========================================
- Coverage   70.47%   70.12%   -0.36%     
==========================================
  Files         297      300       +3     
  Lines       43411    43658     +247     
==========================================
+ Hits        30594    30613      +19     
- Misses      12817    13045     +228     
Components Coverage Δ
crashtracker 43.48% <ø> (+0.03%) ⬆️
crashtracker-ffi 8.41% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 88.76% <ø> (-0.34%) ⬇️
data-pipeline-ffi 0.00% <ø> (ø)
ddcommon 75.60% <7.63%> (-7.86%) ⬇️
ddcommon-ffi 69.12% <ø> (ø)
ddtelemetry 59.05% <ø> (ø)
ddtelemetry-ffi 22.13% <ø> (ø)
dogstatsd 89.45% <ø> (ø)
dogstatsd-client 79.77% <ø> (ø)
ipc 82.86% <ø> (+0.10%) ⬆️
profiling 84.82% <66.15%> (+0.52%) ⬆️
profiling-ffi 77.43% <53.33%> (-0.03%) ⬇️
serverless 0.00% <ø> (ø)
sidecar 38.01% <ø> (ø)
sidecar-ffi 0.00% <ø> (ø)
spawn-worker 50.36% <ø> (ø)
tinybytes 94.77% <ø> (ø)
trace-mini-agent 72.36% <ø> (ø)
trace-normalization 98.23% <ø> (ø)
trace-obfuscation 95.77% <ø> (ø)
trace-protobuf 77.67% <ø> (ø)
trace-utils 92.90% <ø> (-0.39%) ⬇️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common profiling Relates to the profiling* modules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants