Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Work around for ryml
{ "include": ["<c4/std/string.hpp>", "private", "<ryml_std.hpp>", "public"] },

{ "include": ["<c4/yml/common.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/node.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/parse.hpp>", "private", "<ryml.hpp>", "public"] },
{ "include": ["<c4/yml/parse_engine.hpp>", "private", "<ryml.hpp>", "public"] },
Expand Down
2 changes: 1 addition & 1 deletion functional/configuration/shelltests/empty.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

$ example_yaml --test --yaml shelltests/empty.yaml
>
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Yaml: not a map, looking for: file_format
[ERROR] <shelltests/empty.yaml>:0[0](0): Yaml: not a map, looking for: file_format
FAILED TO PARSE MODEL
>= 1
2 changes: 1 addition & 1 deletion functional/configuration/shelltests/format_empty.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

$ example_yaml --test --yaml shelltests/format_empty.yaml
>
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Yaml: string value is empty: file_format
[ERROR] <shelltests/format_empty.yaml>:4[0](94): Yaml: string value is empty: file_format
FAILED TO PARSE MODEL
>= 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

$ example_yaml --test --yaml shelltests/propagator_broken.yaml
>
[ERROR] [Yaml Configuration Parser] Parse failed with exception: Illegal composite child 2, properties count: 3
[ERROR] <shelltests/propagator_broken.yaml>:10[6](206): Illegal composite child 2, properties count: 3
FAILED TO PARSE MODEL
>= 1
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ namespace configuration
class ConfigurationParser
{
public:
OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name) const;
OtlpHttpEncoding ParseOtlpHttpEncoding(const std::unique_ptr<DocumentNode> &node,
const std::string &name) const;

std::unique_ptr<StringArrayConfiguration> ParseStringArrayConfiguration(
const std::unique_ptr<DocumentNode> &node) const;
Expand Down Expand Up @@ -151,9 +152,12 @@ class ConfigurationParser
std::unique_ptr<LoggerProviderConfiguration> ParseLoggerProviderConfiguration(
const std::unique_ptr<DocumentNode> &node) const;

DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name) const;
DefaultHistogramAggregation ParseDefaultHistogramAggregation(
const std::unique_ptr<DocumentNode> &node,
const std::string &name) const;

TemporalityPreference ParseTemporalityPreference(const std::string &name) const;
TemporalityPreference ParseTemporalityPreference(const std::unique_ptr<DocumentNode> &node,
const std::string &name) const;

std::unique_ptr<OtlpHttpPushMetricExporterConfiguration>
ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr<DocumentNode> &node) const;
Expand Down Expand Up @@ -203,7 +207,8 @@ class ConfigurationParser
std::unique_ptr<MetricReaderConfiguration> ParseMetricReaderConfiguration(
const std::unique_ptr<DocumentNode> &node) const;

InstrumentType ParseInstrumentType(const std::string &name) const;
InstrumentType ParseInstrumentType(const std::unique_ptr<DocumentNode> &node,
const std::string &name) const;

std::unique_ptr<ViewSelectorConfiguration> ParseViewSelectorConfiguration(
const std::unique_ptr<DocumentNode> &node) const;
Expand Down
14 changes: 14 additions & 0 deletions sdk/include/opentelemetry/sdk/configuration/document_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace configuration

class DocumentNodeConstIterator;
class PropertiesNodeConstIterator;
class DocumentNodeLocation;

class DocumentNode
{
Expand All @@ -30,6 +31,8 @@ class DocumentNode
DocumentNode &operator=(const DocumentNode &other) = default;
virtual ~DocumentNode() = default;

virtual DocumentNodeLocation Location() const = 0;

virtual std::string Key() const = 0;

virtual bool AsBoolean() const = 0;
Expand Down Expand Up @@ -172,6 +175,17 @@ class PropertiesNodeConstIterator
std::unique_ptr<PropertiesNodeConstIteratorImpl> impl_;
};

