diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD index 5099b43510..e8c4507031 100644 --- a/exporters/otlp/BUILD +++ b/exporters/otlp/BUILD @@ -143,6 +143,7 @@ cc_library( srcs = [ "src/otlp_http_exporter.cc", "src/otlp_http_exporter_factory.cc", + "src/otlp_http_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", @@ -170,6 +171,7 @@ cc_library( srcs = [ "src/otlp_grpc_metric_exporter.cc", "src/otlp_grpc_metric_exporter_factory.cc", + "src/otlp_grpc_metric_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", @@ -201,6 +203,7 @@ cc_library( srcs = [ "src/otlp_http_metric_exporter.cc", "src/otlp_http_metric_exporter_factory.cc", + "src/otlp_http_metric_exporter_options.cc", ], hdrs = [ "include/opentelemetry/exporters/otlp/otlp_environment.h", diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index adab87ff02..b50e99ec7a 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -130,8 +130,11 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_TARGETS opentelemetry_exporter_otlp_http_client) - add_library(opentelemetry_exporter_otlp_http - src/otlp_http_exporter.cc src/otlp_http_exporter_factory.cc) + add_library( + opentelemetry_exporter_otlp_http + src/otlp_http_exporter.cc + src/otlp_http_exporter_factory.cc + src/otlp_http_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http PROPERTIES EXPORT_NAME otlp_http_exporter) @@ -147,7 +150,8 @@ if(WITH_OTLP_HTTP) add_library( opentelemetry_exporter_otlp_http_log src/otlp_http_log_record_exporter.cc - src/otlp_http_log_record_exporter_factory.cc) + src/otlp_http_log_record_exporter_factory.cc + src/otlp_http_log_record_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http_log PROPERTIES EXPORT_NAME otlp_http_log_record_exporter) @@ -162,7 +166,9 @@ if(WITH_OTLP_HTTP) add_library( opentelemetry_exporter_otlp_http_metric - src/otlp_http_metric_exporter.cc src/otlp_http_metric_exporter_factory.cc) + src/otlp_http_metric_exporter.cc + src/otlp_http_metric_exporter_factory.cc + src/otlp_http_metric_exporter_options.cc) set_target_properties(opentelemetry_exporter_otlp_http_metric PROPERTIES EXPORT_NAME otlp_http_metric_exporter) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h index 29b4b76ec0..6fd30c686b 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h @@ -3,9 +3,9 @@ #pragma once -#include "opentelemetry/exporters/otlp/otlp_http.h" - #include "opentelemetry/exporters/otlp/otlp_environment.h" +#include "opentelemetry/exporters/otlp/otlp_http.h" +#include "opentelemetry/version.h" #include #include @@ -20,65 +20,88 @@ namespace otlp /** * Struct to hold OTLP HTTP traces exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ struct OtlpHttpExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultHttpEndpoint(); + OtlpHttpExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - std::chrono::system_clock::duration timeout = GetOtlpDefaultTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultHeaders(); + /** Print debug messages. */ + bool console_debug; + + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; - std::string ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; + + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultTracesSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultTracesSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultTracesSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultTracesSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h index 65fd2b9b63..c16afd78d0 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h @@ -5,7 +5,7 @@ #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" -#include "opentelemetry/sdk/logs/exporter.h" +#include "opentelemetry/version.h" #include #include @@ -20,65 +20,88 @@ namespace otlp /** * Struct to hold OTLP HTTP logs exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ struct OtlpHttpLogRecordExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultHttpLogsEndpoint(); + OtlpHttpLogRecordExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - std::chrono::system_clock::duration timeout = GetOtlpDefaultLogsTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultLogsHeaders(); + /** Print debug messages. */ + bool console_debug; + + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; + + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; - std::string ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultLogsSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultLogsSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultLogsSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultLogsSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h index 8aa0ccad21..96546db73c 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h @@ -6,6 +6,7 @@ #include "opentelemetry/exporters/otlp/otlp_environment.h" #include "opentelemetry/exporters/otlp/otlp_http.h" #include "opentelemetry/exporters/otlp/otlp_preferred_temporality.h" +#include "opentelemetry/version.h" #include #include @@ -20,70 +21,90 @@ namespace otlp /** * Struct to hold OTLP HTTP metrics exporter options. + * + * See + * https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md#otlphttp + * + * See + * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md */ struct OtlpHttpMetricExporterOptions { - // The endpoint to export to. By default - // @see - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md - // @see https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver - std::string url = GetOtlpDefaultMetricsEndpoint(); + OtlpHttpMetricExporterOptions(); - // By default, post json data - HttpRequestContentType content_type = HttpRequestContentType::kJson; + /** The endpoint to export to. */ + std::string url; - // If convert bytes into hex. By default, we will convert all bytes but id into base64 - // This option is ignored if content_type is not kJson - JsonBytesMappingKind json_bytes_mapping = JsonBytesMappingKind::kHexId; + /** HTTP content type. */ + HttpRequestContentType content_type; - // If using the json name of protobuf field to set the key of json. By default, we will use the - // field name just like proto files. - bool use_json_name = false; + /** + Json byte mapping. - // Whether to print the status of the exporter in the console - bool console_debug = false; + Used only for HttpRequestContentType::kJson. + Convert bytes to hex / base64. + */ + JsonBytesMappingKind json_bytes_mapping; - // TODO: Enable/disable to verify SSL certificate - std::chrono::system_clock::duration timeout = GetOtlpDefaultMetricsTimeout(); + /** + Use json names (true) or protobuf field names (false) to set the json key. + */ + bool use_json_name; - // Additional HTTP headers - OtlpHeaders http_headers = GetOtlpDefaultMetricsHeaders(); + /** Print debug messages. */ + bool console_debug; - // Preferred Aggregation Temporality - PreferredAggregationTemporality aggregation_temporality = - PreferredAggregationTemporality::kCumulative; + /** Export timeout. */ + std::chrono::system_clock::duration timeout; + + /** Additional HTTP headers. */ + OtlpHeaders http_headers; + + PreferredAggregationTemporality aggregation_temporality; #ifdef ENABLE_ASYNC_EXPORT - // Concurrent requests - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-concurrent-requests - std::size_t max_concurrent_requests = 64; + /** Max number of concurrent requests. */ + std::size_t max_concurrent_requests; - // Requests per connections - std::size_t max_requests_per_connection = 8; + /** Max number of requests per connection. */ + std::size_t max_requests_per_connection; #endif #ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW - bool ssl_insecure_skip_verify{false}; + /** True do disable SSL. */ + bool ssl_insecure_skip_verify; + + /** CA CERT, path to a file. */ + std::string ssl_ca_cert_path; + + /** CA CERT, as a string. */ + std::string ssl_ca_cert_string; - std::string ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); - std::string ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); + /** CLIENT KEY, path to a file. */ + std::string ssl_client_key_path; - std::string ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); - std::string ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + /** CLIENT KEY, as a string. */ + std::string ssl_client_key_string; - std::string ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); - std::string ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); + /** CLIENT CERT, path to a file. */ + std::string ssl_client_cert_path; + + /** CLIENT CERT, as a string. */ + std::string ssl_client_cert_string; #endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ #ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW /** Minimum TLS version. */ - std::string ssl_min_tls = GetOtlpDefaultMetricsSslTlsMinVersion(); + std::string ssl_min_tls; + /** Maximum TLS version. */ - std::string ssl_max_tls = GetOtlpDefaultMetricsSslTlsMaxVersion(); + std::string ssl_max_tls; + /** TLS cipher. */ - std::string ssl_cipher = GetOtlpDefaultMetricsSslTlsCipher(); + std::string ssl_cipher; + /** TLS cipher suite. */ - std::string ssl_cipher_suite = GetOtlpDefaultMetricsSslTlsCipherSuite(); + std::string ssl_cipher_suite; #endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ }; diff --git a/exporters/otlp/src/otlp_http_exporter_options.cc b/exporters/otlp/src/otlp_http_exporter_options.cc new file mode 100644 index 0000000000..e41ab4e55d --- /dev/null +++ b/exporters/otlp/src/otlp_http_exporter_options.cc @@ -0,0 +1,51 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpExporterOptions::OtlpHttpExporterOptions() +{ + url = GetOtlpDefaultHttpTracesEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultTracesTimeout(); + http_headers = GetOtlpDefaultTracesHeaders(); + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif /* ENABLE_ASYNC_EXPORT */ + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultTracesSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultTracesSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultTracesSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultTracesSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultTracesSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultTracesSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultTracesSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultTracesSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultTracesSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultTracesSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +}; +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc new file mode 100644 index 0000000000..68d920e4f4 --- /dev/null +++ b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -0,0 +1,54 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions() +{ + url = GetOtlpDefaultHttpLogsEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultLogsTimeout(); + http_headers = GetOtlpDefaultLogsHeaders(); + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultLogsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultLogsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultLogsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultLogsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultLogsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultLogsSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultLogsSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultLogsSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultLogsSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultLogsSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/exporters/otlp/src/otlp_http_metric_exporter_options.cc new file mode 100644 index 0000000000..64777b5959 --- /dev/null +++ b/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -0,0 +1,53 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h" + +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace otlp +{ + +OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions() +{ + url = GetOtlpDefaultMetricsEndpoint(); + content_type = HttpRequestContentType::kJson; + json_bytes_mapping = JsonBytesMappingKind::kHexId; + use_json_name = false; + console_debug = false; + timeout = GetOtlpDefaultMetricsTimeout(); + http_headers = GetOtlpDefaultMetricsHeaders(); + aggregation_temporality = PreferredAggregationTemporality::kCumulative; + +#ifdef ENABLE_ASYNC_EXPORT + max_concurrent_requests = 64; + max_requests_per_connection = 8; +#endif + +#ifdef ENABLE_OTLP_HTTP_SSL_PREVIEW + ssl_insecure_skip_verify = false; + ssl_ca_cert_path = GetOtlpDefaultMetricsSslCertificatePath(); + ssl_ca_cert_string = GetOtlpDefaultMetricsSslCertificateString(); + ssl_client_key_path = GetOtlpDefaultMetricsSslClientKeyPath(); + ssl_client_key_string = GetOtlpDefaultMetricsSslClientKeyString(); + ssl_client_cert_path = GetOtlpDefaultMetricsSslClientCertificatePath(); + ssl_client_cert_string = GetOtlpDefaultMetricsSslClientCertificateString(); +#endif /* ENABLE_OTLP_HTTP_SSL_PREVIEW */ + +#ifdef ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW + ssl_min_tls = GetOtlpDefaultMetricsSslTlsMinVersion(); + ssl_max_tls = GetOtlpDefaultMetricsSslTlsMaxVersion(); + ssl_cipher = GetOtlpDefaultMetricsSslTlsCipher(); + ssl_cipher_suite = GetOtlpDefaultMetricsSslTlsCipherSuite(); +#endif /* ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW */ +}; + +} // namespace otlp +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE