Skip to content

Commit 740d843

Browse files
committed
merged from upstream
2 parents 81429c4 + 755411e commit 740d843

File tree

14 files changed

+195
-99
lines changed

14 files changed

+195
-99
lines changed

.iwyu.imp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Work around for ryml
1515
{ "include": ["<c4/std/string.hpp>", "private", "<ryml_std.hpp>", "public"] },
1616

17+
{ "include": ["<c4/yml/common.hpp>", "private", "<ryml.hpp>", "public"] },
1718
{ "include": ["<c4/yml/node.hpp>", "private", "<ryml.hpp>", "public"] },
1819
{ "include": ["<c4/yml/parse.hpp>", "private", "<ryml.hpp>", "public"] },
1920
{ "include": ["<c4/yml/parse_engine.hpp>", "private", "<ryml.hpp>", "public"] },

functional/configuration/shelltests/empty.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
$ example_yaml --test --yaml shelltests/empty.yaml
55
>
6-
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Yaml: not a map, looking for: file_format
6+
[ERROR] <shelltests/empty.yaml>:0[0](0): Yaml: not a map, looking for: file_format
77
FAILED TO PARSE MODEL
88
>= 1

functional/configuration/shelltests/format_empty.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
$ example_yaml --test --yaml shelltests/format_empty.yaml
55
>
6-
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Yaml: string value is empty: file_format
6+
[ERROR] <shelltests/format_empty.yaml>:4[0](94): Yaml: string value is empty: file_format
77
FAILED TO PARSE MODEL
88
>= 1

functional/configuration/shelltests/propagator_broken.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
$ example_yaml --test --yaml shelltests/propagator_broken.yaml
55
>
6-
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Illegal composite child 2, properties count: 3
6+
[ERROR] <shelltests/propagator_broken.yaml>:10[6](206): Illegal composite child 2, properties count: 3
77
FAILED TO PARSE MODEL
88
>= 1

sdk/include/opentelemetry/sdk/configuration/configuration_parser.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ namespace configuration
100100
class OPENTELEMETRY_EXPORT_TYPE ConfigurationParser
101101
{
102102
public:
103-
OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name) const;
103+
OtlpHttpEncoding ParseOtlpHttpEncoding(const std::unique_ptr<DocumentNode> &node,
104+
const std::string &name) const;
104105

105106
std::unique_ptr<StringArrayConfiguration> ParseStringArrayConfiguration(
106107
const std::unique_ptr<DocumentNode> &node) const;
@@ -152,9 +153,12 @@ class OPENTELEMETRY_EXPORT_TYPE ConfigurationParser
152153
std::unique_ptr<LoggerProviderConfiguration> ParseLoggerProviderConfiguration(
153154
const std::unique_ptr<DocumentNode> &node) const;
154155

155-
DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name) const;
156+
DefaultHistogramAggregation ParseDefaultHistogramAggregation(
157+
const std::unique_ptr<DocumentNode> &node,
158+
const std::string &name) const;
156159

157-
TemporalityPreference ParseTemporalityPreference(const std::string &name) const;
160+
TemporalityPreference ParseTemporalityPreference(const std::unique_ptr<DocumentNode> &node,
161+
const std::string &name) const;
158162

159163
std::unique_ptr<OtlpHttpPushMetricExporterConfiguration>
160164
ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr<DocumentNode> &node) const;
@@ -204,7 +208,8 @@ class OPENTELEMETRY_EXPORT_TYPE ConfigurationParser
204208
std::unique_ptr<MetricReaderConfiguration> ParseMetricReaderConfiguration(
205209
const std::unique_ptr<DocumentNode> &node) const;
206210

207-
InstrumentType ParseInstrumentType(const std::string &name) const;
211+
InstrumentType ParseInstrumentType(const std::unique_ptr<DocumentNode> &node,
212+
const std::string &name) const;
208213

209214
std::unique_ptr<ViewSelectorConfiguration> ParseViewSelectorConfiguration(
210215
const std::unique_ptr<DocumentNode> &node) const;

sdk/include/opentelemetry/sdk/configuration/document_node.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace configuration
1616

1717
class DocumentNodeConstIterator;
1818
class PropertiesNodeConstIterator;
19+
class DocumentNodeLocation;
1920

2021
class DocumentNode
2122
{
@@ -30,6 +31,8 @@ class DocumentNode
3031
DocumentNode &operator=(const DocumentNode &other) = default;
3132
virtual ~DocumentNode() = default;
3233

34+
virtual DocumentNodeLocation Location() const = 0;
35+
3336
virtual std::string Key() const = 0;
3437

3538
virtual bool AsBoolean() const = 0;
@@ -172,6 +175,17 @@ class PropertiesNodeConstIterator
172175
std::unique_ptr<PropertiesNodeConstIteratorImpl> impl_;
173176
};
174177

178+
class DocumentNodeLocation
179+
{
180+
public:
181+
size_t offset;
182+
size_t line;
183+
size_t col;
184+
std::string filename;
185+
186+
std::string ToString() const;
187+
};
188+
175189
} // namespace configuration
176190
} // namespace sdk
177191
OPENTELEMETRY_END_NAMESPACE

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ namespace configuration
1919
class InvalidSchemaException : public std::runtime_error
2020
{
2121
public:
22-
InvalidSchemaException(const std::string &msg) : std::runtime_error(msg) {}
22+
InvalidSchemaException(const DocumentNodeLocation &location, const std::string &msg)
23+
: std::runtime_error(msg), location_(location)
24+
{}
25+
26+
std::string Where() const { return location_.ToString(); }
27+
28+
private:
29+
DocumentNodeLocation location_;
2330
};
2431

