Skip to content

Commit 0e33217

Browse files
committed
Make it an opt-in feature
1 parent f8e10c7 commit 0e33217

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ if(NOT WITH_STL STREQUAL "OFF")
212212
endif()
213213
endif()
214214

215+
option(WITH_OTLP_RETRY_PREVIEW
216+
"Whether to enable experimental retry functionality" OFF)
217+
215218
option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW
216219
"Whether to enable mTLS support fro gRPC" OFF)
217220

api/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ target_compile_definitions(
116116
opentelemetry_api
117117
INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO})
118118

119+
if(WITH_OTLP_RETRY_PREVIEW)
120+
target_compile_definitions(opentelemetry_api
121+
INTERFACE ENABLE_OTLP_RETRY_PREVIEW)
122+
endif()
123+
119124
if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
120125
target_compile_definitions(opentelemetry_api
121126
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW)

ci/do_ci.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
131131
-DOTELCPP_MAINTAINER_MODE=ON \
132132
-DWITH_NO_DEPRECATED_CODE=ON \
133133
-DWITH_OTLP_HTTP_COMPRESSION=ON \
134+
-DWITH_OTLP_RETRY_PREVIEW=ON \
134135
${IWYU} \
135136
"${SRC_DIR}"
136137
eval "$MAKE_COMMAND"
@@ -153,6 +154,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
153154
-DOTELCPP_MAINTAINER_MODE=ON \
154155
-DWITH_NO_DEPRECATED_CODE=ON \
155156
-DWITH_OTLP_HTTP_COMPRESSION=ON \
157+
-DWITH_OTLP_RETRY_PREVIEW=ON \
156158
${IWYU} \
157159
"${SRC_DIR}"
158160
eval "$MAKE_COMMAND"
@@ -176,6 +178,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then
176178
-DOTELCPP_MAINTAINER_MODE=ON \
177179
-DWITH_NO_DEPRECATED_CODE=ON \
178180
-DWITH_OTLP_HTTP_COMPRESSION=ON \
181+
-DWITH_OTLP_RETRY_PREVIEW=ON \
179182
"${SRC_DIR}"
180183
make -k -j $(nproc)
181184
make test
@@ -199,6 +202,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
199202
-DWITH_ABI_VERSION_1=OFF \
200203
-DWITH_ABI_VERSION_2=ON \
201204
-DWITH_OTLP_HTTP_COMPRESSION=ON \
205+
-DWITH_OTLP_RETRY_PREVIEW=ON \
202206
${IWYU} \
203207
"${SRC_DIR}"
204208
eval "$MAKE_COMMAND"

exporters/otlp/test/otlp_http_exporter_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ TEST_F(OtlpHttpExporterTestPeer, ConfigRetryGenericValuesFromEnv)
685685
}
686686
# endif // NO_GETENV
687687

688+
# ifdef ENABLE_OTLP_RETRY_PREVIEW
688689
using StatusCodeVector = std::vector<int>;
689690

690691
class OtlpHttpExporterRetryIntegrationTests
@@ -787,6 +788,7 @@ TEST_P(OtlpHttpExporterRetryIntegrationTests, StatusCodes)
787788

788789
ASSERT_EQ(expected_attempts, request_count);
789790
}
791+
# endif // ENABLE_OTLP_RETRY_PREVIEW
790792

791793
} // namespace otlp
792794
} // namespace exporter

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ void HttpOperation::Cleanup()
439439

440440
bool HttpOperation::IsRetryable()
441441
{
442+
#ifdef ENABLE_OTLP_RETRY_PREVIEW
442443
static constexpr auto kRetryableStatusCodes = std::array<decltype(response_code_), 4>{
443444
429, // Too Many Requests
444445
502, // Bad Gateway
@@ -451,6 +452,9 @@ bool HttpOperation::IsRetryable()
451452

452453
return is_retryable && (last_curl_result_ == CURLE_OK) &&
453454
(retry_attempts_ < retry_policy_.max_attempts);
455+
#else
456+
return false;
457+
#endif // ENABLE_OTLP_RETRY_PREVIEW
454458
}
455459

456460
std::chrono::system_clock::time_point HttpOperation::NextRetryTime()

ext/test/http/curl_http_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ TEST_F(BasicCurlHttpTests, CurlHttpOperations)
354354
delete handler;
355355
}
356356

357+
#ifdef ENABLE_OTLP_RETRY_PREVIEW
357358
TEST_F(BasicCurlHttpTests, RetryPolicyEnabled)
358359
{
359360
RetryEventHandler handler;
@@ -436,6 +437,7 @@ TEST_F(BasicCurlHttpTests, ExponentialBackoffRetry)
436437
ASSERT_EQ(CURLE_OK, operation.Send());
437438
ASSERT_FALSE(operation.IsRetryable());
438439
}
440+
#endif // ENABLE_OTLP_RETRY_PREVIEW
439441

440442
TEST_F(BasicCurlHttpTests, SendGetRequestSync)
441443
{

0 commit comments

Comments
 (0)