[EXPORTER] Add custom HTTP client#4071
Conversation
|
Could you please add a test to use a simple custom http client? |
|
Thanks @ltowarek. Couple of review comments as of now -
|
dbarker
left a comment
There was a problem hiding this comment.
Thanks for the PR. Please see the question below.
|
Thanks for the feedback! I think I've covered everything in the new patch set:
|
marcalff
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
Please consider to use:
- an abstract class
HttpClientFactory, with virtual methods forCreateandCreateSync - A child class
HttpCurlClientFactory, which implement this for CURL - a HttpCurlClientFactory::singleton
Everywhere the static method HttpClientFactory::Create() is used today, pass a HttpClientFactory instance instead, taken as input parameter.
The user of an HTTP client can then decide which implementation to use:
- pass HttpCurlClientFactory::singleton to use CURL
- pass an instance of MyOwnHttpClientFactory for alternate implementations.
It should be possible to mix CURL and non CURL HTTP clients in the same binary, for example:
- send traces using HTTP + CURL to endpoint A
- send metrics using HTTP + alternate to endpoint B
5147826 to
516c51b
Compare
@marcalff, it looks like a good idea. My main goal with the current PR is build-time configuration - to enable I think runtime changes should be a part of a separate PR which I'm open to working on. |
|
Thanks for adding the runtime factory path. I think this is moving in the right direction, but can we make the injection story consistent across all HTTP exporters? Right now Also, after making |
…to fix/issue-24-custom-http-client
|
@lalitb thanks for the feedback! I've addressed your comments in the latest commits. |
Fixes #2084
Changes
Adds a way to provide a custom HTTP client instead of the default
libcurl-based client.The main motivation are embedded and cross-compiled targets where libcurl is unavailable. A working example for ESP32S3 using ESP-IDF's
esp_http_clientas the transport backend is at ltowarek/esp-opentelemetry-cpp#30.