2532
} // namespace configuration

sdk/include/opentelemetry/sdk/configuration/ryml_document.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ class OPENTELEMETRY_EXPORT_TYPE RymlDocument : public Document
2222
public:
2323
static std::unique_ptr<Document> Parse(const std::string &source, const std::string &content);
2424

25-
RymlDocument(ryml::Tree tree) : tree_(std::move(tree)) {}
25+
RymlDocument() {}
2626
RymlDocument(RymlDocument &&) = delete;
2727
RymlDocument(const RymlDocument &) = delete;
2828
RymlDocument &operator=(RymlDocument &&) = delete;
2929
RymlDocument &operator=(const RymlDocument &other) = delete;
3030
~RymlDocument() override = default;
3131

32+
int ParseDocument(const std::string &source, const std::string &content);
33+
3234
std::unique_ptr<DocumentNode> GetRootNode() override;
3335

36+
DocumentNodeLocation Location(ryml::ConstNodeRef node) const;
37+
3438
private:
39+
ryml::ParserOptions opts_;
40+
ryml::Parser::handler_type event_handler_;
41+
std::unique_ptr<ryml::Parser> parser_;
3542
ryml::Tree tree_;
3643
};
3744

sdk/include/opentelemetry/sdk/configuration/ryml_document_node.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ namespace configuration
2020
class OPENTELEMETRY_EXPORT_TYPE RymlDocumentNode : public DocumentNode
2121
{
2222
public:
23-
RymlDocumentNode(ryml::ConstNodeRef node, std::size_t depth) : node_(node), depth_(depth) {}
23+
RymlDocumentNode(const RymlDocument *doc, ryml::ConstNodeRef node, std::size_t depth)
24+
: doc_(doc), node_(node), depth_(depth)
25+
{}
2426
RymlDocumentNode(RymlDocumentNode &&) = delete;
2527
RymlDocumentNode(const RymlDocumentNode &) = delete;
2628
RymlDocumentNode &operator=(RymlDocumentNode &&) = delete;
2729
RymlDocumentNode &operator=(const RymlDocumentNode &other) = delete;
2830
~RymlDocumentNode() override = default;
2931

32+
DocumentNodeLocation Location() const override;
33+
3034
std::string Key() const override;
3135

3236
bool AsBoolean() const override;
@@ -62,14 +66,16 @@ class OPENTELEMETRY_EXPORT_TYPE RymlDocumentNode : public DocumentNode
6266
ryml::ConstNodeRef GetRequiredRymlChildNode(const std::string &name) const;
6367
ryml::ConstNodeRef GetRymlChildNode(const std::string &name) const;
6468

69+
const RymlDocument *doc_;
6570
ryml::ConstNodeRef node_;
6671
std::size_t depth_;
6772
};
6873

6974
class OPENTELEMETRY_EXPORT_TYPE RymlDocumentNodeConstIteratorImpl : public DocumentNodeConstIteratorImpl
7075
{
7176
public:
72-
RymlDocumentNodeConstIteratorImpl(ryml::ConstNodeRef parent,
77+
RymlDocumentNodeConstIteratorImpl(const RymlDocument *doc,
78+
ryml::ConstNodeRef parent,
7379
std::size_t index,
7480
std::size_t depth);
7581
RymlDocumentNodeConstIteratorImpl(RymlDocumentNodeConstIteratorImpl &&) = delete;
@@ -84,6 +90,7 @@ class OPENTELEMETRY_EXPORT_TYPE RymlDocumentNodeConstIteratorImpl : public Docum
8490
bool Equal(const DocumentNodeConstIteratorImpl *rhs) const override;
8591

8692
private:
93+
const RymlDocument *doc_;
8794
ryml::ConstNodeRef parent_;
8895
std::size_t index_;
8996
std::size_t depth_;
@@ -92,7 +99,8 @@ class OPENTELEMETRY_EXPORT_TYPE RymlDocumentNodeConstIteratorImpl : public Docum
9299
class OPENTELEMETRY_EXPORT_TYPE RymlPropertiesNodeConstIteratorImpl : public PropertiesNodeConstIteratorImpl
93100
{
94101
public:
95-
RymlPropertiesNodeConstIteratorImpl(ryml::ConstNodeRef parent,
102+
RymlPropertiesNodeConstIteratorImpl(const RymlDocument *doc,
103+
ryml::ConstNodeRef parent,
96104
std::size_t index,
97105
std::size_t depth);
98106
RymlPropertiesNodeConstIteratorImpl(RymlPropertiesNodeConstIteratorImpl &&) = delete;
@@ -108,6 +116,7 @@ class OPENTELEMETRY_EXPORT_TYPE RymlPropertiesNodeConstIteratorImpl : public Pro
108116
bool Equal(const PropertiesNodeConstIteratorImpl *rhs) const override;
109117

110118
private:
119+
const RymlDocument *doc_;
111120
ryml::ConstNodeRef parent_;
112121
std::size_t index_;
113122
std::size_t depth_;

0 commit comments

Comments
 (0)