class DocumentNodeLocation
{
public:
size_t offset;
size_t line;
size_t col;
std::string filename;

std::string ToString() const;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ namespace configuration
class InvalidSchemaException : public std::runtime_error
{
public:
InvalidSchemaException(const std::string &msg) : std::runtime_error(msg) {}
InvalidSchemaException(const DocumentNodeLocation &location, const std::string &msg)
: std::runtime_error(msg), location_(location)
{}

std::string Where() const { return location_.ToString(); }

private:
DocumentNodeLocation location_;
};

} // namespace configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ class RymlDocument : public Document
public:
static std::unique_ptr<Document> Parse(const std::string &source, const std::string &content);

RymlDocument(ryml::Tree tree) : tree_(std::move(tree)) {}
RymlDocument() {}
RymlDocument(RymlDocument &&) = delete;
RymlDocument(const RymlDocument &) = delete;
RymlDocument &operator=(RymlDocument &&) = delete;
RymlDocument &operator=(const RymlDocument &other) = delete;
~RymlDocument() override = default;

int ParseDocument(const std::string &source, const std::string &content);

std::unique_ptr<DocumentNode> GetRootNode() override;

DocumentNodeLocation Location(ryml::ConstNodeRef node) const;

private:
ryml::ParserOptions opts_;
ryml::Parser::handler_type event_handler_;
std::unique_ptr<ryml::Parser> parser_;
ryml::Tree tree_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ namespace sdk
namespace configuration
{

class RymlDocument;

class RymlDocumentNode : public DocumentNode
{
public:
RymlDocumentNode(ryml::ConstNodeRef node, std::size_t depth) : node_(node), depth_(depth) {}
RymlDocumentNode(const RymlDocument *doc, ryml::ConstNodeRef node, std::size_t depth)
: doc_(doc), node_(node), depth_(depth)
{}
RymlDocumentNode(RymlDocumentNode &&) = delete;
RymlDocumentNode(const RymlDocumentNode &) = delete;
RymlDocumentNode &operator=(RymlDocumentNode &&) = delete;
RymlDocumentNode &operator=(const RymlDocumentNode &other) = delete;
~RymlDocumentNode() override = default;

DocumentNodeLocation Location() const override;

std::string Key() const override;

bool AsBoolean() const override;
Expand Down Expand Up @@ -62,14 +68,16 @@ class RymlDocumentNode : public DocumentNode
ryml::ConstNodeRef GetRequiredRymlChildNode(const std::string &name) const;
ryml::ConstNodeRef GetRymlChildNode(const std::string &name) const;

const RymlDocument *doc_;
ryml::ConstNodeRef node_;
std::size_t depth_;
};

class RymlDocumentNodeConstIteratorImpl : public DocumentNodeConstIteratorImpl
{
public:
RymlDocumentNodeConstIteratorImpl(ryml::ConstNodeRef parent,
RymlDocumentNodeConstIteratorImpl(const RymlDocument *doc,
ryml::ConstNodeRef parent,
std::size_t index,
std::size_t depth);
RymlDocumentNodeConstIteratorImpl(RymlDocumentNodeConstIteratorImpl &&) = delete;
Expand All @@ -84,6 +92,7 @@ class RymlDocumentNodeConstIteratorImpl : public DocumentNodeConstIteratorImpl
bool Equal(const DocumentNodeConstIteratorImpl *rhs) const override;

private:
const RymlDocument *doc_;
ryml::ConstNodeRef parent_;
std::size_t index_;
std::size_t depth_;
Expand All @@ -92,7 +101,8 @@ class RymlDocumentNodeConstIteratorImpl : public DocumentNodeConstIteratorImpl
class RymlPropertiesNodeConstIteratorImpl : public PropertiesNodeConstIteratorImpl
{
public:
RymlPropertiesNodeConstIteratorImpl(ryml::ConstNodeRef parent,
RymlPropertiesNodeConstIteratorImpl(const RymlDocument *doc,
ryml::ConstNodeRef parent,
std::size_t index,
std::size_t depth);
RymlPropertiesNodeConstIteratorImpl(RymlPropertiesNodeConstIteratorImpl &&) = delete;
Expand All @@ -108,6 +118,7 @@ class RymlPropertiesNodeConstIteratorImpl : public PropertiesNodeConstIteratorIm
bool Equal(const PropertiesNodeConstIteratorImpl *rhs) const override;

private:
const RymlDocument *doc_;
ryml::ConstNodeRef parent_;
std::size_t index_;
std::size_t depth_;
Expand Down
Loading
Loading