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

[EXPORTER] Support handling retry-able errors for OTLP/HTTP #3223

Merged
merged 35 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c4c31aa
Add environment-related logic
chusitoo Dec 24, 2024
ed07242
Update options with retry policy settings
chusitoo Dec 24, 2024
1dba246
Test config and retry mechanism
chusitoo Dec 24, 2024
ae47b20
Functional retry policy
chusitoo Dec 29, 2024
3c2c24a
Model exponential backoff after grpc retry policy
chusitoo Dec 29, 2024
2f9b629
Fix some neglected bits
chusitoo Dec 30, 2024
9cd4717
Reduce usage of decimal seconds to http client et al
chusitoo Dec 30, 2024
cec3b98
Fix overlook on iterator increment
chusitoo Dec 30, 2024
082597a
Unit test http retries with exponential backoff
chusitoo Dec 30, 2024
8008e8c
Update comments for clarity
chusitoo Dec 30, 2024
48402d9
Fix unit tests and minor touchups
chusitoo Dec 30, 2024
6de20c1
Make intent clear in options used by UTs
chusitoo Dec 31, 2024
4de2f81
Cleanup
chusitoo Dec 31, 2024
413b284
Fix to support windows macro
chusitoo Jan 4, 2025
14a2927
Merge branch 'main' into RetryableErrorHttp
marcalff Jan 6, 2025
25b332c
Code review feedback
chusitoo Jan 7, 2025
f511021
Code review feedback pt 2
chusitoo Jan 8, 2025
20b347f
Code review feedback pt 3
chusitoo Jan 8, 2025
da7c636
Change to strtoull to ensure portability on msvc
chusitoo Jan 8, 2025
cd816b6
Include errno
chusitoo Jan 8, 2025
169b4a6
Bail out earlier from retry list
chusitoo Jan 8, 2025
62e2a6a
Merge remote-tracking branch 'remotes/origin/main' into RetryableErro…
chusitoo Jan 8, 2025
2e3ec77
Fixes for iwyu
chusitoo Jan 9, 2025
cb60f09
Fixes for clang-tidy
chusitoo Jan 9, 2025
f8e10c7
Add to changelog
chusitoo Jan 9, 2025
0e33217
Make it an opt-in feature
chusitoo Jan 10, 2025
e8bdb66
Guard includes for iwyu
chusitoo Jan 10, 2025
904929a
Merge remote-tracking branch 'remotes/origin/main' into RetryableErro…
chusitoo Jan 11, 2025
f8b6a09
Slightly faster code, slightly clearer intent
chusitoo Jan 11, 2025
797fda1
Remove unused include
chusitoo Jan 11, 2025
472aa35
Merge remote-tracking branch 'remotes/origin/main' into RetryableErro…
chusitoo Jan 16, 2025
facc19d
Prevent background thread from exiting when pending retries
chusitoo Jan 17, 2025
d3c52fe
Merge remote-tracking branch 'remotes/origin/main' into RetryableErro…
chusitoo Jan 17, 2025
63d7d7d
Address nit and minor logic flaw
chusitoo Jan 17, 2025
905e7ae
Fix clang tidy warning
chusitoo Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Increment the:
* [SDK] Enable deriving from ResourceDetector to create a Resource
[#3247](https://github.com/open-telemetry/opentelemetry-cpp/pull/3247)

* [EXPORTER] Support handling retry-able errors for OTLP/HTTP
[#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223)

New features:

* [SDK] Better control of threads executed by opentelemetry-cpp
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ if(NOT WITH_STL STREQUAL "OFF")
endif()
endif()

option(WITH_OTLP_RETRY_PREVIEW
"Whether to enable experimental retry functionality" OFF)

option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW
"Whether to enable mTLS support fro gRPC" OFF)

Expand Down
5 changes: 5 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ target_compile_definitions(
opentelemetry_api
INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO})

if(WITH_OTLP_RETRY_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_RETRY_PREVIEW)
endif()

if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW)
Expand Down
4 changes: 4 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand All @@ -142,6 +143,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand All @@ -165,6 +167,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then
-DOTELCPP_MAINTAINER_MODE=ON \
-DWITH_NO_DEPRECATED_CODE=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
make -k -j $(nproc)
Expand All @@ -189,6 +192,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
-DWITH_ABI_VERSION_1=OFF \
-DWITH_ABI_VERSION_2=ON \
-DWITH_OTLP_HTTP_COMPRESSION=ON \
-DWITH_OTLP_RETRY_PREVIEW=ON \
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
"${SRC_DIR}"
eval "$MAKE_COMMAND"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ std::string GetOtlpDefaultTracesCompression();
std::string GetOtlpDefaultMetricsCompression();
std::string GetOtlpDefaultLogsCompression();

