Skip to content

Commit 182fbb2

Browse files
committed
Cleanup, continued.
1 parent 1576f56 commit 182fbb2

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

sdk/src/configuration/configuration_factory.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ static std::unique_ptr<AlwaysOnSamplerConfiguration> ParseAlwaysOnSamplerConfigu
974974
return model;
975975
}
976976

977+
// NOLINTBEGIN(misc-no-recursion)
977978
static std::unique_ptr<JaegerRemoteSamplerConfiguration> ParseJaegerRemoteSamplerConfiguration(
978979
const std::unique_ptr<DocumentNode> &node,
979980
size_t depth)
@@ -995,7 +996,9 @@ static std::unique_ptr<JaegerRemoteSamplerConfiguration> ParseJaegerRemoteSample
995996

996997
return model;
997998
}
999+
// NOLINTEND(misc-no-recursion)
9981000

1001+
// NOLINTBEGIN(misc-no-recursion)
9991002
static std::unique_ptr<ParentBasedSamplerConfiguration> ParseParentBasedSamplerConfiguration(
10001003
const std::unique_ptr<DocumentNode> &node,
10011004
size_t depth)
@@ -1035,6 +1038,7 @@ static std::unique_ptr<ParentBasedSamplerConfiguration> ParseParentBasedSamplerC
10351038

10361039
return model;
10371040
}
1041+
// NOLINTEND(misc-no-recursion)
10381042

10391043
static std::unique_ptr<TraceIdRatioBasedSamplerConfiguration>
10401044
ParseTraceIdRatioBasedSamplerConfiguration(const std::unique_ptr<DocumentNode> &node,
@@ -1061,6 +1065,7 @@ static std::unique_ptr<ExtensionSamplerConfiguration> ParseSamplerExtensionConfi
10611065
return model;
10621066
}
10631067

1068+
// NOLINTBEGIN(misc-no-recursion)
10641069
static std::unique_ptr<SamplerConfiguration> ParseSamplerConfiguration(
10651070
const std::unique_ptr<DocumentNode> &node,
10661071
size_t depth)
@@ -1121,6 +1126,7 @@ static std::unique_ptr<SamplerConfiguration> ParseSamplerConfiguration(
11211126

11221127
return model;
11231128
}
1129+
// NOLINTEND(misc-no-recursion)
11241130

11251131
static std::unique_ptr<OtlpHttpSpanExporterConfiguration> ParseOtlpHttpSpanExporterConfiguration(
11261132
const std::unique_ptr<DocumentNode> &node)

sdk/src/configuration/document_node.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ std::string DocumentNode::DoSubstitution(const std::string &text)
9191
*/
9292
std::string DocumentNode::DoOneSubstitution(const std::string &text)
9393
{
94+
static std::string illegal_msg{"Illegal substitution expression"};
95+
9496
static std::string env_token{"env:"};
9597
static std::string env_with_replacement{"env:-"};
9698
static std::string replacement_token{":-"};
@@ -108,25 +110,29 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
108110

109111
if (len < 4)
110112
{
111-
goto illegal;
113+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
114+
throw InvalidSchemaException(illegal_msg);
112115
}
113116

114117
c = text[0];
115118
if (c != '$')
116119
{
117-
goto illegal;
120+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
121+
throw InvalidSchemaException(illegal_msg);
118122
}
119123

120124
c = text[1];
121125
if (c != '{')
122126
{
123-
goto illegal;
127+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
128+
throw InvalidSchemaException(illegal_msg);
124129
}
125130

126131
c = text[len - 1];
127132
if (c != '}')
128133
{
129-
goto illegal;
134+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
135+
throw InvalidSchemaException(illegal_msg);
130136
}
131137

132138
begin_name = 2;
@@ -148,7 +154,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
148154
c = text[begin_name];
149155
if (!std::isalpha(c) && c != '_')
150156
{
151-
goto illegal;
157+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
158+
throw InvalidSchemaException(illegal_msg);
152159
}
153160

154161
end_name = begin_name + 1;
@@ -181,7 +188,8 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
181188
pos = text.find(replacement_token, end_name);
182189
if (pos != end_name)
183190
{
184-
goto illegal;
191+
OTEL_INTERNAL_LOG_ERROR(illegal_msg << ": " << text);
192+
throw InvalidSchemaException(illegal_msg);
185193
}
186194
// text is of the form ${ENV_NAME:-fallback}
187195
begin_fallback = pos + replacement_token.length();
@@ -203,10 +211,6 @@ std::string DocumentNode::DoOneSubstitution(const std::string &text)
203211
fallback = "";
204212
}
205213
return fallback;
206-
207-
illegal:
208-
OTEL_INTERNAL_LOG_ERROR("Illegal substitution expression: " << text);
209-
throw InvalidSchemaException("Illegal substitution expression");
210214
}
211215

212216
bool DocumentNode::BooleanFromString(const std::string &value)

sdk/src/init/configured_sdk.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <exception>
55
#include <memory>
66
#include <ostream>
7+
#include <utility>
78

89
#include "opentelemetry/logs/logger_provider.h"
910
#include "opentelemetry/logs/provider.h"

0 commit comments

Comments
 (0)