opentelemetry-cpp
opentelemetry-cpp copied to clipboard
Allow adding custom HTTP client
As of now, otel-cpp use Curl as the default HTTP Client, and is set here for CMake. It should be instead possible for users to bring their own HTTP Client library. Proposed solution could be:
- Add cmake option (say WITH_CUSTOM_HTTP_CLIENT). And then WITH_HTTP_CLIENT_CURL shouldn't be set if the new option is enabled.
- User need to provide following as part of their application code -
- Implementation for
opentelemetry::ext::http::client::HttpClientFactory::Create()andopentelemetry::ext::http::client::HttpClientFactory::CreateSync(). These two methods should return instances for custom implementation for HttpClient (async http client) and HttpClientSync (sync http client) as mentioned in step below. - Custom implementation for
ext::http::client::HttpClientSyncand:ext::http::client::HttpClientclasses.
- Implementation for
- (Open Issue)
opentelemetry_http_client_curlshouldn't be directly linked with other targets, probably some way to ensure that custom client library get's used at all the places.
This will ensure that only one definition/symbol for HttpClient and HttpClientSync is exposed (either from Custom http client, or the Curl http client) and would be invoked at run-time.
Also changes would be required in bazel build.
We can use this issue to finalize solution before implementation.
Related issue : #1145 #1146
This issue was marked as stale due to lack of activity.