-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: main
Are you sure you want to change the base?
Conversation
dc5aeaa
to
8c09a72
Compare
@@ -37,7 +37,7 @@ members = [ | |||
"data-pipeline-ffi", | |||
"ddsketch", | |||
"tinybytes", | |||
"dogstatsd-client", | |||
"dogstatsd-client", "ddcommon-net", |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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.
/// - User agent | ||
/// - Api key | ||
/// - Container Id/Entity Id | ||
pub fn into_request_builder( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ I'd expect into_
named functions to consume the object.
Self { | ||
url: uri, | ||
api_key: None, | ||
timeout_ms: 0, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
|
||
/// Creates a tokio runtime for the current thread. This is the expected | ||
/// way to create a runtime used by this crate. | ||
pub fn create_current_thread_runtime() -> io::Result<runtime::Runtime> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we stash this in a thread_local?
if uri.scheme_str() != Some("unix") || uri.scheme_str() != Some("windows") { | ||
return Err(io::Error::new( | ||
io::ErrorKind::InvalidInput, | ||
"URI scheme must be unix or windows", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"URI scheme must be unix or windows", | |
format!("URI scheme must be unix or windows: was {}", uri.scheme_str()), |
if uri.scheme_str() != Some("https") { | ||
return Err(Error::Io(io::Error::new( | ||
io::ErrorKind::InvalidInput, | ||
"URI scheme must be https", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"URI scheme must be https", | |
format!("URI scheme must be https, was {}", uri.scheme_str()), |
Some(scheme) => match scheme.as_str() { | ||
"http" => send_http(request).await, | ||
"https" => send_https(request).await, | ||
#[cfg(unix)] |
There was a problem hiding this comment.
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/
What does this PR do?
ddcommon-net
, naming suggestions welcome. It has bits ofddcommon
networking code which have been upgraded to hyper 1. Note it's not a direct 1:1 because hyper 1 changed a lot.datadog-profiling
crate has been updated to use it. Currently its tests pass for me locally. Thedatadog-profiling-ffi
is currently broken.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 fromddcommon
toddcommon-net
.Additional Notes
Please tell me if you have concerns about the approach, technical or otherwise. Here are some of mine:
datadog-profiling
is the only crate using this for now, isddcommon-net
really going to be common? Maybe we should make anet
module inside ofdatadog-profiling
instead and only extract a crate when there is at least one other crate migrated to hyper 1?ddcommon-net::compat
andddcommon
, 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.