std::uint32_t GetOtlpDefaultTracesRetryMaxAttempts();
std::uint32_t GetOtlpDefaultMetricsRetryMaxAttempts();
std::uint32_t GetOtlpDefaultLogsRetryMaxAttempts();

std::chrono::duration<float> GetOtlpDefaultTracesRetryInitialBackoff();
std::chrono::duration<float> GetOtlpDefaultMetricsRetryInitialBackoff();
std::chrono::duration<float> GetOtlpDefaultLogsRetryInitialBackoff();

std::chrono::duration<float> GetOtlpDefaultTracesRetryMaxBackoff();
std::chrono::duration<float> GetOtlpDefaultMetricsRetryMaxBackoff();
std::chrono::duration<float> GetOtlpDefaultLogsRetryMaxBackoff();

float GetOtlpDefaultTracesRetryBackoffMultiplier();
float GetOtlpDefaultMetricsRetryBackoffMultiplier();
float GetOtlpDefaultLogsRetryBackoffMultiplier();

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ struct OtlpHttpClientOptions
// Additional HTTP headers
OtlpHeaders http_headers;

// Retry policy for select failure codes
ext::http::client::RetryPolicy retry_policy;

// Concurrent requests
std::size_t max_concurrent_requests = 64;

Expand Down Expand Up @@ -107,6 +110,10 @@ struct OtlpHttpClientOptions
bool input_console_debug,
std::chrono::system_clock::duration input_timeout,
const OtlpHeaders &input_http_headers,
std::uint32_t input_retry_policy_max_attempts,
std::chrono::duration<float> input_retry_policy_initial_backoff,
std::chrono::duration<float> input_retry_policy_max_backoff,
float input_retry_policy_backoff_multiplier,
const std::shared_ptr<sdk::common::ThreadInstrumentation> &input_thread_instrumentation,
std::size_t input_concurrent_sessions = 64,
std::size_t input_max_requests_per_connection = 8,
Expand All @@ -131,6 +138,8 @@ struct OtlpHttpClientOptions
console_debug(input_console_debug),
timeout(input_timeout),
http_headers(input_http_headers),
retry_policy{input_retry_policy_max_attempts, input_retry_policy_initial_backoff,
input_retry_policy_max_backoff, input_retry_policy_backoff_multiplier},
max_concurrent_requests(input_concurrent_sessions),
max_requests_per_connection(input_max_requests_per_connection),
user_agent(input_user_agent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstdint>
#include <string>

#include "opentelemetry/exporters/otlp/otlp_environment.h"
Expand Down Expand Up @@ -101,6 +102,18 @@ struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions

/** Compression type. */
std::string compression;

/** The maximum number of call attempts, including the original attempt. */
std::uint32_t retry_policy_max_attempts{};

/** The initial backoff delay between retry attempts, random between (0, initial_backoff). */
std::chrono::duration<float> retry_policy_initial_backoff{};

/** The maximum backoff places an upper limit on exponential backoff growth. */
std::chrono::duration<float> retry_policy_max_backoff{};

/** The backoff will be multiplied by this value after each retry attempt. */
float retry_policy_backoff_multiplier{};
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstdint>
#include <string>

#include "opentelemetry/exporters/otlp/otlp_environment.h"
Expand Down Expand Up @@ -101,6 +102,18 @@ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions

/** Compression type. */
std::string compression;

/** The maximum number of call attempts, including the original attempt. */
std::uint32_t retry_policy_max_attempts{};

/** The initial backoff delay between retry attempts, random between (0, initial_backoff). */
std::chrono::duration<float> retry_policy_initial_backoff{};
marcalff marked this conversation as resolved.
Show resolved Hide resolved

/** The maximum backoff places an upper limit on exponential backoff growth. */
std::chrono::duration<float> retry_policy_max_backoff{};

/** The backoff will be multiplied by this value after each retry attempt. */
float retry_policy_backoff_multiplier{};
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <chrono>
#include <cstdint>
#include <string>

#include "opentelemetry/exporters/otlp/otlp_environment.h"
Expand Down Expand Up @@ -104,6 +105,18 @@ struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterOptions

/** Compression type. */
std::string compression;

/** The maximum number of call attempts, including the original attempt. */
std::uint32_t retry_policy_max_attempts{};

/** The initial backoff delay between retry attempts, random between (0, initial_backoff). */
std::chrono::duration<float> retry_policy_initial_backoff{};

/** The maximum backoff places an upper limit on exponential backoff growth. */
std::chrono::duration<float> retry_policy_max_backoff{};

/** The backoff will be multiplied by this value after each retry attempt. */
float retry_policy_backoff_multiplier{};
};

} // namespace otlp
Expand Down
Loading
Loading