Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Increment the:

## [Unreleased]

* [EXT] TCP keepalive is now configurable via `Request::SetKeepAlive()` and per-exporter
options `http_keepalive`, `http_keepalive_idle`, and `http_keepalive_intvl` on
`OtlpHttpExporterOptions`, `OtlpHttpLogRecordExporterOptions`,
`OtlpHttpMetricExporterOptions`, and `OtlpHttpClientOptions`. Keepalive is disabled
by default (opt-in). `CURLOPT_TCP_KEEPIDLE` and `CURLOPT_TCP_KEEPINTVL` are
configurable; zero values fall back to the libcurl/OS default.
[#4266](https://github.com/open-telemetry/opentelemetry-cpp/pull/4266)

* [CONFIGURATION] Build the configured resource detectors in SdkBuilder, apply
the `detection.attributes` include/exclude filter to the detected attributes,
and merge the resource per the resource SDK specification.
Expand Down Expand Up @@ -162,6 +170,13 @@ Increment the:
* [CODE HEALTH] Fix more clang tidy warnings (member initialization)
[#4270](https://github.com/open-telemetry/opentelemetry-cpp/pull/4270)

* docs: update supported development platforms
[#4260](https://github.com/open-telemetry/opentelemetry-cpp/pull/4260)

* [RELEASE] Bump main branch to 1.29.0-dev
[#4259](https://github.com/open-telemetry/opentelemetry-cpp/pull/4259)


* docs: update supported development platforms
[#4260](https://github.com/open-telemetry/opentelemetry-cpp/pull/4260)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,47 @@ struct OtlpHttpClientOptions
std::shared_ptr<sdk::common::ThreadInstrumentation> thread_instrumentation =
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);

/**
* Enable TCP keepalive probes on the underlying curl connection.
*
* When true, the OS will send keepalive probes after the connection
* has been idle for @p http_keepalive_idle seconds, then repeat every
* @p http_keepalive_intvl seconds until the peer acknowledges or the
* connection is declared dead. This detects half-open TCP connections
* caused by silent peer disappearance.
*
* Default: false (keepalive disabled).
*/
bool http_keepalive = false;

/**
* Idle time in seconds before TCP keepalive probes begin.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 60-75 s on
* Linux, 7200 s on macOS). Set to a smaller value (e.g., 30) for
* faster detection of half-open connections.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_idle = std::chrono::seconds::zero();

/**
* Interval in seconds between successive TCP keepalive probes.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 75 s on
* Linux). Set to a smaller value (e.g., 5) to detect failures more
* quickly once probing has started.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_intvl = std::chrono::seconds::zero();

inline OtlpHttpClientOptions(
nostd::string_view input_url,
bool input_ssl_insecure_skip_verify,
Expand Down Expand Up @@ -119,7 +160,10 @@ struct OtlpHttpClientOptions
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,
nostd::string_view input_user_agent = GetOtlpDefaultUserAgent())
nostd::string_view input_user_agent = GetOtlpDefaultUserAgent(),
bool input_http_keepalive = false,
std::chrono::seconds input_http_keepalive_idle = std::chrono::seconds::zero(),
std::chrono::seconds input_http_keepalive_intvl = std::chrono::seconds::zero())
: url(input_url),
ssl_options(input_url,
input_ssl_insecure_skip_verify,
Expand All @@ -145,7 +189,10 @@ struct OtlpHttpClientOptions
max_concurrent_requests(input_concurrent_sessions),
max_requests_per_connection(input_max_requests_per_connection),
user_agent(input_user_agent),
thread_instrumentation(input_thread_instrumentation)
thread_instrumentation(input_thread_instrumentation),
http_keepalive(input_http_keepalive),
http_keepalive_idle(input_http_keepalive_idle),
http_keepalive_intvl(input_http_keepalive_intvl)
{}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,47 @@ struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions
std::uint32_t max_links = (std::numeric_limits<std::uint32_t>::max)();
std::uint32_t max_attributes_per_event = (std::numeric_limits<std::uint32_t>::max)();
std::uint32_t max_attributes_per_link = (std::numeric_limits<std::uint32_t>::max)();

/**
* Enable TCP keepalive probes on the underlying curl connection.
*
* When true, the OS will send keepalive probes after the connection
* has been idle for @p http_keepalive_idle seconds, then repeat every
* @p http_keepalive_intvl seconds until the peer acknowledges or the
* connection is declared dead. This detects half-open TCP connections
* caused by silent peer disappearance.
*
* Default: false (keepalive disabled, preserves pre-existing behavior).
*/
bool http_keepalive{false};

/**
* Idle time in seconds before TCP keepalive probes begin.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 60-75 s on
* Linux, 7200 s on macOS). Set to a smaller value (e.g., 30) for
* faster detection of half-open connections.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_idle{std::chrono::seconds::zero()};

/**
* Interval in seconds between successive TCP keepalive probes.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 75 s on
* Linux). Set to a smaller value (e.g., 5) to detect failures more
* quickly once probing has started.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_intvl{std::chrono::seconds::zero()};
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,47 @@ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions

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

/**
* Enable TCP keepalive probes on the underlying curl connection.
*
* When true, the OS will send keepalive probes after the connection
* has been idle for @p http_keepalive_idle seconds, then repeat every
* @p http_keepalive_intvl seconds until the peer acknowledges or the
* connection is declared dead. This detects half-open TCP connections
* caused by silent peer disappearance.
*
* Default: false (keepalive disabled, preserves pre-existing behavior).
*/
bool http_keepalive{false};

/**
* Idle time in seconds before TCP keepalive probes begin.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 60-75 s on
* Linux, 7200 s on macOS). Set to a smaller value (e.g., 30) for
* faster detection of half-open connections.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_idle{std::chrono::seconds::zero()};

/**
* Interval in seconds between successive TCP keepalive probes.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 75 s on
* Linux). Set to a smaller value (e.g., 5) to detect failures more
* quickly once probing has started.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_intvl{std::chrono::seconds::zero()};
};

} // namespace otlp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,47 @@ struct OPENTELEMETRY_EXPORT OtlpHttpMetricExporterOptions

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

/**
* Enable TCP keepalive probes on the underlying curl connection.
*
* When true, the OS will send keepalive probes after the connection
* has been idle for @p http_keepalive_idle seconds, then repeat every
* @p http_keepalive_intvl seconds until the peer acknowledges or the
* connection is declared dead. This detects half-open TCP connections
* caused by silent peer disappearance.
*
* Default: false (keepalive disabled, preserves pre-existing behavior).
*/
bool http_keepalive{false};

/**
* Idle time in seconds before TCP keepalive probes begin.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 60-75 s on
* Linux, 7200 s on macOS). Set to a smaller value (e.g., 30) for
* faster detection of half-open connections.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_idle{std::chrono::seconds::zero()};

/**
* Interval in seconds between successive TCP keepalive probes.
*
* Only effective when @p http_keepalive is true.
* A value of zero uses the libcurl / OS default (typically 75 s on
* Linux). Set to a smaller value (e.g., 5) to detect failures more
* quickly once probing has started.
*
* Requires libcurl >= 7.25.0; silently ignored on older versions.
*
* Default: 0 (use OS default).
*/
std::chrono::seconds http_keepalive_intvl{std::chrono::seconds::zero()};
};

} // namespace otlp
Expand Down
69 changes: 57 additions & 12 deletions exporters/otlp/src/otlp_http_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,16 @@ OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options)
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
)))
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl)))
{}

OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options,
Expand Down Expand Up @@ -115,9 +122,16 @@ OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options,
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
)))
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl)))
{}

OtlpHttpExporter::OtlpHttpExporter(
Expand Down Expand Up @@ -153,9 +167,16 @@ OtlpHttpExporter::OtlpHttpExporter(
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
),
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl),
factory))
{}

Expand Down Expand Up @@ -193,9 +214,16 @@ OtlpHttpExporter::OtlpHttpExporter(
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
),
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl),
factory))
{}

Expand Down Expand Up @@ -231,9 +259,16 @@ OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options,
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
),
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl),
std::move(http_client)))
{}

Expand Down Expand Up @@ -270,9 +305,16 @@ OtlpHttpExporter::OtlpHttpExporter(const OtlpHttpExporterOptions &options,
#ifdef ENABLE_ASYNC_EXPORT
,
options.max_concurrent_requests,
options.max_requests_per_connection
options.max_requests_per_connection,
#else
,
64,
8,
#endif
),
GetOtlpDefaultUserAgent(),
options.http_keepalive,
options.http_keepalive_idle,
options.http_keepalive_intvl),
std::move(http_client)))
{}

Expand All @@ -296,6 +338,9 @@ OtlpHttpExporter::OtlpHttpExporter(std::unique_ptr<OtlpHttpClient> http_client)
options_.max_requests_per_connection = http_client_->GetOptions().max_requests_per_connection;
#endif
runtime_options_.thread_instrumentation = http_client_->GetOptions().thread_instrumentation;
options_.http_keepalive = http_client_->GetOptions().http_keepalive;
options_.http_keepalive_idle = http_client_->GetOptions().http_keepalive_idle;
options_.http_keepalive_intvl = http_client_->GetOptions().http_keepalive_intvl;
}
// ----------------------------- Exporter methods ------------------------------

Expand Down
5 changes: 4 additions & 1 deletion exporters/otlp/src/otlp_http_exporter_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ OtlpHttpExporterOptions::OtlpHttpExporterOptions()
retry_policy_max_attempts(GetOtlpDefaultTracesRetryMaxAttempts()),
retry_policy_initial_backoff(GetOtlpDefaultTracesRetryInitialBackoff()),
retry_policy_max_backoff(GetOtlpDefaultTracesRetryMaxBackoff()),
retry_policy_backoff_multiplier(GetOtlpDefaultTracesRetryBackoffMultiplier())
retry_policy_backoff_multiplier(GetOtlpDefaultTracesRetryBackoffMultiplier()),
http_keepalive(false),
http_keepalive_idle(std::chrono::seconds::zero()),
http_keepalive_intvl(std::chrono::seconds::zero())
{}

OtlpHttpExporterOptions::OtlpHttpExporterOptions(void *) {}
Expand Down
Loading
Loading