Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Oct 28, 2023
1 parent 17da6d8 commit 427bf72
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 113 deletions.
3 changes: 3 additions & 0 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 10 additions & 4 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <chrono>
#include <cstddef>
Expand All @@ -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 */
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <chrono>
#include <cstddef>
Expand All @@ -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 */
};

Expand Down
Loading

0 comments on commit 427bf72

Please sign in to comment.