Skip to content

Commit

Permalink
POC
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Feb 1, 2024
1 parent 90e6418 commit 469bc0e
Show file tree
Hide file tree
Showing 13 changed files with 323 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "opentelemetry/sdk/configuration/span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -16,6 +17,11 @@ namespace configuration
class BatchSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitBatch(this);
}

size_t schedule_delay;
size_t export_timeout;
size_t max_queue_size;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/sdk/configuration/document_node.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class ExtensionSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitExtension(this);
}

std::string name;
std::unique_ptr<DocumentNode> node;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/sdk/configuration/document_node.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class ExtensionSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitExtension(this);
}

std::string name;
std::unique_ptr<DocumentNode> node;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "opentelemetry/sdk/configuration/headers_configuration.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -16,6 +17,11 @@ namespace configuration
class OtlpSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitOtlp(this);
}

std::string protocol;
std::string endpoint;
std::string certificate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "opentelemetry/sdk/configuration/span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -15,6 +16,11 @@ namespace configuration
class SimpleSpanProcessorConfiguration : public SpanProcessorConfiguration
{
public:
void Accept(SpanProcessorConfigurationVisitor *visitor) const override
{
visitor->VisitSimple(this);
}

std::unique_ptr<SpanExporterConfiguration> exporter;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ namespace sdk
{
namespace configuration
{
class SpanExporterConfigurationVisitor;

class SpanExporterConfiguration
{
public:
virtual void Accept(SpanExporterConfigurationVisitor *visitor) const = 0;
};

} // namespace configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class OtlpSpanExporterConfiguration;
class ZipkinSpanExporterConfiguration;
class ExtensionSpanExporterConfiguration;

class SpanExporterConfigurationVisitor
{
public:
virtual void VisitOtlp(const OtlpSpanExporterConfiguration *model) = 0;
virtual void VisitZipkin(const ZipkinSpanExporterConfiguration *model) = 0;
virtual void VisitExtension(const ExtensionSpanExporterConfiguration *model) = 0;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ namespace sdk
{
namespace configuration
{
class SpanProcessorConfigurationVisitor;

class SpanProcessorConfiguration
{
public:
virtual void Accept(SpanProcessorConfigurationVisitor *visitor) const = 0;
};

} // namespace configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace configuration
{

class BatchSpanProcessorConfiguration;
class SimpleSpanProcessorConfiguration;
class ExtensionSpanProcessorConfiguration;

class SpanProcessorConfigurationVisitor
{
public:
virtual void VisitBatch(const BatchSpanProcessorConfiguration *model) = 0;
virtual void VisitSimple(const SimpleSpanProcessorConfiguration *model) = 0;
virtual void VisitExtension(const ExtensionSpanProcessorConfiguration *model) = 0;
};

} // namespace configuration
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "opentelemetry/sdk/configuration/span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand All @@ -15,6 +16,11 @@ namespace configuration
class ZipkinSpanExporterConfiguration : public SpanExporterConfiguration
{
public:
void Accept(SpanExporterConfigurationVisitor *visitor) const override
{
visitor->VisitZipkin(this);
}

std::string endpoint;
size_t timeout;
};
Expand Down
29 changes: 29 additions & 0 deletions sdk/include/opentelemetry/sdk/init/sdk_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
#pragma once

#include "opentelemetry/sdk/configuration/always_off_sampler_configuration.h"
#include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/configuration.h"
#include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/otlp_span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h"
#include "opentelemetry/sdk/configuration/span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h"
#include "opentelemetry/sdk/trace/exporter.h"
#include "opentelemetry/sdk/trace/processor.h"
#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/trace/tracer_provider.h"
Expand Down Expand Up @@ -40,6 +48,27 @@ class SdkBuilder
static std::unique_ptr<opentelemetry::sdk::trace::Sampler> CreateSampler(
const std::unique_ptr<opentelemetry::sdk::configuration::SamplerConfiguration> &model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> CreateOtlpSpanExporter(
const opentelemetry::sdk::configuration::OtlpSpanExporterConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> CreateZipkinSpanExporter(
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> CreateExtensionSpanExporter(
const opentelemetry::sdk::configuration::ExtensionSpanExporterConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> CreateSpanExporter(
const std::unique_ptr<opentelemetry::sdk::configuration::SpanExporterConfiguration> &model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor> CreateBatchSpanProcessor(
const opentelemetry::sdk::configuration::BatchSpanProcessorConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor> CreateSimpleSpanProcessor(
const opentelemetry::sdk::configuration::SimpleSpanProcessorConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor> CreateExtensionSpanProcessor(
const opentelemetry::sdk::configuration::ExtensionSpanProcessorConfiguration *model);

static std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor> CreateProcessor(
const std::unique_ptr<opentelemetry::sdk::configuration::SpanProcessorConfiguration> &model);

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/configuration/configuration_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ std::unique_ptr<Configuration> ConfigurationFactory::ParseFile(std::string filen
conf = ConfigurationFactory::Parse(in);
}

return Parse(in);
return conf;
}

std::unique_ptr<Configuration> ConfigurationFactory::ParseString(std::string content)
Expand Down
Loading

0 comments on commit 469bc0e

Please sign in to comment.