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

Switch from reqwest to hyper and add uds support #2

Closed
wants to merge 4 commits into from

Conversation

paullegranddc
Copy link
Contributor

@paullegranddc paullegranddc commented Feb 28, 2022

What does this PR do?

  • Switch the exporter http client from reqwest to hyper
  • Copy the MultipartForm format code from reqwest, for use it in the exporter.
    // TODO what does this imply in term of licensing, do we need to add the link to the original license Apache/MIT somewhere?
  • Add UDS support for the exporter, by implementing hyper's Service<Uri> to resolve UDS sockets into a stream.

Motivation

This PR is motivated by a few things

  • reqwest doesn't support UDS. There are multiple years old issues open on the repo asking if it is planned.
  • The reqwest crate is the biggest contributor in term of size to the final artefact. By using a lower level we can remove a lot of the bloat generated (691.3KiB on 8.9MiB). The new artifact is 5.7MiB which is a 35% size reduction

Additional Notes

hyper doesn't support TLS natively. I added support for it through the hyper-rustls. By default the rustls feature for request uses webpki as root of trust, whereas with hyper-rustls the default certificates are picked from the OS which is probably also saves some space.

How to test the change?

I am still testing them

@paullegranddc
Copy link
Contributor Author

PR has been merged in libddprof first

@morrisonlevi morrisonlevi deleted the paullgdc/switch_http_client branch January 27, 2023 16:20
bwoebi added a commit that referenced this pull request May 24, 2024
It apparently leads to race conditions if libpthread and libc aren't loaded at the same time.
In this case a library linking against libpthread is dlopen()'ed dynamically from the trampoline.

It led to interesting libc memory corruptions, like in getaddrinfo:

#2  0x00007fe45328df67 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7fe4533a05d0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:196
#3  0x00007fe453296329 in malloc_printerr (ar_ptr=0x7fe4535dc760 <main_arena>, ptr=<optimized out>, str=0x7fe4533a06d8 "double free or corruption (out)", action=3) at malloc.c:4967
#4  _int_free (av=0x7fe4535dc760 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3843
#5  0x00007fe453283247 in _IO_new_fclose (fp=0x7fe448001d20) at iofclose.c:84

etc. on older glibc versions.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
bwoebi added a commit that referenced this pull request May 24, 2024
It apparently leads to race conditions if libpthread and libc aren't loaded at the same time.
In this case a library linking against libpthread is dlopen()'ed dynamically from the trampoline.

It led to interesting libc memory corruptions, like in getaddrinfo:

#2  0x00007fe45328df67 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7fe4533a05d0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:196
#3  0x00007fe453296329 in malloc_printerr (ar_ptr=0x7fe4535dc760 <main_arena>, ptr=<optimized out>, str=0x7fe4533a06d8 "double free or corruption (out)", action=3) at malloc.c:4967
#4  _int_free (av=0x7fe4535dc760 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3843
#5  0x00007fe453283247 in _IO_new_fclose (fp=0x7fe448001d20) at iofclose.c:84

etc. on older glibc versions.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
bwoebi added a commit that referenced this pull request May 24, 2024
It apparently leads to race conditions if libpthread and libc aren't loaded at the same time.
In this case a library linking against libpthread is dlopen()'ed dynamically from the trampoline.

It led to interesting libc memory corruptions, like in getaddrinfo:

#2  0x00007fe45328df67 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7fe4533a05d0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:196
#3  0x00007fe453296329 in malloc_printerr (ar_ptr=0x7fe4535dc760 <main_arena>, ptr=<optimized out>, str=0x7fe4533a06d8 "double free or corruption (out)", action=3) at malloc.c:4967
#4  _int_free (av=0x7fe4535dc760 <main_arena>, p=<optimized out>, have_lock=0) at malloc.c:3843
#5  0x00007fe453283247 in _IO_new_fclose (fp=0x7fe448001d20) at iofclose.c:84

etc. on older glibc versions.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant