Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ namespace metrics
*/
struct PrometheusExporterOptions
{
// Lookup environment variables
PrometheusExporterOptions();

// No defaults
PrometheusExporterOptions(void *);

// The endpoint the Prometheus backend can collect metrics from
std::string url;

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

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h"
#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/metrics/metric_reader.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace metrics
{

class OPENTELEMETRY_EXPORT PrometheusPullBuilder
: public opentelemetry::sdk::configuration::PrometheusPullMetricExporterBuilder
{
public:
static void Register(opentelemetry::sdk::configuration::Registry *registry);

std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> Build(
const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model)
const override;
};

} // namespace metrics
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
2 changes: 2 additions & 0 deletions exporters/prometheus/src/exporter_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ PrometheusExporterOptions::PrometheusExporterOptions()
without_type_suffix(GetPrometheusWithoutTypeSuffix())
{}

PrometheusExporterOptions::PrometheusExporterOptions(void *) : url("") {}

} // namespace metrics
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
49 changes: 49 additions & 0 deletions exporters/prometheus/src/prometheus_pull_builder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <memory>
#include <string>
#include <utility>

#include "opentelemetry/exporters/prometheus/exporter_factory.h"
#include "opentelemetry/exporters/prometheus/exporter_options.h"
#include "opentelemetry/exporters/prometheus/prometheus_pull_builder.h"
#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h"
#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/metrics/metric_reader.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace metrics
{

void PrometheusPullBuilder::Register(opentelemetry::sdk::configuration::Registry *registry)
{
auto builder = std::make_unique<PrometheusPullBuilder>();
registry->SetPrometheusPullMetricExporterBuilder(std::move(builder));
}

std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> PrometheusPullBuilder::Build(
const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) const
{
opentelemetry::exporter::metrics::PrometheusExporterOptions options(nullptr);

std::string url(model->host);
url.append(":");
url.append(std::to_string(model->port));

options.url = url;
options.populate_target_info = true;
options.without_otel_scope = model->without_scope_info;
options.without_units = model->without_units;
options.without_type_suffix = model->without_type_suffix;

return PrometheusExporterFactory::Create(options);
}

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

#pragma once

#include <memory>

#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h"
#include "opentelemetry/sdk/trace/exporter.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace zipkin
{

class OPENTELEMETRY_EXPORT ZipkinBuilder
: public opentelemetry::sdk::configuration::ZipkinSpanExporterBuilder
{
public:
static void Register(opentelemetry::sdk::configuration::Registry *registry);

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

} // namespace zipkin
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace exporter
namespace zipkin
{

// The endpoint to export to. By default the OpenTelemetry Collector's default endpoint.
inline const std::string GetDefaultZipkinEndpoint()
{
const char *otel_exporter_zipkin_endpoint_env = "OTEL_EXPORTER_ZIPKIN_ENDPOINT";
Expand All @@ -36,8 +37,13 @@ enum class TransportFormat
*/
struct ZipkinExporterOptions
{
// The endpoint to export to. By default the OpenTelemetry Collector's default endpoint.
std::string endpoint = GetDefaultZipkinEndpoint();
// Lookup environment variables
ZipkinExporterOptions() : endpoint(GetDefaultZipkinEndpoint()) {}

// No defaults
ZipkinExporterOptions(void *) : endpoint("") {}

std::string endpoint;
TransportFormat format = TransportFormat::kJson;
std::string service_name = "default-service";
std::string ipv4;
Expand Down
41 changes: 41 additions & 0 deletions exporters/zipkin/src/zipkin_builder.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <memory>
#include <string>
#include <utility>

#include "opentelemetry/exporters/zipkin/zipkin_builder.h"
#include "opentelemetry/exporters/zipkin/zipkin_exporter_factory.h"
#include "opentelemetry/exporters/zipkin/zipkin_exporter_options.h"
#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_builder.h"
#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h"
#include "opentelemetry/sdk/trace/exporter.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace zipkin
{

void ZipkinBuilder::Register(opentelemetry::sdk::configuration::Registry *registry)
{
auto builder = std::make_unique<ZipkinBuilder>();
registry->SetZipkinSpanBuilder(std::move(builder));
}

std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> ZipkinBuilder::Build(
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const
{
ZipkinExporterOptions options(nullptr);

options.endpoint = model->endpoint;

return ZipkinExporterFactory::Create(options);
}

} // namespace zipkin
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Loading