Skip to content

Commit

Permalink
Switch to absl options/variant to support earlier C++.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylepl committed May 3, 2023
1 parent 0e06a9e commit b3b4f12
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

#pragma once

#include "absl/types/optional.h"
#include "absl/types/variant.h"
#include "opentelemetry/exporters/otlp/otlp_environment.h"

#include <memory>
// TODO: These requires C++17, is that OK? It seems like we need to support C++0x?
#include <optional>
#include <variant>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
Expand All @@ -17,7 +16,7 @@ namespace otlp
{

// This type allows the variants to be default-constructed to neither type.
// This avoids needing deeper template if std::optional<std::variant<>>.
// This avoids needing deeper template if absl::optional<absl::variant<>>.
struct Unset {};

// TODO: Check if this strong-typing is ok. It seems nice, and allows variant typing.
Expand All @@ -35,13 +34,13 @@ struct FileContents {
struct SSLCredentials {
// Path to or contents of a .pem file of the root certs used to verify the service side
// certificate.
std::variant<Unset, FilePath, FileContents> pem_root_certs;
absl::variant<Unset, FilePath, FileContents> pem_root_certs;

// Path to or contents of a .pem file containing the client's private key.
std::variant<Unset, FilePath, FileContents> pem_private_key;
absl::variant<Unset, FilePath, FileContents> pem_private_key;

// Path to or contents of a .pem file containing the client's certificate chain.
std::variant<Unset, FilePath, FileContents> pem_cert_chain;
absl::variant<Unset, FilePath, FileContents> pem_cert_chain;
};

/**
Expand All @@ -61,7 +60,7 @@ struct OtlpGrpcExporterOptions
// SSL encryption.
std::string ssl_credentials_cacert_as_string = GetOtlpDefaultSslCertificateString();
// The credentials to secure the connection.
std::optional<SSLCredentials> ssl_credentials;
absl::optional<SSLCredentials> ssl_credentials;
// Timeout for grpc deadline
std::chrono::system_clock::duration timeout = GetOtlpDefaultTimeout();
// Additional HTTP headers
Expand Down

0 comments on commit b3b4f12

Please sign in to comment.