Skip to content

Commit c9e4d27

Browse files
committed
exporter cleanup
1 parent 3f1e66b commit c9e4d27

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ namespace metrics
1818
*/
1919
struct PrometheusExporterOptions
2020
{
21+
// Lookup environment variables
2122
PrometheusExporterOptions();
2223

24+
// No defaults
25+
PrometheusExporterOptions(void *);
26+
2327
// The endpoint the Prometheus backend can collect metrics from
2428
std::string url;
2529

exporters/prometheus/src/exporter_options.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ PrometheusExporterOptions::PrometheusExporterOptions()
7777
without_type_suffix(GetPrometheusWithoutTypeSuffix())
7878
{}
7979

80+
PrometheusExporterOptions::PrometheusExporterOptions(void *)
81+
: url(""),
82+
populate_target_info(true),
83+
without_otel_scope(false),
84+
without_units(false),
85+
without_type_suffix(false)
86+
{}
87+
8088
} // namespace metrics
8189
} // namespace exporter
8290
OPENTELEMETRY_END_NAMESPACE

exporters/prometheus/src/prometheus_pull_builder.cc

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,19 @@ void PrometheusPullBuilder::Register(opentelemetry::sdk::configuration::Registry
2626
}
2727

2828
std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> PrometheusPullBuilder::Build(
29-
const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration
30-
* /* model */) const
29+
const opentelemetry::sdk::configuration::PrometheusPullMetricExporterConfiguration *model) const
3130
{
32-
opentelemetry::exporter::metrics::PrometheusExporterOptions options;
33-
34-
#ifdef LATER
35-
// Expected
36-
options.url = model->xxx;
37-
options.populate_target_info = model->xxx;
38-
options.without_otel_scope = model->xxx;
39-
40-
// Configuration model
41-
options.xxx = model->host;
42-
options.xxx = model->port;
43-
options.xxx = model->without_units;
44-
options.xxx = model->without_type_suffix;
45-
options.xxx = model->without_scope_info;
46-
#endif
31+
opentelemetry::exporter::metrics::PrometheusExporterOptions options(nullptr);
32+
33+
std::string url(model->host);
34+
url.append(":");
35+
url.append(std::to_string(model->port));
36+
37+
options.url = url;
38+
options.populate_target_info = true;
39+
options.without_otel_scope = model->without_scope_info;
40+
options.without_units = model->without_units;
41+
options.without_type_suffix = model->without_type_suffix;
4742

4843
return PrometheusExporterFactory::Create(options);
4944
}

exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace exporter
1313
namespace zipkin
1414
{
1515

16+
// The endpoint to export to. By default the OpenTelemetry Collector's default endpoint.
1617
inline const std::string GetDefaultZipkinEndpoint()
1718
{
1819
const char *otel_exporter_zipkin_endpoint_env = "OTEL_EXPORTER_ZIPKIN_ENDPOINT";
@@ -36,8 +37,13 @@ enum class TransportFormat
3637
*/
3738
struct ZipkinExporterOptions
3839
{
39-
// The endpoint to export to. By default the OpenTelemetry Collector's default endpoint.
40-
std::string endpoint = GetDefaultZipkinEndpoint();
40+
// Lookup environment variables
41+
ZipkinExporterOptions() : endpoint(GetDefaultZipkinEndpoint()) {}
42+
43+
// No defaults
44+
ZipkinExporterOptions(void *) : endpoint("") {}
45+
46+
std::string endpoint;
4147
TransportFormat format = TransportFormat::kJson;
4248
std::string service_name = "default-service";
4349
std::string ipv4;

exporters/zipkin/src/zipkin_builder.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ void ZipkinBuilder::Register(opentelemetry::sdk::configuration::Registry *regist
3131
std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> ZipkinBuilder::Build(
3232
const opentelemetry::sdk::configuration::ZipkinSpanExporterConfiguration *model) const
3333
{
34-
ZipkinExporterOptions options;
34+
ZipkinExporterOptions options(nullptr);
3535

3636
options.endpoint = model->endpoint;
3737

38-
#ifdef LATER
39-
options.xxx = model->timeout;
40-
#endif
41-
4238
return ZipkinExporterFactory::Create(options);
4339
}
4440

0 commit comments

Comments
 (0)