From 5d65ac2371ee00f091dcfe743ba8f7db71dd9553 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Wed, 28 Feb 2024 01:02:43 +0100 Subject: [PATCH] POC - Now starting on metrics --- .../console_metric_exporter_configuration.h | 31 +++ .../extension_metric_exporter_configuration.h | 34 ++++ .../meter_provider_configuration.h | 7 + .../metric_exporter_configuration.h | 26 +++ .../metric_exporter_configuration_visitor.h | 33 ++++ .../metric_reader_configuration.h | 25 +++ .../otlp_metric_exporter_configuration.h | 43 ++++ .../periodic_metric_reader_configuration.h | 31 +++ ...prometheus_metric_exporter_configuration.h | 37 ++++ .../pull_metric_reader_configuration.h | 29 +++ .../sdk/configuration/ryml_document_node.h | 3 - .../sdk/configuration/view_configuration.h | 23 +++ .../configuration/configuration_factory.cc | 186 +++++++++++++++++- sdk/src/configuration/ryml_document_node.cc | 85 -------- 14 files changed, 503 insertions(+), 90 deletions(-) create mode 100644 sdk/include/opentelemetry/sdk/configuration/console_metric_exporter_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/extension_metric_exporter_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/metric_reader_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/otlp_metric_exporter_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/prometheus_metric_exporter_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/pull_metric_reader_configuration.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/view_configuration.h diff --git a/sdk/include/opentelemetry/sdk/configuration/console_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/console_metric_exporter_configuration.h new file mode 100644 index 0000000000..45a1a23e5c --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/console_metric_exporter_configuration.h @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ConsoleMetricExporterConfiguration : public MetricExporterConfiguration +{ +public: + ConsoleMetricExporterConfiguration() = default; + ~ConsoleMetricExporterConfiguration() override = default; + + void Accept(MetricExporterConfigurationVisitor *visitor) const override + { + visitor->VisitConsole(this); + } +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/extension_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/extension_metric_exporter_configuration.h new file mode 100644 index 0000000000..8f7120905b --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/extension_metric_exporter_configuration.h @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/sdk/configuration/document_node.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ExtensionMetricExporterConfiguration : public MetricExporterConfiguration +{ +public: + ExtensionMetricExporterConfiguration() = default; + ~ExtensionMetricExporterConfiguration() override = default; + + void Accept(MetricExporterConfigurationVisitor *visitor) const override + { + visitor->VisitExtension(this); + } + + std::string name; + std::unique_ptr node; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h b/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h index 081e70d3ab..c9fa1ede84 100644 --- a/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h @@ -3,6 +3,11 @@ #pragma once +#include +#include + +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/view_configuration.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -14,6 +19,8 @@ namespace configuration class MeterProviderConfiguration { public: + std::vector> readers; + std::vector> views; }; } // namespace configuration diff --git a/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration.h new file mode 100644 index 0000000000..670da28a7d --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration.h @@ -0,0 +1,26 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ +class MetricExporterConfigurationVisitor; + +class MetricExporterConfiguration +{ +public: + MetricExporterConfiguration() = default; + virtual ~MetricExporterConfiguration() = default; + + virtual void Accept(MetricExporterConfigurationVisitor *visitor) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h b/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h new file mode 100644 index 0000000000..7cb4a593d2 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h @@ -0,0 +1,33 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpMetricExporterConfiguration; +class ConsoleMetricExporterConfiguration; +class PrometheusMetricExporterConfiguration; +class ExtensionMetricExporterConfiguration; + +class MetricExporterConfigurationVisitor +{ +public: + MetricExporterConfigurationVisitor() = default; + virtual ~MetricExporterConfigurationVisitor() = default; + + virtual void VisitOtlp(const OtlpMetricExporterConfiguration *model) = 0; + virtual void VisitConsole(const ConsoleMetricExporterConfiguration *model) = 0; + virtual void VisitPrometheus(const PrometheusMetricExporterConfiguration *model) = 0; + virtual void VisitExtension(const ExtensionMetricExporterConfiguration *model) = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/metric_reader_configuration.h b/sdk/include/opentelemetry/sdk/configuration/metric_reader_configuration.h new file mode 100644 index 0000000000..e47167051f --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/metric_reader_configuration.h @@ -0,0 +1,25 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class MetricReaderConfiguration +{ +public: + MetricReaderConfiguration() = default; + virtual ~MetricReaderConfiguration() = default; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_metric_exporter_configuration.h new file mode 100644 index 0000000000..e9f157334f --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_metric_exporter_configuration.h @@ -0,0 +1,43 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class OtlpMetricExporterConfiguration : public MetricExporterConfiguration +{ +public: + OtlpMetricExporterConfiguration() = default; + ~OtlpMetricExporterConfiguration() override = default; + + void Accept(MetricExporterConfigurationVisitor *visitor) const override + { + visitor->VisitOtlp(this); + } + + std::string protocol; + std::string endpoint; + std::string certificate; + std::string client_key; + std::string client_certificate; + std::unique_ptr headers; + std::string compression; + size_t timeout; + std::string temporality_preference; + int default_histogram_aggregation; // FIXME enum + bool insecure; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h b/sdk/include/opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h new file mode 100644 index 0000000000..e09c5ca431 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class PeriodicMetricReaderConfiguration : public MetricReaderConfiguration +{ +public: + PeriodicMetricReaderConfiguration() = default; + ~PeriodicMetricReaderConfiguration() override = default; + + size_t interval; + size_t timeout; + std::unique_ptr exporter; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/prometheus_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/prometheus_metric_exporter_configuration.h new file mode 100644 index 0000000000..b3fabae67d --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/prometheus_metric_exporter_configuration.h @@ -0,0 +1,37 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class PrometheusMetricExporterConfiguration : public MetricExporterConfiguration +{ +public: + PrometheusMetricExporterConfiguration() = default; + ~PrometheusMetricExporterConfiguration() override = default; + + void Accept(MetricExporterConfigurationVisitor *visitor) const override + { + visitor->VisitPrometheus(this); + } + + std::string host; + size_t port; + bool without_units; + bool without_type_suffix; + bool without_scope_info; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/pull_metric_reader_configuration.h b/sdk/include/opentelemetry/sdk/configuration/pull_metric_reader_configuration.h new file mode 100644 index 0000000000..4f8e5856e6 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/pull_metric_reader_configuration.h @@ -0,0 +1,29 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class PullMetricReaderConfiguration : public MetricReaderConfiguration +{ +public: + PullMetricReaderConfiguration() = default; + ~PullMetricReaderConfiguration() override = default; + + std::unique_ptr exporter; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/ryml_document_node.h b/sdk/include/opentelemetry/sdk/configuration/ryml_document_node.h index 2f1ad01067..a4e0fdb1ff 100644 --- a/sdk/include/opentelemetry/sdk/configuration/ryml_document_node.h +++ b/sdk/include/opentelemetry/sdk/configuration/ryml_document_node.h @@ -55,9 +55,6 @@ class RymlDocumentNode : public DocumentNode ryml::ConstNodeRef GetRequiredRymlChildNode(const std::string &name); ryml::ConstNodeRef GetRymlChildNode(const std::string &name); - std::string GetRequiredRaw(const std::string &name); - std::pair GetRaw(const std::string &name); - ryml::ConstNodeRef m_node; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/view_configuration.h b/sdk/include/opentelemetry/sdk/configuration/view_configuration.h new file mode 100644 index 0000000000..4636c5ac6a --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/view_configuration.h @@ -0,0 +1,23 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +class ViewConfiguration +{ +public: +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/configuration/configuration_factory.cc b/sdk/src/configuration/configuration_factory.cc index ae91afeba4..19c821d1ec 100644 --- a/sdk/src/configuration/configuration_factory.cc +++ b/sdk/src/configuration/configuration_factory.cc @@ -11,21 +11,30 @@ #include "opentelemetry/sdk/configuration/composite_propagator_configuration.h" #include "opentelemetry/sdk/configuration/configuration.h" #include "opentelemetry/sdk/configuration/configuration_factory.h" +#include "opentelemetry/sdk/configuration/console_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" #include "opentelemetry/sdk/configuration/document.h" #include "opentelemetry/sdk/configuration/document_node.h" +#include "opentelemetry/sdk/configuration/extension_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" #include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h" #include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h" #include "opentelemetry/sdk/configuration/invalid_schema_exception.h" #include "opentelemetry/sdk/configuration/jaeger_remote_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/otlp_span_exporter_configuration.h" #include "opentelemetry/sdk/configuration/parent_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/prometheus_metric_exporter_configuration.h" #include "opentelemetry/sdk/configuration/propagator_configuration.h" #include "opentelemetry/sdk/configuration/propagator_configuration_visitor.h" +#include "opentelemetry/sdk/configuration/pull_metric_reader_configuration.h" #include "opentelemetry/sdk/configuration/simple_propagator_configuration.h" #include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h" #include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/view_configuration.h" #include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" #include "opentelemetry/version.h" @@ -56,12 +65,185 @@ static std::unique_ptr ParseLoggerProviderConfigura return model; } -static std::unique_ptr ParseMeterProviderConfiguration( +static std::unique_ptr ParseOtlpMetricExporterConfiguration( + const std::unique_ptr & /* node */) +{ + std::unique_ptr model(new OtlpMetricExporterConfiguration); + + OTEL_INTERNAL_LOG_ERROR("ParseOtlpMetricExporterConfiguration: FIXME"); + + return model; +} + +static std::unique_ptr ParseConsoleMetricExporterConfiguration( + const std::unique_ptr & /* node */) +{ + std::unique_ptr model(new ConsoleMetricExporterConfiguration); + + OTEL_INTERNAL_LOG_ERROR("ParseConsoleMetricExporterConfiguration: FIXME"); + + return model; +} + +static std::unique_ptr +ParsePrometheusMetricExporterConfiguration(const std::unique_ptr & /* node */) +{ + std::unique_ptr model( + new PrometheusMetricExporterConfiguration); + + OTEL_INTERNAL_LOG_ERROR("ParsePrometheusMetricExporterConfiguration: FIXME"); + + return model; +} + +static std::unique_ptr +ParseMetricExporterExtensionConfiguration(const std::string &name, + std::unique_ptr node) +{ + auto extension = new ExtensionMetricExporterConfiguration; + extension->name = name; + extension->node = std::move(node); + std::unique_ptr model(extension); + return model; +} + +static std::unique_ptr ParseMetricExporterConfiguration( + const std::unique_ptr &node) +{ + std::unique_ptr model; + + std::string name; + std::unique_ptr child; + size_t count = 0; + + for (auto it = node->begin_properties(); it != node->end_properties(); ++it) + { + name = it.Name(); + child = it.Value(); + count++; + } + + if (count != 1) + { + OTEL_INTERNAL_LOG_ERROR("ParseMetricExporterConfiguration: count " << count); + throw InvalidSchemaException("Illegal metric exporter"); + } + + if (name == "otlp") + { + model = ParseOtlpMetricExporterConfiguration(child); + } + else if (name == "console") + { + model = ParseConsoleMetricExporterConfiguration(child); + } + else if (name == "prometheus") + { + model = ParsePrometheusMetricExporterConfiguration(child); + } + else + { + model = ParseMetricExporterExtensionConfiguration(name, std::move(child)); + } + + return model; +} + +static std::unique_ptr ParsePeriodicMetricReaderConfiguration( + const std::unique_ptr &node) +{ + std::unique_ptr model(new PeriodicMetricReaderConfiguration); + std::unique_ptr child; + + model->interval = node->GetInteger("interval", 5000); + model->timeout = node->GetInteger("timeout", 30000); + + child = node->GetRequiredChildNode("exporter"); + model->exporter = ParseMetricExporterConfiguration(child); + + return model; +} + +static std::unique_ptr ParsePullMetricReaderConfiguration( + const std::unique_ptr &node) +{ + std::unique_ptr model(new PullMetricReaderConfiguration); + std::unique_ptr child; + + child = node->GetRequiredChildNode("exporter"); + model->exporter = ParseMetricExporterConfiguration(child); + + return model; +} + +static std::unique_ptr ParseMetricReaderConfiguration( + const std::unique_ptr &node) +{ + std::unique_ptr model; + + std::string name; + std::unique_ptr child; + size_t count = 0; + + for (auto it = node->begin_properties(); it != node->end_properties(); ++it) + { + name = it.Name(); + child = it.Value(); + count++; + } + + if (count != 1) + { + OTEL_INTERNAL_LOG_ERROR("ParseMetricReaderConfiguration: count " << count); + throw InvalidSchemaException("Illegal metric reader"); + } + + if (name == "periodic") + { + model = ParsePeriodicMetricReaderConfiguration(child); + } + else if (name == "pull") + { + model = ParsePullMetricReaderConfiguration(child); + } + else + { + OTEL_INTERNAL_LOG_ERROR("ParseMetricReaderConfiguration: name " << name); + throw InvalidSchemaException("Illegal metric reader"); + } + + return model; +} + +static std::unique_ptr ParseViewConfiguration( const std::unique_ptr & /* node */) +{ + std::unique_ptr model(new ViewConfiguration); + + OTEL_INTERNAL_LOG_ERROR("ParseViewConfiguration: FIXME"); + + return model; +} + +static std::unique_ptr ParseMeterProviderConfiguration( + const std::unique_ptr &node) { std::unique_ptr model(new MeterProviderConfiguration); + std::unique_ptr child; - OTEL_INTERNAL_LOG_ERROR("ParseMeterProviderConfiguration: FIXME"); + child = node->GetRequiredChildNode("readers"); + + for (auto it = child->begin(); it != child->end(); ++it) + { + model->readers.push_back(ParseMetricReaderConfiguration(*it)); + } + + child = node->GetRequiredChildNode("views"); + + for (auto it = child->begin(); it != child->end(); ++it) + { + model->views.push_back(ParseViewConfiguration(*it)); + } return model; } diff --git a/sdk/src/configuration/ryml_document_node.cc b/sdk/src/configuration/ryml_document_node.cc index 0fc61dd36a..505757ec72 100644 --- a/sdk/src/configuration/ryml_document_node.cc +++ b/sdk/src/configuration/ryml_document_node.cc @@ -280,91 +280,6 @@ std::string RymlDocumentNode::GetString(const std::string &name, const std::stri return value; } -std::string RymlDocumentNode::GetRequiredRaw(const std::string &name) -{ - OTEL_INTERNAL_LOG_DEBUG("RymlDocumentNode::GetRequiredRaw(" << name << ")"); - - if (!m_node.is_map()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: not a map, looking for " << name); - throw InvalidSchemaException(name); - } - - const char *name_str = name.c_str(); - if (!m_node.has_child(name_str)) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: required node: " << name); - throw InvalidSchemaException(name); - } - - ryml::ConstNodeRef attr = m_node[name_str]; - if (attr.empty()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: empty node: " << name); - throw InvalidSchemaException(name); - } - - if (!attr.has_val()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: no value node: " << name); - throw InvalidSchemaException(name); - } - - ryml::csubstr view = attr.val(); - if (view.len == 0) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: 0 length node: " << name); - throw InvalidSchemaException(name); - } - - std::string value(view.str, view.len); - return value; -} - -std::pair RymlDocumentNode::GetRaw(const std::string &name) -{ - OTEL_INTERNAL_LOG_DEBUG("RymlDocumentNode::GetRaw(" << name << ")"); - - std::pair result{false, ""}; - - if (!m_node.is_map()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: not a map, looking for " << name); - throw InvalidSchemaException(name); - } - - const char *name_str = name.c_str(); - if (!m_node.has_child(name_str)) - { - return result; - } - - ryml::ConstNodeRef attr = m_node[name_str]; - if (attr.empty()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: empty node: " << name); - throw InvalidSchemaException(name); - } - - if (!attr.has_val()) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: no value node: " << name); - throw InvalidSchemaException(name); - } - - ryml::csubstr view = attr.val(); - if (view.len == 0) - { - OTEL_INTERNAL_LOG_ERROR("Yaml: 0 length node: " << name); - throw InvalidSchemaException(name); - } - - std::string value(view.str, view.len); - result.first = true; - result.second = value; - return result; -} - DocumentNodeConstIterator RymlDocumentNode::begin() const { OTEL_INTERNAL_LOG_DEBUG("RymlDocumentNode::begin()");