Skip to content

Commit 3be305e

Browse files
committed
Add compile-time flag
1 parent ab2c39b commit 3be305e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ option(
215215
"Whether to include gzip compression for the OTLP http exporter in the SDK"
216216
OFF)
217217

218+
option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs" OFF)
219+
218220
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)
219221

220222
option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"

ext/src/http/client/curl/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ else()
2424
PRIVATE ${CURL_LIBRARIES})
2525
endif()
2626

27+
if(WITH_CURL_LOGGING)
28+
target_compile_definitions(opentelemetry_http_client_curl
29+
PRIVATE ENABLE_CURL_LOGGING)
30+
endif()
31+
2732
if(WITH_OTLP_HTTP_COMPRESSION)
2833
if(TARGET ZLIB::ZLIB)
2934
target_link_libraries(

ext/src/http/client/curl/http_operation_curl.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ int HttpOperation::CurlLoggerCallback(const CURL * /* handle */,
633633

634634
CURLcode HttpOperation::Setup()
635635
{
636+
#ifdef ENABLE_CURL_LOGGING
637+
static constexpr auto kEnableCurlLogging = true;
638+
#else
639+
static constexpr auto kEnableCurlLogging = false;
640+
#endif // ENABLE_CURL_LOGGING
641+
636642
if (!curl_resource_.easy_handle)
637643
{
638644
return CURLE_FAILED_INIT;
@@ -643,7 +649,7 @@ CURLcode HttpOperation::Setup()
643649
curl_error_message_[0] = '\0';
644650
curl_easy_setopt(curl_resource_.easy_handle, CURLOPT_ERRORBUFFER, curl_error_message_);
645651

646-
rc = SetCurlLongOption(CURLOPT_VERBOSE, static_cast<long>(needs_to_log_));
652+
rc = SetCurlLongOption(CURLOPT_VERBOSE, static_cast<long>(needs_to_log_ || kEnableCurlLogging));
647653
if (rc != CURLE_OK)
648654
{
649655
return rc;

0 commit comments

Comments
 (0)