Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Feb 7, 2024
1 parent 9d12c76 commit 083e9f1
Show file tree
Hide file tree
Showing 30 changed files with 99 additions and 18 deletions.
4 changes: 3 additions & 1 deletion examples/yaml/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ void InitOtel()
std::string config_file = "config.yaml";
auto model = opentelemetry::sdk::configuration::ConfigurationFactory::ParseFile(config_file);

/* 5 - Build the SDL from the parsed a config.yaml */
/* 5 - Build the SDK from the parsed config.yaml */

sdk = opentelemetry::sdk::init::ConfiguredSdk::Create(registry, model);

/* 6 - Deploy the SDK */

if (sdk != nullptr)
{
sdk->Install();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ class OPENTELEMETRY_EXPORT ConsoleBuilder
public:
static void Register(opentelemetry::sdk::init::Registry *registry);

ConsoleBuilder() = default;
~ConsoleBuilder() override = default;

std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) const override;
const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model)
const override;
};

} // namespace otlp
} // namespace trace
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ namespace exporter
namespace otlp
{

class OPENTELEMETRY_EXPORT OtlpBuilder
: public opentelemetry::sdk::init::OtlpSpanExporterBuilder
class OPENTELEMETRY_EXPORT OtlpBuilder : public opentelemetry::sdk::init::OtlpSpanExporterBuilder
{
public:
static void Register(opentelemetry::sdk::init::Registry *registry);

OtlpBuilder() = default;
~OtlpBuilder() override = default;

std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::OtlpSpanExporterConfiguration *model) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <memory>

#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h"
#include "opentelemetry/sdk/init/zipkin_span_exporter_builder.h"
#include "opentelemetry/sdk/init/registry.h"
#include "opentelemetry/sdk/init/zipkin_span_exporter_builder.h"
#include "opentelemetry/sdk/trace/exporter.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -22,10 +22,14 @@ class OPENTELEMETRY_EXPORT ZipkinBuilder
public:
static void Register(opentelemetry::sdk::init::Registry *registry);

ZipkinBuilder() = default;
~ZipkinBuilder() override = default;

std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const override;
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model)
const override;
};

} // namespace otlp
} // namespace zipkin
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class AlwaysOffSamplerConfiguration : public SamplerConfiguration
{
public:
AlwaysOffSamplerConfiguration() = default;
~AlwaysOffSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
visitor->VisitAlwaysOff(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class AlwaysOnSamplerConfiguration : public SamplerConfiguration
{
public:
AlwaysOnSamplerConfiguration() = default;
~AlwaysOnSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override { visitor->VisitAlwaysOn(this); }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class BatchSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
BatchSpanProcessorConfiguration() = default;
~BatchSpanProcessorConfiguration() override = default;

void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitBatch(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class ConsoleSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
ConsoleSpanExporterConfiguration() = default;
~ConsoleSpanExporterConfiguration() override = default;

void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitConsole(this);
Expand Down
3 changes: 3 additions & 0 deletions sdk/include/opentelemetry/sdk/configuration/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class Document
{
public:
Document() = default;
virtual ~Document() = default;

virtual std::unique_ptr<DocumentNode> GetRootNode() = 0;
};

Expand Down
12 changes: 6 additions & 6 deletions sdk/include/opentelemetry/sdk/configuration/document_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class PropertiesNodeConstIterator;
class DocumentNode
{
public:
DocumentNode() {}
virtual ~DocumentNode() {}
DocumentNode() = default;
virtual ~DocumentNode() = default;

virtual bool AsBoolean() = 0;
virtual size_t AsInteger() = 0;
Expand Down Expand Up @@ -60,8 +60,8 @@ class DocumentNode
class DocumentNodeConstIteratorImpl
{
public:
DocumentNodeConstIteratorImpl() {}
virtual ~DocumentNodeConstIteratorImpl() {}
DocumentNodeConstIteratorImpl() = default;
virtual ~DocumentNodeConstIteratorImpl() = default;

virtual void Next() = 0;
virtual std::unique_ptr<DocumentNode> Item() const = 0;
Expand All @@ -71,8 +71,8 @@ class DocumentNodeConstIteratorImpl
class PropertiesNodeConstIteratorImpl
{
public:
PropertiesNodeConstIteratorImpl() {}
virtual ~PropertiesNodeConstIteratorImpl() {}
PropertiesNodeConstIteratorImpl() = default;
virtual ~PropertiesNodeConstIteratorImpl() = default;

virtual void Next() = 0;
virtual std::string Name() const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class ExtensionSamplerConfiguration : public SamplerConfiguration
{
public:
ExtensionSamplerConfiguration() = default;
~ExtensionSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
visitor->VisitExtension(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class ExtensionSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
ExtensionSpanExporterConfiguration() = default;
~ExtensionSpanExporterConfiguration() override = default;

void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitExtension(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class ExtensionSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
ExtensionSpanProcessorConfiguration() = default;
~ExtensionSpanProcessorConfiguration() override = default;

void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitExtension(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class JaegerRemoteSamplerConfiguration : public SamplerConfiguration
{
public:
JaegerRemoteSamplerConfiguration() = default;
~JaegerRemoteSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
visitor->VisitJaegerRemote(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace configuration
class OtlpSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
OtlpSpanExporterConfiguration() = default;
virtual ~OtlpSpanExporterConfiguration() = default;

void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitOtlp(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class ParentBasedSamplerConfiguration : public SamplerConfiguration
{
public:
ParentBasedSamplerConfiguration() = default;
~ParentBasedSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
visitor->VisitParentBased(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class SamplerConfigurationVisitor;
class SamplerConfiguration
{
public:
SamplerConfiguration() = default;
virtual ~SamplerConfiguration() = default;

virtual void Accept(SamplerConfigurationVisitor *visitor) const = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class ExtensionSamplerConfiguration;
class SamplerConfigurationVisitor
{
public:
SamplerConfigurationVisitor() = default;
virtual ~SamplerConfigurationVisitor() = default;

virtual void VisitAlwaysOff(const AlwaysOffSamplerConfiguration *model) = 0;
virtual void VisitAlwaysOn(const AlwaysOnSamplerConfiguration *model) = 0;
virtual void VisitJaegerRemote(const JaegerRemoteSamplerConfiguration *model) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class SimpleSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
SimpleSpanProcessorConfiguration() = default;
~SimpleSpanProcessorConfiguration() override = default;

void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitSimple(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class SpanExporterConfigurationVisitor;
class SpanExporterConfiguration
{
public:
SpanExporterConfiguration() = default;
virtual ~SpanExporterConfiguration() = default;

virtual void Accept(SpanExporterConfigurationVisitor *visitor) const = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ class ExtensionSpanExporterConfiguration;
class SpanExporterConfigurationVisitor
{
public:
SpanExporterConfigurationVisitor() = default;
virtual ~SpanExporterConfigurationVisitor() = default;

virtual void VisitOtlp(const OtlpSpanExporterConfiguration *model) = 0;
virtual void VisitConsole(const ConsoleSpanExporterConfiguration *model) = 0;
virtual void VisitConsole(const ConsoleSpanExporterConfiguration *model) = 0;
virtual void VisitZipkin(const ZipkinSpanExporterConfiguration *model) = 0;
virtual void VisitExtension(const ExtensionSpanExporterConfiguration *model) = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class SpanProcessorConfigurationVisitor;
class SpanProcessorConfiguration
{
public:
SpanProcessorConfiguration() = default;
virtual ~SpanProcessorConfiguration() = default;

virtual void Accept(SpanProcessorConfigurationVisitor *visitor) const = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ExtensionSpanProcessorConfiguration;
class SpanProcessorConfigurationVisitor
{
public:
SpanProcessorConfigurationVisitor() = default;
virtual ~SpanProcessorConfigurationVisitor() = default;

virtual void VisitBatch(const BatchSpanProcessorConfiguration *model) = 0;
virtual void VisitSimple(const SimpleSpanProcessorConfiguration *model) = 0;
virtual void VisitExtension(const ExtensionSpanProcessorConfiguration *model) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class TraceIdRatioBasedSamplerConfiguration : public SamplerConfiguration
{
public:
TraceIdRatioBasedSamplerConfiguration() = default;
~TraceIdRatioBasedSamplerConfiguration() override = default;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
visitor->VisitTraceIdRatioBased(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class YamlDocument : public Document
static std::unique_ptr<Document> Parse(std::istream &in);

YamlDocument(YAML::Node root) : m_root(root) {}
~YamlDocument() = default;
~YamlDocument() override = default;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class YamlDocumentNodeConstIteratorImpl : public DocumentNodeConstIteratorImpl
{
public:
YamlDocumentNodeConstIteratorImpl(const YAML::const_iterator &iter);
virtual ~YamlDocumentNodeConstIteratorImpl();
~YamlDocumentNodeConstIteratorImpl() override;

void Next() override;
std::unique_ptr<DocumentNode> Item() const override;
Expand All @@ -75,7 +75,7 @@ class YamlPropertiesNodeConstIteratorImpl : public PropertiesNodeConstIteratorIm
{
public:
YamlPropertiesNodeConstIteratorImpl(const YAML::const_iterator &iter);
virtual ~YamlPropertiesNodeConstIteratorImpl();
~YamlPropertiesNodeConstIteratorImpl() override;

void Next() override;
std::string Name() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace configuration
class ZipkinSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
ZipkinSpanExporterConfiguration() = default;
~ZipkinSpanExporterConfiguration() override = default;

void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitZipkin(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace init
class ConsoleSpanExporterBuilder
{
public:
ConsoleSpanExporterBuilder() = default;
virtual ~ConsoleSpanExporterBuilder() = default;

virtual std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::ConsoleSpanExporterConfiguration *model) const = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace init
class OtlpSpanExporterBuilder
{
public:
OtlpSpanExporterBuilder() = default;
virtual ~OtlpSpanExporterBuilder() = default;

virtual std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::OtlpSpanExporterConfiguration *model) const = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace init
class ZipkinSpanExporterBuilder
{
public:
ZipkinSpanExporterBuilder() = default;
virtual ~ZipkinSpanExporterBuilder() = default;

virtual std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Build(
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const = 0;
};
Expand Down

0 comments on commit 083e9f1

Please sign in to comment.