Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e383cc8
Update OtlpGrpcClientOptions to populate options for gRPC client sharing
ML-dev-crypto Jul 15, 2026
70e50e9
Add missing trailing newline (fixes -Wnewline-eof in maintainer mode)
ML-dev-crypto Jul 16, 2026
424b466
Address review feedback for OtlpGrpcClientOption
ML-dev-crypto Jul 16, 2026
2ca8d8e
Address remaining review feedback
ML-dev-crypto Jul 19, 2026
b2627ca
Export generic gRPC client environment helpers
ML-dev-crypto Jul 20, 2026
d703b72
Preserve shared client timeout in signal exporters
ML-dev-crypto Jul 21, 2026
b76e2be
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Aug 4, 2026
adf559b
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Aug 5, 2026
455ba94
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Aug 12, 2026
4754ef4
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Aug 14, 2026
2a6cfdc
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Aug 31, 2026
7e36ff0
fix formatting
dbarker Aug 31, 2026
7c2bc6d
fix iwyu warnings
dbarker Aug 31, 2026
8b45712
fix clang-tidy warnings
dbarker Aug 31, 2026
23935d4
cleanup
dbarker Aug 31, 2026
fa16125
fix iwyu warning
dbarker Aug 31, 2026
d62e4f1
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Sep 1, 2026
6dd46c0
fix iwyu warning
dbarker Sep 1, 2026
6177395
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Sep 2, 2026
2e6ecce
fix changelog
dbarker Sep 2, 2026
ec4cd1e
Merge branch 'main' into fix-4239-otlp-grpc-client-options
dbarker Sep 3, 2026
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ Increment the:
* docs: update supported development platforms
[#4260](https://github.com/open-telemetry/opentelemetry-cpp/pull/4260)

* [EXPORTER] Populate `OtlpGrpcClientOptions` with spec-compliant environment
variable defaults, and add constructors to `OtlpGrpcExporterOptions` /
`OtlpGrpcMetricExporterOptions` / `OtlpGrpcLogRecordExporterOptions` that
build from a shared `OtlpGrpcClientOptions`, to support sharing one gRPC
client across the trace, metric, and log exporters.
[#4239](https://github.com/open-telemetry/opentelemetry-cpp/issues/4239)

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

Expand Down
19 changes: 19 additions & 0 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ cc_library(
srcs = [
"src/otlp_grpc_client.cc",
"src/otlp_grpc_client_factory.cc",
"src/otlp_grpc_client_options.cc",
"src/otlp_grpc_utils.cc",
],
hdrs = [
Expand All @@ -114,6 +115,7 @@ cc_library(
deps = [
":otlp_common",
"//ext:headers",
"//sdk/src/common:env_variables",
"//sdk/src/common:global_log_handler",
"@com_github_grpc_grpc//:grpc++",
"@com_github_opentelemetry_proto//:common_proto_cc",
Expand Down Expand Up @@ -757,6 +759,23 @@ cc_test(
],
)

cc_test(
name = "otlp_grpc_client_options_test",
srcs = ["test/otlp_grpc_client_options_test.cc"],
tags = [
"otlp",
"otlp_grpc",
"test",
],
deps = [
":otlp_grpc_client",
":otlp_grpc_exporter",
":otlp_grpc_log_record_exporter",
":otlp_grpc_metric_exporter",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "otlp_grpc_exporter_factory_test",
srcs = ["test/otlp_grpc_exporter_factory_test.cc"],
Expand Down
18 changes: 17 additions & 1 deletion exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ if(OTELCPP_WITH_OTLP_GRPC)
add_library(
opentelemetry_exporter_otlp_grpc_client
${OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE} src/otlp_grpc_client.cc
src/otlp_grpc_client_factory.cc src/otlp_grpc_utils.cc)
src/otlp_grpc_client_factory.cc src/otlp_grpc_client_options.cc
src/otlp_grpc_utils.cc)
set_target_properties(opentelemetry_exporter_otlp_grpc_client
PROPERTIES EXPORT_NAME otlp_grpc_client)
set_target_version(opentelemetry_exporter_otlp_grpc_client)
Expand Down Expand Up @@ -891,6 +892,21 @@ if(OTELCPP_BUILD_TESTING)
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_target_test)

add_executable(otlp_grpc_client_options_test
test/otlp_grpc_client_options_test.cc)
target_link_libraries(
otlp_grpc_client_options_test
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${GMOCK_LIB}
opentelemetry_exporter_otlp_grpc
opentelemetry_exporter_otlp_grpc_log
opentelemetry_exporter_otlp_grpc_metrics)
gtest_add_tests(
TARGET otlp_grpc_client_options_test
TEST_PREFIX exporter.otlp.
TEST_LIST otlp_grpc_client_options_test)

add_executable(otlp_grpc_exporter_factory_test
test/otlp_grpc_exporter_factory_test.cc)
target_link_libraries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <algorithm>
#include <cctype>
#include <chrono>
#include <cstdint>
#include <map>
#include <string>

Expand Down Expand Up @@ -121,6 +122,10 @@ std::chrono::system_clock::duration GetOtlpDefaultTracesTimeout();
std::chrono::system_clock::duration GetOtlpDefaultMetricsTimeout();
std::chrono::system_clock::duration GetOtlpDefaultLogsTimeout();

bool GetOtlpDefaultTracesTimeoutOverride(std::chrono::system_clock::duration &value);
bool GetOtlpDefaultMetricsTimeoutOverride(std::chrono::system_clock::duration &value);
bool GetOtlpDefaultLogsTimeoutOverride(std::chrono::system_clock::duration &value);

// Compatibility with OTELCPP 1.8.2
inline std::chrono::system_clock::duration GetOtlpDefaultTimeout()
{
Expand Down Expand Up @@ -168,6 +173,30 @@ float GetOtlpDefaultTracesRetryBackoffMultiplier();
float GetOtlpDefaultMetricsRetryBackoffMultiplier();
float GetOtlpDefaultLogsRetryBackoffMultiplier();

/**
* Signal-independent accessors, for use by a gRPC client shared across
* multiple signal exporters. These read only the generic OTEL_EXPORTER_OTLP_*
* environment variables and fall back to the same spec defaults used above.
*/

void DumpOtlpHeaders(OtlpHeaders &output, const char *env_var_name);

OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientEndpoint();
OPENTELEMETRY_EXPORT bool GetOtlpDefaultGrpcClientIsInsecure();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslCertificatePath();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslCertificateString();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslClientKeyPath();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslClientKeyString();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslClientCertificatePath();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientSslClientCertificateString();
OPENTELEMETRY_EXPORT std::chrono::system_clock::duration GetOtlpDefaultGrpcClientTimeout();
OPENTELEMETRY_EXPORT OtlpHeaders GetOtlpDefaultGrpcClientHeaders();
OPENTELEMETRY_EXPORT std::string GetOtlpDefaultGrpcClientCompression();
OPENTELEMETRY_EXPORT std::uint32_t GetOtlpDefaultGrpcClientRetryMaxAttempts();
OPENTELEMETRY_EXPORT std::chrono::duration<float> GetOtlpDefaultGrpcClientRetryInitialBackoff();
OPENTELEMETRY_EXPORT std::chrono::duration<float> GetOtlpDefaultGrpcClientRetryMaxBackoff();
OPENTELEMETRY_EXPORT float GetOtlpDefaultGrpcClientRetryBackoffMultiplier();

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
#include "opentelemetry/version.h"

#include <chrono>
#include <memory>
#include <cstddef>
#include <cstdint>
#include <string>

#ifdef ENABLE_OTLP_GRPC_CREDENTIAL_PREVIEW
# include <memory>
#endif

namespace grpc
{
#ifdef ENABLE_OTLP_GRPC_CREDENTIAL_PREVIEW
class ChannelCredentials;
#endif
class ChannelArguments;
} // namespace grpc

Expand All @@ -22,10 +29,16 @@ namespace exporter
namespace otlp
{

struct OtlpGrpcClientOptions
struct OPENTELEMETRY_EXPORT OtlpGrpcClientOptions
Comment thread
dbarker marked this conversation as resolved.
Resolved
{
virtual ~OtlpGrpcClientOptions() = default;
OtlpGrpcClientOptions() = default;
virtual ~OtlpGrpcClientOptions();
Comment thread
owent marked this conversation as resolved.
Resolved

/** Lookup environment variables, and populate spec-compliant defaults. */
OtlpGrpcClientOptions();

/** No defaults. */
explicit OtlpGrpcClientOptions(void *);

OtlpGrpcClientOptions(const OtlpGrpcClientOptions &) = default;
OtlpGrpcClientOptions(OtlpGrpcClientOptions &&) = default;
OtlpGrpcClientOptions &operator=(const OtlpGrpcClientOptions &) = default;
Expand All @@ -35,7 +48,7 @@ struct OtlpGrpcClientOptions
std::string endpoint;

/** Use SSL. */
bool use_ssl_credentials{};
bool use_ssl_credentials{true};

@owent owent Sep 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem, but I think it would more clear to make all member initialization in one place(Maybe in OtlpGrpcClientOptions::OtlpGrpcClientOptions of otlp_grpc_client_options.cc).


/** CA CERT, path to a file. */
std::string ssl_credentials_cacert_path;
Expand Down Expand Up @@ -70,14 +83,14 @@ struct OtlpGrpcClientOptions
std::string user_agent;

/** max number of threads that can be allocated from this */
std::size_t max_threads{};
std::size_t max_threads{0};

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

#ifdef ENABLE_ASYNC_EXPORT
// Concurrent requests
std::size_t max_concurrent_requests{};
std::size_t max_concurrent_requests{64};
#endif

/** The maximum number of call attempts, including the original attempt. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct OPENTELEMETRY_EXPORT OtlpGrpcExporterOptions : public OtlpGrpcClientOptio
OtlpGrpcExporterOptions();
/** No defaults. */
OtlpGrpcExporterOptions(void *);
explicit OtlpGrpcExporterOptions(const OtlpGrpcClientOptions &client_options);
OtlpGrpcExporterOptions(const OtlpGrpcExporterOptions &) = default;
OtlpGrpcExporterOptions(OtlpGrpcExporterOptions &&) = default;
OtlpGrpcExporterOptions &operator=(const OtlpGrpcExporterOptions &) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterOptions : public OtlpGrpcCl
OtlpGrpcLogRecordExporterOptions();
/** No defaults. */
OtlpGrpcLogRecordExporterOptions(void *);
explicit OtlpGrpcLogRecordExporterOptions(const OtlpGrpcClientOptions &client_options);
OtlpGrpcLogRecordExporterOptions(const OtlpGrpcLogRecordExporterOptions &) = default;
OtlpGrpcLogRecordExporterOptions(OtlpGrpcLogRecordExporterOptions &&) = default;
OtlpGrpcLogRecordExporterOptions &operator=(const OtlpGrpcLogRecordExporterOptions &) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct OPENTELEMETRY_EXPORT OtlpGrpcMetricExporterOptions : public OtlpGrpcClien
OtlpGrpcMetricExporterOptions();
/** No defaults. */
OtlpGrpcMetricExporterOptions(void *);
explicit OtlpGrpcMetricExporterOptions(const OtlpGrpcClientOptions &client_options);
OtlpGrpcMetricExporterOptions(const OtlpGrpcMetricExporterOptions &) = default;
OtlpGrpcMetricExporterOptions(OtlpGrpcMetricExporterOptions &&) = default;
OtlpGrpcMetricExporterOptions &operator=(const OtlpGrpcMetricExporterOptions &) = default;
Expand Down
Loading
Loading