Skip to content

Commit 3f99d32

Browse files
committed
Refresh code from PR #2518, to fix review comments.
1 parent 5927a67 commit 3f99d32

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

sdk/include/opentelemetry/sdk/configuration/invalid_schema_exception.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ class InvalidSchemaException : public std::runtime_error
2020
{
2121
public:
2222
InvalidSchemaException(const std::string &msg) : std::runtime_error(msg) {}
23-
InvalidSchemaException(InvalidSchemaException &&) = default;
24-
InvalidSchemaException(const InvalidSchemaException &) = default;
25-
InvalidSchemaException &operator=(InvalidSchemaException &&) = default;
26-
InvalidSchemaException &operator=(const InvalidSchemaException &other) = default;
27-
~InvalidSchemaException() override = default;
2823
};
2924

3025
} // namespace configuration

sdk/src/configuration/document_node.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <ostream>
77
#include <string>
88

9+
#include "opentelemetry/sdk/common/env_variables.h"
910
#include "opentelemetry/sdk/common/global_log_handler.h"
1011
#include "opentelemetry/sdk/configuration/document_node.h"
1112
#include "opentelemetry/sdk/configuration/invalid_schema_exception.h"
@@ -106,7 +107,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
106107
std::string::size_type pos;
107108
std::string name;
108109
std::string fallback;
109-
const char *sub;
110+
std::string sub;
111+
bool env_exists;
110112

111113
if (len < 4)
112114
{
@@ -196,8 +198,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
196198
end_fallback = len - 1;
197199
}
198200

199-
sub = std::getenv(name.c_str());
200-
if (sub != nullptr)
201+
env_exists = sdk::common::GetStringEnvironmentVariable(name.c_str(), sub);
202+
if (env_exists)
201203
{
202204
return sub;
203205
}

sdk/src/configuration/yaml_configuration_parser.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
#include <cstdlib>
54
#include <exception>
65
#include <fstream>
76
#include <memory>
87
#include <sstream>
98
#include <string>
109
#include <utility>
1110

11+
#include "opentelemetry/sdk/common/env_variables.h"
1212
#include "opentelemetry/sdk/common/global_log_handler.h"
1313
#include "opentelemetry/sdk/configuration/configuration.h"
1414
#include "opentelemetry/sdk/configuration/configuration_parser.h"
@@ -29,8 +29,12 @@ std::unique_ptr<Configuration> YamlConfigurationParser::ParseFile(const std::str
2929

3030
if (input_file.empty())
3131
{
32-
const char *env_var = std::getenv("OTEL_EXPERIMENTAL_CONFIG_FILE");
33-
if (env_var != nullptr)
32+
static std::string env_var_name("OTEL_EXPERIMENTAL_CONFIG_FILE");
33+
std::string env_var;
34+
bool env_exists;
35+
env_exists = sdk::common::GetStringEnvironmentVariable(env_var_name.c_str(), env_var);
36+
37+
if (env_exists)
3438
{
3539
input_file = env_var;
3640
}

0 commit comments

Comments
 (0)